modify spring bean programatically in runtime using ApplicationContext
<p>I need to modify some spring bean in runtime by webservice. Im using ApplicationContext .</p>

<pre><code>ConfigurableApplicationContext configContext = (ConfigurableApplicationContext)applicationContext;

ConfigurableListableBeanFactory registery = configContext.getBeanFactory();

registery.registerSingleton("XXX", new MyNewBeanDefintion());
</code></pre>

<p>in my @Configuration class there is </p>

<pre><code>@Bean
public ParentClass campaignSelection(){
if(type.equals("X")) {

return new X();

}
else if(type.equals("Y")){

return new Y();
}

    return null;

}
</code></pre>

<p>with simply </p>

<pre><code>public interface ParentClass {

public Item selectOneItem();

}

public class X implements ParentClass {

@Override
public Item selectOneItem() {
// return item
}
</code></pre>

<p>}</p>

<pre><code>public class Y implements ParentClass {
@Override
public Item selectOneItem() {
 // return item
}
}
</code></pre>

<p>and i need i need the bean to switch between X , Y in runtime</p>