javabeans - spring destroy bean manually instead of ctx.close() -


is possible tell container of spring destroy specific bean (prototype) in order save memory?

i dont want user ctx.close() in order see bean destroyed, rather on runtime.

if understand correctly want remove bean defined in ctx @ runtime, use beandefinitionregistry done, beandefinitionregistry has method of removebean() takes bean name parameter.

beandefinitionregistry factory =     (beandefinitionregistry) applicationctx.getautowirecapablebeanfactory(); 

then

((defaultlistablebeanfactory) beanfactory).destroysingleton("mybean"); 

edit

reference http://static.springsource.org/spring/docs/3.0.x/api/org/springframework/beans/factory/support/beandefinitionregistry.html#removebeandefinition%28java.lang.string%29


Comments

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -