Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [equinox-dev] is this a service tracker bug?

Mark,

This is because of the pending removal of the old class loader from bundle A which bundle B is still wired to for package bundlea.service. You do not see the new service from bundle B because you would get a ClassCastException. The Framework filters out services that it knows you do not have the correct package wiring for. The new content for the service is loaded from the new class loader of Bundle A. But since Bundle B is still wired to the old content of Bundle A it will not see the service until it is refreshed.

A refresh operation will rewire Bundle B so that it gets the new content from Bundle A and everybody will be happy.

Tom



equinox-dev-bounces@xxxxxxxxxxx wrote on 01/25/2008 10:33:33 AM:

>
> This is driving me mad. I have two bundles A and B. B track the
> service offered by A.
>
> However if I call update on A then I get a remove Service
> notification but no add Service notification - that is until I issue
> a refresh command ? is this a bug?
>
> I have written the same simple code 10 time .. see the results.
>
> I have attached the two bundles and the two eclipse plugin projects
> (as one zip) - just in case a Eclipse/OSGi guru like yourself can
> figure it out?
>
> ========================================
>
> [image removed] [image removed] C:\eg>java -jar equinox.osgi.jar -console
>
> osgi> ss
>
> Framework is launched.
>
> id      State       Bundle
> 0       ACTIVE      org.eclipse.osgi_3.4.0.v20071207
>
> osgi> install file:bundleA_1.0.0.jar
> Bundle id is 1
>
> osgi> install file:bundleB_1.0.0.jar
> Bundle id is 2
>
> osgi> ss
>
> Framework is launched.
>
> id      State       Bundle
> 0       ACTIVE      org.eclipse.osgi_3.4.0.v20071207
> 1       INSTALLED   bundleA_1.0.0
> 2       INSTALLED   bundleB_1.0.0
>
> osgi> start 1
>
> osgi> start 2
> addingService
>
> osgi> stop 1
> removedService
>
> osgi> start 1
> addingService
>
> osgi> update 1
> removedService <----- no add !
>
> osgi> stop 2
>
> osgi> start 2
>
> osgi> refresh <- Only get add after refresh
>
> osgi> addingService
>
>
> osgi>

>

> On 25/01/2008, Neil Bartlett <njbartlett@xxxxxxxxx > wrote:
> Hi Mark,
>
> Many thanks for your kind words!

>
> Regarding the service tracker problem... that's not the behaviour I
> would expect to see, and I've just put together a small test case
> which prints a message in the addingService, removedService and
> modifiedService methods of the ServiceTracker. When I update the
> bundle that registered the service, I see the following:

>
> osgi> update 5
> Removed service
> Added service
>
> osgi>

>
> Which seems to be the way it should work. I suggest posting a
> message to the equinox-dev mailing list ( https://dev.eclipse.org/
> mailman/listinfo/equinox-dev) explaining the problem in detail and
> including a minimal code sample that reproduces the problem.

>
> Regards,

> Neil
>
> On 25 Jan 2008, at 13:42, Mark wrote:

>
> Neil,
>
> First off I have to thank you in a big way, because it was you
> articles that got me up and running on OSGI.
>
> I am also glad that you are putting together a book... because I was
> thinking about it myself...in practice or in action!, would you like
> some help?
>
> ..Anyway the reason for this mail...
>
> I was looking at the Listeners Considered Harmful: The "Whiteboard"
> Pattern white paper, and I put together a very simple two bundle
> example (on Equinox),
>
> Bundle A (offers a service)
> Bundle B (consumes service A, using a Service Tracker)
>
> So far so good, and not exactly rocket science.
>
> However this morning I discovered that if you update A - then you
> must refresh A in order for B to receive the added service event.
>
> This came as a surprise, go I Googled a while, and came up short. So
> I was wondering if you had some words of widom for me on this ?
>
> Kind Regards
>
> Mark

>
> [attachment "bundleA_1.0.0.jar" deleted by Thomas Watson/Austin/IBM]
> [attachment "bundleB_1.0.0.jar" deleted by Thomas Watson/Austin/IBM]
> [attachment "eclipe-projects.zip" deleted by Thomas Watson/Austin/IBM]
> _______________________________________________
> equinox-dev mailing list
> equinox-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/equinox-dev


Back to the top