Note: The content of this document is overlapping with Creating a Standard JBI Component, Hello World - BC and Hello World - SE. Any changes you might want to do for this document might be relevant for them as well. Questions unanswered by this document may be answered by the other documents.

Introduction

Before you attempt at creating a JBI component using http://servicemix.org/site/creating-a-standard-jbi-component.html;. My suggestion is that you should visit Maven's home page and have a look at the getting started page http://maven.apache.org/guides/getting-started/index.html;. Get acquainted with the term archetype- going by definition it's more of "an original pattern or model from which all other things of the same kind are made". So there you go, Servicemix already has a template which you can use!

When to use this JBI Component

<TODO>

First things first

Check if you have maven2 installed, if not then please install it. http://maven.apache.org/download.html#Installation

1) To create a JBI component as you might have guessed by now - run the mvn command: (needless to say you should create a new directory where you want all your stuff to be generated and you have to remove the trailing backshlashes and make it one line)

mvn archetype:create \
        -DarchetypeGroupId=org.apache.servicemix.tooling \
        -DarchetypeArtifactId=servicemix-service-engine \
        -DarchetypeVersion=3.0-incubating \
        -DgroupId=org.apache.servicemix.package \
        -DartifactId=servicemix-package

Well, notice the text in blue in the above mvn command. This is meant to be the package info. So if you are creating a component which maybe does some xslt transformation then you would end up with something like:

mvn archetype:create \
        -DarchetypeGroupId=org.apache.servicemix.tooling \
        -DarchetypeArtifactId=servicemix-service-engine \
        -DarchetypeVersion=1.0-incubating-SNAPSHOT \
        -DgroupId=org.apache.servicemix.xslt \
        -DartifactId=servicemix-xslt

The version information "3.0-incubating" may have to be changed; just look at any of ServiceMix' pom.xml for the version you are using.

In case of a BUILD ERROR: Maven plugin version requirement

The  maven-archetype-plugin 1.0-alpha4 or above is required for this tutorial. When an older version is installed, a BUILD ERROR will occur. The version can be checked by having a look at the name of the directories contained in ~/.m2/repository/org/apache/maven/plugins/maven-archetype-plugin (~ is you user directory, on Windows C:\Documents and Settings\<USERNAME>). In case only an older version is present, we create a minimal pom.xml in the folder where we're calling the mvn archetype:create goal in (so the current folder) and fill the created file with the following content: 

<?xml version="1.0" encoding="UTF-8"?>
<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>mygroup</groupId>
    <artifactId>myartifact</artifactId>
    <version>myversion</version>
    <packaging>pom</packaging>
    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-archetype-plugin</artifactId>
                    <version>1.0-alpha-4</version>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
</project>

 2) After you have successfully run the above command this is what you would end up with 

servicemix-xslt\
  pom.xml
  src\
    main\
      java\
        org\
          apache\
            servicemix\
              xslt\
                MyBootstrap.java
                MyComponent.java
                MyDeployer.java
                MyEndpoint.java
                MyLifeCycle.java
                MySpringComponent.java
    test\
      java\
        org\
          apache\
            servicemix\
              xslt\
                MySpringComponentTest.java
      resources\
        spring.xml

    
Now you might be wondering why all the classes have the word "My" prefixed to them. Don't worry these are just driven from the template, you just need to rename them to whatever you want to. Just make sure you change the corresponding resource files, change "My" to whatever prefix that you used for the classes.

3) Using an IDE to add meat to the component.

You can either use IDEA or Eclipse, I tried it with Eclipse so I guess I am going to stick it for now.
To generate project files ready to import in the IDE use:

mvn eclipse:eclipse
or
mvn idea:idea

For eclipse you have to set the M2_REPO variable to your repository that should be at ~/m2/repository.

Using the component that you created

<TODO>