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


If you want to pass information between 2 bundles which are not simulataneously installed, you will need to go through some persistent storage. Bundle D can provide that storage but the form of storage will need to be non-object. Some form of flattening or serialization.

Also, having bundle D hold an object from the uninstalled bundle B is not very well behaved since bundle B cannot be garbage collected. The object reference will pin all of bundle B's class objects and class loader in memory.
BJ Hargrave
Senior Technical Staff Member, IBM
OSGi Fellow and CTO of the
OSGi Alliance
hargrave@xxxxxxxxxx

office: +1 386 848 1781
mobile: +1 386 848 3788




"Thomas Fischer" <fischer@xxxxxxxxxxxxxxxxxxx>
Sent by: equinox-dev-bounces@xxxxxxxxxxx

2007-04-12 18:01

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

To
"'Equinox development mailing list'" <equinox-dev@xxxxxxxxxxx>
cc
Subject
AW: [equinox-dev] ServiceListener ignored after Service Replacement





Hi,
Thank you very much for the fast responses to my question.

The approach Thomas Watson suggested worked as well as this Solution, but this one fulfills my requirements for transparent service exchanges better, due to the fact that Bundle A does not get down to INSTALLED State for rewiring and so does not lose its state. But this leads to another question:

I have some fields in the old Bundle B, which I want to copy to the new Bundle B* controlled via a Bundle D. But if I assume it the right way, there is no possible way to pass an object instantiated in B containing the fields to B* via D, because B* could not resolve the type of the Object being instantiated in the Classloader of B and therefore not visible for B*. (I get a ClassCast Exception again)

Is there any framework functionality regarding this issue which I may have overlooked?

Regards from Erlangen (Germany),
Thomas Fischer

PS: Again sorry for bothering you again, but I am writing my Master Thesis about OSGi as a dynamic component/service framework and these issues are the last open questions I have, which no one was able to answer, yet.


-----UrsprÃngliche Nachricht-----
Von: equinox-dev-bounces@xxxxxxxxxxx [mailto:equinox-dev-bounces@xxxxxxxxxxx] Im Auftrag von BJ Hargrave
Gesendet: Donnerstag, 12. April 2007 15:12
An: Equinox development mailing list
Betreff: Re: [equinox-dev] ServiceListener ignored after Service Replacement

It may be that bundle B* uses a different service interface class object for the service. Bundle A may only have class visibility to the service interface class for bundle B's service.

The framework is required to filter service events based upon class visibility of the receiver. So your bundle A may not receive the event because bundle A does not have class visibility to the service registered by B*.

To test this, change bundle A to use an AllServiceListener. If you get the ServiceEvent for bundle B* but get a ClassCastException when trying to cast the Object to service interface type, then we have confirmed the situation.

To solve this, both bundle B and B* need to use the same package which defines the service interface class. This can be done in several ways. One is to put that package in a 3rd bundle, C. Then A, B and B* import that package. Another way is for B and B* to contain the package and have B and
B* both export AND import that package. Then A will import from B. When B is uninstalled and B* installed, B* will import the package from the old B (without a package refresh, B will remain in the system to satisfy class loads from its exported packages - this is a gross simplification, read the spec for more details). I recommend the first choice, bundle C.

BJ Hargrave
Senior Technical Staff Member, IBM
OSGi Fellow and CTO of the OSGi Alliance hargrave@xxxxxxxxxx

office: +1 386 848 1781
mobile: +1 386 848 3788




"Thomas Fischer" <fischer@xxxxxxxxxxxxxxxxxxx> Sent by: equinox-dev-bounces@xxxxxxxxxxx
2007-04-12 08:37
Please respond to
Equinox development mailing list <equinox-dev@xxxxxxxxxxx>


To
<equinox-dev@xxxxxxxxxxx>
cc

Subject
[equinox-dev] ServiceListener ignored after Service Replacement






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
equinox-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/equinox-dev