LibraryLink ToToggle FramesPrintFeedback

Packaging and Installing an Application

There are a number of tools available and the different OSGi containers use varying deployment mechanisms. However, the basic steps to package and deploy applications into an OSGi container are the same:

Once your bundles are installed, you can start and stop them using the container's commands. You can also upgrade them in place when needed.

Spring Dynamic Modules for OSGi Service Platforms(Spring-DM) scans bundles in an OSGi container and automatically creates a Spring application context for any bundles that contains a Spring XML file in its META-INF/spring folder. It will inject all of the beans defined in the configuration file into the application context. For JAX-WS server, you would include a jaxws:endpoint element for each service provider your application exposes. Spring-DM injects them into the application context and publish the endpoints when the bundle is started.

Before using Spring-DM you must make sure the required bundles are installed into your OSGi container. You must also make sure they are started. FUSE ESB and include support for Spring-DM as part of their default configuration. If your container does not include Spring-DM support you can download it from http://www.springsource.org/osgi.

[Important]Important

When using Spring-DM to publish endpoints you must include the following DynamicImport-Package statement in the bundle's manifest:

DynamicImport-Package: org.apache.cxf.*

This allows the Spring framework to construct the proper FUSE Services Framework objects.

The org.osgi.framework .BundleActivator is an OSGi API used by the OSGi framework when it starts and stops bundles. As shown in Example 4.1, it has two methods that need to be implemented.


The start() method is called when the container starts the bundle. This is where you would instantiate and publish any service provider endpoints exposed by a server application. For a client application, this is the method that would instantiate the client's application logic.

The stop() method is called when the container stops the bundle. This is where you would stop any endpoints exposed by a server.

When using a bundle activator you need to add the Bundle-Activator property to the bundle's manifest. This property tells the container which class in the bundle to use when activating the bundle.

For more information on publishing service provider endpoints see Publishing a Service in Developing Applications Using JAX-WS.

You can hand edit the manifest files for each of your application's bundles and manually assemble them using the standard Java mechanism for creating JARs. Hand editing a manifest is a tedious and error prone process and is not recommended. You should use one of the many tools available for creating OSGi bundles.

The bnd tool from Peter Kriens is powerful and freely available. It automates the construction of OSGi bundle manifests by introspecting the contents of the classes being packaged in the bundle. Using the knowledge of the classes contained in the bundle, the tool can calculate the proper values to populate the Import-Packages and the Export-Package properties in the bundle manifest.

The bnd tool can be used as an Ant task and is the foundation for the Maven bundle plug-in from Apache Felix.

The FUSE Services Framework core components are included in an OSGi bundle called org.apache.cxf.cxf-bundle.

[Tip]Tip

FUSE ESB and install the org.apache.cxf.cxf-bundle bundle by default.

FUSE Services Framework applications depend on a number of runtime packages. Because of the complex nature of the dependencies in FUSE Services Framework, you cannot rely on the bnd tool to automatically determine the needed imports. You will need to explicitly declare them.

You need to import the following packages into your bundle: