|SynchronousBundleListener [message #997428]
||Mon, 07 January 2013 08:34
| Daniel McGreal
Registered: January 2013
Hi, I have a question regarding the use of SynchronousBundleListeners in a Virgo 3.5 environment.|
I have a service, S, running in a bundle, B1 which receives anonymously created objects, O, from a second bundle B2. I need to make this environment react to the the lifecycle of both B1 and B2. So; when B1 is refreshed, the object created by B2 needs to be registered again with the new service S, when B2 is refreshed I need to deregister O such that when B2 initialises again and registers a new O there are not any references to the previous anonymous object in S.
Supposing this is reasonable, I have a SynchronousBundleListener which deregisters O from S when B2 is BundleEvent.STOPPING and reregisters O into S when B1 is BundleEvent.STARTED.
This usually works fine, sometimes however, S's proxy has been destroyed during my SynchronousBundleListener's response to the BundleEvent.STOPPING. My understanding has been that the SynchronousBundleListener should be fully executed before further lifecycle events take place.
How have I misunderstood, and is there a different/standard way of achieving the above? I'm thinking of publishing my Os as services and use a list of them and binding methods in S.
Many thanks in advance,