Bundle Repositories and Bundle Class Loaders

Bundle repositories contain bundles that are not specific to any one application but that might need to be shared.

For example, the following list contains some of the bundles that are used by the InfoSphere® MDM EBA:
 com.ibm.pdq;version=2.25.95, 
 com.ibm.icu;version=4.8.1, 
 org.apache.commons.codec;version=1.5.0, 
 org.apache.commons.pool;version=1.5.6, 
 org.apache.ws.xmlschema.core;version=2.0.0 

There are two types of bundle repositories that can be used by the InfoSphere MDM application: a development bundle repository and a runtime bundle repository. Both share common traits, except that one is contained in the MDM Workbench, and the other is contained in a IBM® WebSphere® Application Server OSGi container. You can also create a single repository to serve both purposes.

Using a bundle repository enables your application to access bundles that contain any third party JAR files that are needed without having to place all third party JAR files in a separate project, and although this worked in traditional Java™ and JEE applications, in which a class loader’s scope is the entire application, this approach is not practical for OSGi.

The approach in OSGi is modular. Each bundle has its own class loader, and each class loader can only see classes inside the bundle or inside classes in packages that are explicitly imported by the bundle.

When you create bundles out of the third party JAR files, or find bundle versions of existing third party JAR files and put them into a bundle repository, you enable them to be shared. You do not need to explicitly add each third party JAR to every bundle that uses it, and so you can avoid potential bloating of the application size, and there is no need to track down and replace any updated third-party JAR files in those bundles to which you originally added them.