Sharing common OSGi bundles for Liberty

You can share common OSGi bundles by placing them in a local directory or remote repository and configuring the server.xml file for your server, so that those common OSGi bundles are available to your OSGi applications.

Local Directory

Procedure

  • Create a directory in your file system and place all the common OSGi bundles into the directory.
  • Add the following lines into the server.xml file.
      <bundleRepository> 
       <fileset dir="directory_path" includes="*.jar"/> 
      </bundleRepository> 
    Where directory_path is the path to the directory that contains the common OSGi bundles.
    Note: Some remote bundle repositories do not support service-based provisioning. See Use Blueprint to enable service-based provisioning. Rational Asset Manager will correctly model Blueprint services and references, but most Apache Maven-based repositories will not. In these cases, rather than separating API and implementation bundles, you can merge Blueprint service-providing and API bundles so that clients' package dependencies on service APIs also result in the service implementations being provisioned.
  • Define a dependency on the common bundle using import phrase in the manifest.mf file of your OSGi application.

Remote Repository

You can access bundles held in a remote OSGi repository which supports the OSGi Bundle Repository (OBR) format.

Procedure

Add the following lines into your server.xml file.
<bundleRepository location="URL" />
Where URL points to the location of an OBR XML file. The following protocols are supported:
  • HTTP
  • HTTPS
  • file
Note: If you specify a relative file URL, then it is treated as being relative to the value of ${server.config.dir} and resolved to a local OBR XML file.

You can define a remote and local repository at the same time using both a location attribute and nested fileset tags within the same bundleRepository entry.