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:
Code Block |
---|
mvn archetype:create \
-DarchetypeGroupId=org.apache.servicemix.archetypes \
-DarchetypeArtifactId=servicemix-service-engine \
-DarchetypeVersion=1.0-SNAPSHOT \
-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.
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] ------------------------------------------------------------------------
|
Created by Guillaume Nodet
On Thu May 11 15:07:33 CEST 2006
Using TimTam