[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [equinox-dev] ServiceListener ignored after Service Replacement

As Neil said, make sure the newly installed bundle B is started.  If you are already starting bundle B then I think something else is occurring.

In OSGi uninstalls and updates are "lazy".  Bundle A got resolved and wired to packages from the previously installed version of B (by using Import-Package/Require-Bundle etc.).  You uninstalled bundle B but the framework is not allowed to completely remove the classloader of Bundle B from the framework because Bundle A is currently wired to and using the packages from Bundle B.  Bundle B's classloader cannot be completely removed from the framework until a org.osgi.service.packageadmin.PackageAdmin.refreshPackages is called.  This will force Bundle A to stop using the old packages from the uninstalled version of bundle B and will then allow Bundle A to get resolved and wired to the newly installed version of Bundle B.

The service registry in OSGi filters service events based on package sources.  If the framework determines that the publishing bundle is wired to a different version of a package than the listening bundle then the service event is not delivered to that ServiceListener.  See org.osgi.framework.ServiceReference.isAssignableTo(Bundle, String) for more information.  In your case Bundle A is wired to old versions of the packages from Bundle B and will not be able to see the service registered by the new version of Bundle B.

After uninstalling Bundle B and installing a new version run the "refresh" command from the console.  This runs the PackageAdmin.refreshPackages command.  This should force Bundle A to be wired to the new version of Bundle B.


"Neil Bartlett" <njbartlett@xxxxxxxxx>
Sent by: equinox-dev-bounces@xxxxxxxxxxx

04/12/2007 07:46 AM

Please respond to
Equinox development mailing list <equinox-dev@xxxxxxxxxxx>

"Equinox development mailing list" <equinox-dev@xxxxxxxxxxx>
Re: [equinox-dev] ServiceListener ignored after Service Replacement

You said that bundle B* is "installed". Do you mean "started"? If B* is
only installed but not activated, then it cannot register a service, and
naturally your ServiceListener will not be notified.

If that's not the problem, then check that the service registered by B*
matches the filter under which A is listening. Depending on the filter you
have used in the addServiceListener() call, you might not be matching B*'s
service, e.g. if the properties are a little different.

Also take a look at the output of the Equinox commands "ss" and
"services". This might show up something useful.


> Hi,
> maybe this is just a stupid simple question, and I just don't see the
> solution, if that's the matter sorry for bothering you.
> But here the scenario:
> I have 2 bundles A and B, A is using a service exported and registered by
> B.
> The Service object used in A is wrapped by a dynamic proxy for managing
> the
> service object and some synchronization issues. This proxy registers a
> Service listener, using the Context of Bundle A, to react on Service
> changes
> in B and there is the problem:
> If bundle B gets uninstalled everything works fine, the Listener gets
> called
> on the UNREGISTERING Event, the service object in the proxy is freed, but
> if
> a new bundle B*, implementing and exporting the service exported by former
> B, is installed, the Listener doesn't get called on the REGISTERED Event
> and
> so the Proxy cannot do its work and react to the again available Service.
> What do I miss? Is there any special filtering done in the equinox
> implementation?
> Regards,
> Thomas Fischer
> _______________________________________________
> equinox-dev mailing list
> equinox-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/equinox-dev

equinox-dev mailing list