Wednesday, April 8, 2009

Uses directive in OSGi

Uses directive is very important when you shift to versioning of jars, that is when two bundles share the same class.

A runtime type is defined by the combination of the type's fully qualified class name and the class loader that defined the type. If the same fully qualified class name is defined by two distinct class loaders, then this produces two incompatible runtime types. This incompatibility causes runtime errors if the two types come into contact. For example, attempting to cast one of these types to the other will result in a class cast exception.

The conflict arises when one bundle(A) imports one version of the class from bundle ( B v1.0) and another bundle(C) depending on bundle A imports a class from different version of class from (B v 2.0) .

This can be solved by mentioning strict dependencies on the imports , but when the dependency tree gets huge this will be difficult to manage , and hence can be easily solved by the uses attribute.

The following article has detailed explanation on the uses attribute and how errors on that can be diagnosed.

Ref:

http://olegz.wordpress.com/documents-and-articles/osgi-uses/

http://blog.springsource.com/2008/10/20/understanding-the-osgi-uses-directive/

http://blog.springsource.com/2008/11/22/diagnosing-osgi-uses-conflicts/

No comments:

 
Free Domain Names @ .co.nr!