ServiceMix provides a number of different options which you can use to deploy artifacts. In this section we'll look at these options, and show you how to use these.
ServiceMix 4, deployment options
||ServiceMix 4 is built around OSGi and ServiceMix 4 also allows you to deploy your configurations as an OSGi bundle with all the advantages OSGi provides.
|Spring XML files
||ServiceMix 4 support plain Spring XML files.
||You can also deploy artifacts following the JBI standard (service assemblies and service units) to ServiceMix 4.
||This is a Karaf specific way for installing applications. It will install the necessary OSGi bundles and will add configuration defaults. This is mostly used to install core parts of the ServiceMix distribution.
OSGi bundle deployment
The easiest way to create an OSGi based ServiceMix bundle is by using Maven 2. To create a bundle you need to take a couple of simple steps. The first one is adding the mavenbundle- plugin to your pom.xml file. This is shown in the following code fragment.
The important part here is the instructions section. This determines how the plugin packages your project. For more information on these settings see the maven OSGi bundle plugin page at http://cwiki.Apache.org/FELIX/Apachefelixmaven-bundle-plugin-bnd.html.
The next step is to make sure your project is bundled as a OSGi bundle. You do this by setting the <packaging> element in your pom.xml to bundle.
Now you can use mvn install to create an OSGi bundle, which you can copy to the deploy directory of ServiceMix and your bundle will be installed. If you use Spring to configure your application, make sure the Spring configuration files are located in the META-INF/spring directory. That way the Spring application context will be automatically created based on these files.
If you don't want to do this by hand you can also use a Maven archetype. ServiceMix provides a set of archetypes you can use. A good starting point for a project is the Camel OSGi archetype which you can use by executing the following following Maven command:
mvn archetype:create -DarchetypeGroupId=org.Apache.servicemix.tooling
There are many other archetypes available. For an overview of the available archetypes see: http://repo.fusesource.com/maven2/org/Apache/servicemix/tooling/
Spring XML Files Deployment
It's also possible to deploy Spring files without OSGi. Just drop a Spring file into the deploy directory. There are two points to take into account. First, you need to add the following to your Spring configuration file:
<bean class="org.Apache.servicemix.common.osgi.EndpointExporter" />
This will register the endpoints you've configured in your Spring file. The next element is optional but is good practice to add:
Bundle-Version = 1.0.0
Bundle-Name = Dzone :: Dzone test application
Bundle-SymbolicName = dzone.refcards.test
Bundle-Description = An example for servicemix refcard
Bundle-Vendor = email@example.com
Require-Bundle = servicemix-file, servicemix-eip
Using a manifest configuration element allows you to specify how your application is registered in ServiceMix.
JBI Artifacts Deployment
If you've already invested in JBI based applications, you can still use ServiceMix 4 to run them in. Just deploy your Service Assembly (SA) in the ServiceMix deploy directory and ServiceMix will deploy your application.
Feature Descriptor Based Deployment
If you've got an application which contains many bundles and that requires additional configuration you can use a feature to easily manage this. A feature contains a set of bundles and configuration which can be easily installed from the ServiceMix console. The following listing shows the feature descriptor of the nmr component.
<feature name="nmr" version="1.0.0">
If you want to install this feature you can just type features/install nmr from the ServiceMix console.