On 4/6/12 6:17 PM, Matias SM wrote:
Hi everybody,
As the subject of this thread tries to states, my question is regarding objects created through an embedded framework and how safe is to use them after the bundle providing their classes is updated or uninstalled.

I'm trying to replace part of an application with OSGi by means of an embedded framework. The idea is that OSGi will empower the application with multiple class versions handling. Then the application will create objects from classes provided by different bundles and use them through a common interface (shared between the application and the embedded framework).

What I want to know is if there is any danger and what (mis)behavior should I expect if/when a bundle providing some classes is uninstalled or updated (and refreshed). I know that the objects will retain their reference to the classes (and classloader), and thus, I would expect there is no problem. But since I'm not an expert neither in OSGi nor Java, I wanted to get some insight from you (the expert ones). I've read a previous thread about objects and unisntalled services that created them [1] that (I think) confirms what I suspect. However, the thread continues with a discussion about how the invalidation of those objects should be enforced, and I want to know why my objects should be invalidated and what are the dangers of not doing so.

It wouldn't be a good idea to keep using objects from a bundle that has been uninstalled or updated. You will likely end up with class cast errors and/or class loading errors (e.g., if the object you are using causes another class load, which is possible since they are done on-demand not in advance, then it will fail since the JAR file associated with the bundle may not even exist anymore). Further, the functionality provided by the object may no longer be stable if it actually assumes it is installed in a framework.

With simple objects, you have less risk, but the need for additional class loads is the trickiest aspect and something you cannot easily deduce unless you're intimately familiar with the class' code and know it causes all class loads at some particular point in time and won't trigger any more. (And I'm not talking about explicit class loads, but implicit class loads caused simply by executing the code of the object's class.)

-> richard


Hope I've been clear enough about my doubt.
Thank you in advance for any comment about this.
Kind regards

[1] https://mail.osgi.org/pipermail/osgi-dev/2011-February/002966.html


_______________________________________________
OSGi Developer Mail List
[email protected]
https://mail.osgi.org/mailman/listinfo/osgi-dev
_______________________________________________
OSGi Developer Mail List
[email protected]
https://mail.osgi.org/mailman/listinfo/osgi-dev

Reply via email to