Share java object between two forms using Spring IoC
- by Vladimir
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...