Announcement Announcement Module
No announcement yet.
Spring, OSGI, Virgo and SynchronousBundleListener Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring, OSGI, Virgo and SynchronousBundleListener

    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?
    Many thanks in advance,

  • #2
    I took another approach which avoids this issue. I publish the Os as services of B2 and maintain a <list> of them, with a listener whose bind and unbind methods register the O with B1.

    This is great. Thanks!