[jboss-dev-forums] [JBoss OSGi Development] - 3.6.3 Optional Packages

thomas.diesler@jboss.com do-not-reply at jboss.com
Fri Aug 28 15:18:48 EDT 2009


3.6.3 Optional Packages

https://jira.jboss.org/jira/browse/JBOSGI-143

A bundle can indicate that it does not require a package to resolve correctly,
but it may use the package if it is available. For example, logging is important,
but the absence of a log service should not prevent a bundle from running.
Optional imports can be specified in the following ways:

Dynamic Imports – The DynamicImport-Package header is intended to
look for an exported package when that package is needed. The key use
case for dynamic import is the Class forName method when a bundle
does not know in advance the class name it may be requested to load.

Resolution Directive – The resolution directive on an import definition
specifying the value optional. A bundle may successfully resolve if a
suitable optional package is not present.

The key difference between these two mechanisms is when the wires are
made. An attempt is made to establish a wire for a dynamic import every
time there is an attempt to load a class in that package, whereas the wire for
a resolution optional package may only be established when the bundle is
resolved.

View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4252390#4252390

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4252390




More information about the jboss-dev-forums mailing list