Share java object between two forms using Spring IoC

Posted by Vladimir on Stack Overflow See other posts from Stack Overflow or by Vladimir
Published on 2010-05-02T15:26:39Z Indexed on 2010/05/02 16:17 UTC
Read the original article Hit count: 260

Filed under:
|

I want to share java object between two forms using Spring IoC. It should acts like Registry:

Registry.set("key", new Object());
// ...
Object o = Registry.get("key");
// ...
Registry.set("key", new AnotherObject()); // rewrite old object

I tried this code to register bean at runtime:

applicationContext.getBeanFactory().registerSingleton("key", object);

but it does not allow to rewrite existing object (result code for checking and deleting existing bean is too complicated)...

PS I am Java newbie, so mb I am doing it wrong and I should not use IoC at all... any help is appreciated...

© Stack Overflow or respective owner

Related posts about java

Related posts about spring