|
From: <jue...@we...> - 2004-06-03 11:50:15
|
It's not in the ApplicationContext interface itself, because this is = meant to be a client view of the context. Simply cast the context = reference to ConfigurableApplicationContext; you can then invoke the = close method there. Juergen -----Original Message----- From: spr...@li... [mailto:spr...@li...]On Behalf Of Jozsa Kristof Sent: Thursday, June 03, 2004 1:14 PM To: spr...@li... Subject: [Springframework-developer] about closing bean container Hi, I started to wonder today why ApplicationContext interface doesn't=20 include the close() method to dispose the singleton beans in the bean=20 container. Is there any reason not to expose this method? On the other=20 side, wouldn't it make sense to add a shutdown hook to clear up any=20 still-existing bean containers at least on jvm exit? dyn --=20 .Digital.Yearning.for.Networked.Assassination.and.Xenocide. ------------------------------------------------------- This SF.Net email is sponsored by the new InstallShield X. From Windows to Linux, servers to mobile, InstallShield X is the one installation-authoring solution that does it all. Learn more and evaluate today! http://www.installshield.com/Dev2Dev/0504 _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer |
|
From: <jue...@we...> - 2004-06-03 12:37:46
|
If Spring manages your application context, like in the web app or EJB = case, the respective context loaders will properly close the context on = shutdown. If you're instantiating your own context, like a = ClassPathXmlApplicationContext, you're responsible for closing it on = shutdown of your app. This typically happens in the lifecycle code of a = standalone app. ConfigurableApplicationContext context =3D new = ClassPathXmlApplicationContext(...); // run app context.close(); Nevertheless, none of your application objects in the context need to = know about the ConfigurableApplicationContext interface. If at all, they = work with the ApplicationContext interface. Juergen -----Original Message----- From: spr...@li... [mailto:spr...@li...]On Behalf Of Jozsa Kristof Sent: Thursday, June 03, 2004 2:19 PM To: spr...@li... Subject: Re: [Springframework-developer] about closing bean container Ok.. and what about disposing the container's singletons from a shutdown = hook for non-web apps? If close() is not meant for the client view of=20 the context, than the server should take care about it imho. dyn j=FCrgen h=F6ller [werk3AT] wrote: > It's not in the ApplicationContext interface itself, because this is = meant to be a client view of the context. Simply cast the context = reference to ConfigurableApplicationContext; you can then invoke the = close method there. >=20 > Juergen >=20 >=20 > -----Original Message----- > From: spr...@li... > [mailto:spr...@li...]On = Behalf > Of Jozsa Kristof > Sent: Thursday, June 03, 2004 1:14 PM > To: spr...@li... > Subject: [Springframework-developer] about closing bean container >=20 >=20 > Hi, >=20 > I started to wonder today why ApplicationContext interface doesn't=20 > include the close() method to dispose the singleton beans in the bean=20 > container. Is there any reason not to expose this method? On the other = > side, wouldn't it make sense to add a shutdown hook to clear up any=20 > still-existing bean containers at least on jvm exit? >=20 > dyn --=20 .Digital.Yearning.for.Networked.Assassination.and.Xenocide. ------------------------------------------------------- This SF.Net email is sponsored by the new InstallShield X. From Windows to Linux, servers to mobile, InstallShield X is the one installation-authoring solution that does it all. Learn more and evaluate today! http://www.installshield.com/Dev2Dev/0504 _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer |
|
From: Jozsa K. <dy...@on...> - 2004-06-03 12:59:16
|
Ok. My point was to add the shutdown hook thing for=20 ClassPathXmlApplicationContext, but maybe some won't like this=20 functionality, so I'll do it myself within my app / abstract testcase. Thanks for the explanation, dyn j=FCrgen h=F6ller [werk3AT] wrote: > If Spring manages your application context, like in the web app or EJB = case, the respective context loaders will properly close the context on s= hutdown. >=20 > If you're instantiating your own context, like a ClassPathXmlApplicatio= nContext, you're responsible for closing it on shutdown of your app. This= typically happens in the lifecycle code of a standalone app. >=20 > ConfigurableApplicationContext context =3D new ClassPathXmlApplicationC= ontext(...); > // run app > context.close(); >=20 > Nevertheless, none of your application objects in the context need to k= now about the ConfigurableApplicationContext interface. If at all, they w= ork with the ApplicationContext interface. >=20 > Juergen >=20 >=20 > -----Original Message----- > From: spr...@li... > [mailto:spr...@li...]On Behalf > Of Jozsa Kristof > Sent: Thursday, June 03, 2004 2:19 PM > To: spr...@li... > Subject: Re: [Springframework-developer] about closing bean container >=20 >=20 > Ok.. and what about disposing the container's singletons from a shutdow= n=20 > hook for non-web apps? If close() is not meant for the client view of=20 > the context, than the server should take care about it imho. >=20 > dyn >=20 > j=FCrgen h=F6ller [werk3AT] wrote: >=20 >>It's not in the ApplicationContext interface itself, because this is me= ant to be a client view of the context. Simply cast the context reference= to ConfigurableApplicationContext; you can then invoke the close method = there. >> >>Juergen >> >> >>-----Original Message----- >>From: spr...@li... >>[mailto:spr...@li...]On Behalf >>Of Jozsa Kristof >>Sent: Thursday, June 03, 2004 1:14 PM >>To: spr...@li... >>Subject: [Springframework-developer] about closing bean container >> >> >>Hi, >> >>I started to wonder today why ApplicationContext interface doesn't=20 >>include the close() method to dispose the singleton beans in the bean=20 >>container. Is there any reason not to expose this method? On the other=20 >>side, wouldn't it make sense to add a shutdown hook to clear up any=20 >>still-existing bean containers at least on jvm exit? >> >>dyn >=20 >=20 >=20 --=20 .Digital.Yearning.for.Networked.Assassination.and.Xenocide. |
|
From: Jozsa K. <dy...@on...> - 2004-06-03 12:12:16
|
Ok.. and what about disposing the container's singletons from a shutdown=20 hook for non-web apps? If close() is not meant for the client view of=20 the context, than the server should take care about it imho. dyn j=FCrgen h=F6ller [werk3AT] wrote: > It's not in the ApplicationContext interface itself, because this is me= ant to be a client view of the context. Simply cast the context reference= to ConfigurableApplicationContext; you can then invoke the close method = there. >=20 > Juergen >=20 >=20 > -----Original Message----- > From: spr...@li... > [mailto:spr...@li...]On Behalf > Of Jozsa Kristof > Sent: Thursday, June 03, 2004 1:14 PM > To: spr...@li... > Subject: [Springframework-developer] about closing bean container >=20 >=20 > Hi, >=20 > I started to wonder today why ApplicationContext interface doesn't=20 > include the close() method to dispose the singleton beans in the bean=20 > container. Is there any reason not to expose this method? On the other=20 > side, wouldn't it make sense to add a shutdown hook to clear up any=20 > still-existing bean containers at least on jvm exit? >=20 > dyn --=20 .Digital.Yearning.for.Networked.Assassination.and.Xenocide. |
|
From: <rn...@co...> - 2004-06-03 13:25:29
|
I have a class that is responsible for creating a ClasspathXmlApplicationContext and allow access to it as a ApplicationContext. Clients receive the ApplicationContext and ues the normal getBean() methods, etc. The originating class establishes the shutdown hook as it internally keeps the reference as a ConfigurableApplicationContext (since ClassPath... is both). I only do this for legacy code where pushing dependencies in everywhere would be a problem. I don't like creating a factory for the Spring context (using the old static getInstance() pattern), but I'm constrained by current architecture. So, in summary, the class that constructs your application context can create a shutdown hook right there, as you know it implements the close() method, everyone else should get a reference to ApplicationContext, because you don't want just anyone removing your singletons. B. Jozsa Kristof wrote: > Ok.. and what about disposing the container's singletons from a shutdown > hook for non-web apps? If close() is not meant for the client view of > the context, than the server should take care about it imho. > > dyn > > jürgen höller [werk3AT] wrote: > >> It's not in the ApplicationContext interface itself, because this is >> meant to be a client view of the context. Simply cast the context >> reference to ConfigurableApplicationContext; you can then invoke the >> close method there. >> >> Juergen >> >> >> -----Original Message----- >> From: spr...@li... >> [mailto:spr...@li...]On Behalf >> Of Jozsa Kristof >> Sent: Thursday, June 03, 2004 1:14 PM >> To: spr...@li... >> Subject: [Springframework-developer] about closing bean container >> >> >> Hi, >> >> I started to wonder today why ApplicationContext interface doesn't >> include the close() method to dispose the singleton beans in the bean >> container. Is there any reason not to expose this method? On the other >> side, wouldn't it make sense to add a shutdown hook to clear up any >> still-existing bean containers at least on jvm exit? >> >> dyn > > > |