FUSE ESB provides Maven tooling that simplifies the creation and deployment of JBI artifacts. Among the tools provided are:
plug-ins for packaging JBI components
a plug-in for packaging shared libraries
archetypes that create starting point projects for JBI artifacts
The FUSE ESB Maven tooling also includes plug-ins for creating service units and service assemblies. However, those plug-ins are outside of the scope of this book.
In order to use the FUSE ESB Maven tooling, you add the elements shown in Example 6.1 to your POM file.
Example 6.1. POM Elements for Using FUSE ESB Tooling
...
<pluginRepositories>
<pluginRepository>
<id>fusesource.m2</id>
<name>FUSE Open Source Community Release Repository</name>
<url>http://repo.fusesource.com/maven2</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
<repositories>
<repository>
<id>fusesource.m2</id>
<name>FUSE Open Source Community Release Repository</name>
<url>http://repo.fusesource.com/maven2</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
<repository>
<id>fusesource.m2-snapshot</id>
<name>FUSE Open Source Community Snapshot Repository</name>
<url>http://repo.fusesource.com/maven2-snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>false</enabled>
</releases>
</repository>
</repositories>
...
<build>
<plugins>
<plugin>
<groupId>org.apache.servicemix.tooling</groupId>
<artifactId>jbi-maven-plugin</artifactId>
<version>${servicemix-version}</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
...These elements point Maven to the correct repositories to download the FUSE ESB Maven tooling and load the plug-in that implements the tooling.
The FUSE ESB Maven tooling provides a number of archetypes that can be used to seed a JBI project. The archetype will generate the proper file structure for the project and a POM file containing the essential metadata required for the specified project type.
Example 6.2 shows the command for using the JBI archetypes.
Example 6.2. Command for JBI Maven Archetypes
mvn archetype:create -DarchetypeGroupId=org.apache.servicemix.tooling -DarchetypeArtifactId=servicemix-archetype-name -DarchetypeVersion=fuse-4.0.0.0 [-DgroupId=org.apache.servicemix.samples.embedded] [-DartifactId=servicemix-embedded-example]
The value passed to the -DarchetypeArtifactId argument specifies the type of project you wist to create.
As shown in Example 6.3, you instruct the FUSE ESB Maven tooling that the project is for a JBI component by
specifying a value of jbi-component for the project's packaging element.
Example 6.3. Specifying that a Maven Project Results in a JBI Component
<project ...>
...
<groupId>org.apache.servicemix</groupId>
<artifactId>MyBindingComponent</artifactId>
<packaging>jbi-component</packaging>
...
</project>The plugin element responsible for packaging the JBI component is shown in Example 6.4.
The groupId element, the artifactId element, the version element, and
the extensions element are common to all instances of the FUSE ESB Maven plugin. If you used the Maven archetypes to generate the
project, you should not have to change them.
Example 6.4. Plugin Specification for Packaging a JBI Component
...
<plugin>
<groupId>org.apache.servicemix.tooling</groupId>
<artifactId>jbi-maven-plugin</artifactId>
<version>${servicemix-version}</version>
<extensions>true</extensions>
<configuration>
<type>service-engine</type>
<bootstrap>org.apache.servicemix.samples.MyBootstrap</bootstrap>
<component>org.apache.servicemix.samples.MyComponent</component>
</configuration>
</plugin>
...The configuration element and its children provides the FUSE ESB tooling with the metadata needed to construct the
jbi.xml file required by the component.
typeThe type element specifies the type of JBI component the project is building. Valid values are:
service-engine for creating a service engine
binding-component for creating a binding component
bootstrapThe bootstrap element specifies the name of the class that implements the JBI
Bootstrap interface for the component.
![]() | Tip |
|---|---|
If you intend to use the default |
componentThe component element specifies the name of the class that implement the JBI
Component interface for the component.
Once the project is properly configured, you can build the JBI component by using the mvn install command. The FUSE ESB Maven tooling will generate a standard jar containing the component and an installable JBI package for the component.
As shown in Example 6.5, you instruct the FUSE ESB Maven tooling that the project is for a shared library by specifying a
value of jbi-shared-library for the project's packaging element.
Example 6.5. Specifying that a Maven Project Results in a JBI Component
<project ...>
...
<groupId>org.apache.servicemix</groupId>
<artifactId>MyBindingComponent</artifactId>
<packaging>jbi-shared-library</packaging>
...
</project>You build the shared library using the mvn install command. The FUSE ESB Maven tooling will generate a standard jar containing the shared library and an installable JBI package for the shared library.