Page Edited : SM : 8. Intermediate - How to write my own binding component
8. Intermediate - How to write my own binding component has been edited by Lars Heinemann (Dec 08, 2008).Content:
This tutorial will explain to you how to write your own binding components. What you learn here is also enabling you to write own service engines because the difference between a binding component and a service engine is of pure logical nature. While a binding component is translating data from outside bus to normalized messages used inside the bus and vice versa a service engine is only working inside the bus with normalized messages.
Before beginning this tutorial, please take the time to read the FAQ entry titled "Should I Create My Own JBI Components?". It is very important that you understand the reason for developing a JBI binding component and this FAQ entry will explain this to you.
The Java Business Integration (JBI) spec provides a standards-based, service-oriented approach to application integration through the use of an abstract messaging model, without reference to a particular protocol or wire encoding. JBI introduces the concepts of Binding Components (BCs), Service Engines (SEs) to Service Units (SUs) and Service Assemblies (SAs) to define an architecture for vendor-neutral pluggable components. The purpose of this architecture is to provide standards-based interoperability amongst components/services.
JBI components can be thought of as the smallest applications or services accessible in a service-oriented architecture. Each service has a very specific purpose and therefore a narrow scope and set of functionality. Components come in two flavors:
SU*s must be packaged into a *SA to be deployed to the JBI container. A SA is a complete application consisting of one or more services. By comparison, this is similar to the way that WAR files must be packaged inside of an EAR file to be deployed to a J2EE container.
See also the page providing information on working with service units
Below some quick definitions which are dominant throughout the JBI spec:
This tutorial focuses on both component architecture and component packaging. For further information and details on JBI, see the following:
This tutorial will explain to you how to create a binding component for the SNMP protocol. If you don't know what this protocol is about, then see for example the SNMP Wikipedia entry for further details. As a first step we will only create a snmp polling service. Once you understand how to do this, you will be able to go further and create also a sender service but this will be not done inside this tutorial for now.
Now let's move on to creating the Maven projects for the SNMP binding component.
The focus of this section is on the creation of a JBI binding component. For this task, a Maven archetype will be used to create a Maven project skeleton to house the component. Maven archetypes are templates for Maven projects that jumpstart project creation via the automation of repetitive tasks by following standard conventions. The result of using an archetype to create a Maven project is a directory structure, a Maven POM file and, depending on the archetype being used, sometimes Java objects and JUnit tests.
Below are the steps to follow for creating the directory structure and project. All instructions are laid out to take place on a Unix command-line.
1) Create a Maven project named servicemix-snmp and switch to that directory:
$ mvn archetype:create \ -DarchetypeGroupId=org.apache.servicemix.tooling \ -DarchetypeArtifactId=servicemix-project-root \ -DarchetypeVersion=3.2.2 \ -DgroupId=org.apache.servicemix.tutorial.snmp \ -DartifactId=servicemix-snmp-tutorial $ cd servicemix-snmp-tutorial
2. Check the project Maven configuration file
Maven created a project folder for you and already setup a project file called pom.xml. As this is not a beginner tutorial I won't explain the file here.
$ nano pom.xml
You will recognize, that the project file is setup for your purposes already. You normally don't need to change anything in there for the moment.
3) Create the binding component sub project
Use the servicemix-binding-component Maven archetype to generate a Maven project for the component.
To create the BC, execute the following command on the command-line:
$ mvn archetype:create \ -DarchetypeGroupId=org.apache.servicemix.tooling \ -DarchetypeArtifactId=servicemix-binding-component \ -DarchetypeVersion=3.2.2 \ -DgroupId=org.apache.servicemix.tutorial.snmp \ -DartifactId=snmp-binding
The command above will create a directory named snmp-binding that houses a Maven project for the JBI binding component being created here. The name of the directory is taken from the artifactId parameter.
Now switch into the snmp-binding sub folder and open the pom.xml in your editor of choice. We will cleanup the file before proceeding to program code.
Do the following things:
An overview of using Maven-based tooling and archetypes to develop a snmp binding component
This tutorial provides an easy and convenient way for a new user to learn about:
After finishing this tutorial you have a snmp binding component ready to poll devices. Feel free to play around with it and adding improvements.