Note: The content of this document is overlapping with Notes on Creating JBI Component using maven2 and 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.
This document is a tutorial that describes the steps involved in the creation of a standard JBI Component using servicemix-common module.
We will write a full XSLT Service Engine.
First, we will use the servicemix-service-engine maven 2 archetype to create the basis of our JBI component.
Using the maven2 archetype
Run the following command (remove the trailing backshlashes and make it one line):
Code Block |
---|
mvn archetype:create \
-DarchetypeGroupId=org.apache.servicemix.tooling \
-DarchetypeArtifactId=servicemix-service-engine \
-DarchetypeVersion=3.0-incubating \
-DgroupId=org.apache.servicemix.xslt \
-DartifactId=servicemix-xslt
|
The first three parameters identify the maven 2 archetype to use, while the last two parameters are used for the generated maven 2 project. 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.
While ServiceMix is in the incubator you have to specify the incubator repository in order to use the servicemix maven 2 archetypes, unless you did not include the repository in your local maven configuration.
Code Block |
---|
-DremoteRepositories=http://people.apache.org/repo/m2-incubating-repository
|
This will create the following files:
Code Block |
---|
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
|
Testing the generated component
The default implementation of the component accepts InOut MEPs and return the input content as the out message.
To test it, just run
Code Block |
---|
mvn test
|
You should see something like:
Code Block |
---|
[INFO] Scanning for projects...
[INFO] ----------------------------------------------------------------------------
[INFO] Building A custom project
[INFO] task-segment: [test]
[INFO] ----------------------------------------------------------------------------
[INFO] [xbean:mapping {execution: default}]
[INFO] Generating META-INF properties file: c:\java\tmp\servicemix-xslt\target\xbea
n\META-INF\services\org\apache\xbean\spring\http\org.apache.servicemix.xslt\1.0 for
namespace: http://org.apache.servicemix.xslt/1.0
[INFO] Generating HTML documentation file: c:\java\tmp\servicemix-xslt\target\xbean
\servicemix-xslt.xsd.html for namespace: http://org.apache.servicemix.xslt/1.0
[INFO] Generating XSD file: c:\java\tmp\servicemix-xslt\target\xbean\servicemix-xsl
t.xsd for namespace: http://org.apache.servicemix.xslt/1.0
[INFO] ...done.
[INFO] [2-jbi:generate-jbi-descriptor]
[INFO] Generating jbi.xml
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:compile]
Compiling 6 source files to c:\java\tmp\servicemix-xslt\target\classes
[INFO] [resources:testResources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [compiler:testCompile]
Compiling 1 source file to c:\java\tmp\servicemix-xslt\target\test-classes
[INFO] [surefire:test]
[INFO] Setting reports dir: c:\java\tmp\servicemix-xslt\target/surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
[surefire] Running org.apache.servicemix.xslt.MySpringComponentTest
log4j:WARN No appenders could be found for logger (org.apache.xbean.spring.context.
impl.XBeanXmlBeanDefinitionReader).
log4j:WARN Please initialize the log4j system properly.
<?xml version="1.0" encoding="UTF-8"?><hello>world</hello>
[surefire] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 1,422 sec
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 42 seconds
[INFO] Finished at: Thu May 11 22:50:58 CEST 2006
[INFO] Final Memory: 8M/18M
[INFO] ------------------------------------------------------------------------
|
Note: For problems with archetypes in Eclipse, see Importing ServiceMix into Eclipse#Projects with failing build in Eclipse workspace
Created by Guillaume Nodet
On Thu May 11 15:07:33 CEST 2006
Using TimTam