When you wish to deploy a component you can use a Service Unit to provide instance artifacts. In JBI terms this means that a Service Unit can be defined to be provided to a component which will then be passed the contents of the SU. The JBI is purposefully vague on the contents of an SU (other than the jbi.xml) since how you design your components to operate with *Service Unit*s is up to you.

The Maven tooling provides some basic steps to allow you to build the Service Unit*s, which are simply zip files containing the resources you wish to pass to the component. First you must change you pom.xml to package as a *jbi-service-unit.

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>org.apache.servicemix</groupId>
  <artifactId>MyHttpServiceUnit</artifactId>
  <packaging>jbi-service-unit</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>A service unit</name>
  ...
</project>

A Service Unit is assigned to a component and there are couple of ways you can do this using the tooling, the best way to do this is to actually add the component as a dependency, as shown below for the ServiceMix HTTP component:

<dependencies>
    <dependency>
       <groupId>org.apache.servicemix</groupId>
       <artifactId>servicemix-http</artifactId>
       <version>3.0-incubating-SNAPSHOT</version>
    </dependency>
</dependencies>

This is the preferred way, since the tooling can later do some intelligent dependency calculations and actually find and install the components for you before installing the service assembly containing this service unit. However, if you are going to use a component that isn't available as a Maven dependency (is there such as thing I wonder?), then you can use the project properties to define the component name.

<properties>
     <componentName>servicemix-http</componentName>
</properties>

Once you have configured these steps you can run mvn install and you should find that both a jar and zip version of the service unit are created, this is to allow you to reference the SU as a dependency on the Service Assembly.

Remember that a Service Unit is pretty useless outside a Service Assembly

The maven plugin will generate the ServiceUnit jbi descritor if the component contains a ServiceUnitAnalyzer. In some cases, the ServiceUnitAnalyzer may fail to create the needed informations and generate an exception (if the service unit requires some runtime dependencies, such as JNDI objects for example). When such a problem happen, you can disable the jbi.xml generation by using the following configuration:

<plugin>
  <groupId>org.apache.servicemix.tooling</groupId>
  <artifactId>jbi-maven-plugin</artifactId>
  <version>1.0-incubating-SNAPSHOT</version>
  <extensions>true</extensions>
  <configuration>
    <useServiceUnitAnalyzer>false</useServiceUnitAnalyzer>
  </configuration>
</plugin>
  • No labels