javajunky
03-07-2007, 02:44 PM
Hi,
I've a singleton object defined as :
<object id="ApplicationStateManagerThing" type="ApplicationStateManagerThing" singleton="true" lazy-init="false" destroy-method="destroy" >
<property name="DBConfiguration" ref="DBConfig"/>
</object>
I'm listening for Context refresh events in this class, which works. i.e. when I do a refresh on the current Context, the code in this object [A] gets executed (which is great). However the refresh causes a new instance of this singleton to be constructed [B] [as one would expect].
The next time a refresh occurs on the application context, *both* instance [A] and [B] are triggered ? This behaviour was un-expected by myself, as it means that I end up doing the same thing multiple times, am I being stupid should I define an object that sits outside of the application-context to do this sort of thing ?
I'm considering doing what I'm currently doing in the IApplicationContextAware object as an Object PostProcessor, even though I'm not modifying objects, but I'm modifying the Application context ?!?
(just fyi, the purpose of the object is to modify the ApplicationContext to add in some spring objects that aren't available at the normal time ;) )
http://forum.springframework.net/showthread.php?t=1666
I've a singleton object defined as :
<object id="ApplicationStateManagerThing" type="ApplicationStateManagerThing" singleton="true" lazy-init="false" destroy-method="destroy" >
<property name="DBConfiguration" ref="DBConfig"/>
</object>
I'm listening for Context refresh events in this class, which works. i.e. when I do a refresh on the current Context, the code in this object [A] gets executed (which is great). However the refresh causes a new instance of this singleton to be constructed [B] [as one would expect].
The next time a refresh occurs on the application context, *both* instance [A] and [B] are triggered ? This behaviour was un-expected by myself, as it means that I end up doing the same thing multiple times, am I being stupid should I define an object that sits outside of the application-context to do this sort of thing ?
I'm considering doing what I'm currently doing in the IApplicationContextAware object as an Object PostProcessor, even though I'm not modifying objects, but I'm modifying the Application context ?!?
(just fyi, the purpose of the object is to modify the ApplicationContext to add in some spring objects that aren't available at the normal time ;) )
http://forum.springframework.net/showthread.php?t=1666