...
Warning | ||
---|---|---|
| ||
provide additional reading Maybe add testing |
...
Panel |
---|
mvn archetype:create -DarchetypeGroupId=org.apache.servicemix.tooling -DarchetypeArtifactId=servicemix-service-engine |
The first three parameters identify the maven 2 archetype to use, while the last two parameters define the generated maven 2 project. The version information "3.0-incubating" may have to be changed; a look at any of ServiceMix' pom.xml reveals the version to use. Maven uses the group ID (printed in pink) as default Java package (see Defaulting package to group ID: in output below as well), thus invalid characters like minus, percent etc. must be avoided or a custom package name has to be given as parameter. The Mavens output following the command looks like this (only relevant information preserved):
Panel | ||||
---|---|---|---|---|
| ||||
No Format | ||||
|
Maven creates a new folder having the same name as the artifact ID provided (printed in green in the command and output). Inside this folder, a file called pom.xml is created. This contains the Project Object Model providing Maven with all needed information for building , see (see Introduction to the POM at the Maven website). Moreover, Java source files and tests were created. The full structure of the things files created by Maven for you looks like this (some directories are grouped together for better readability):
No Format |
---|
\hello-world-SE-SU-SA\hello-world-SE\ pom.xml src\main\ java\ org\apache\servicemix\ samples\helloWorldSE\ MyBootstrap.java MyComponent.java MyDeployer.java MyEndpoint.java MyLifeCycle.java MySpringComponent.java test\ java\ org\apache\servicemix\ samples\helloWorldSE\ MySpringComponentTest.java resources\ spring.xml |
You might be wondering why all All the classes have the word "My" prefixed to them . This prefix is just driven from due to the template; you just need to rename it . We can just rename the prefix to whatever you we want to, as long as you we make sure you we change the corresponding resource files (all tests and the pom.xml) as well.
Compiling the code
From now on, you we can build the code by executing
No Format |
---|
cd hello-world-SE mvn compile |
which shall present you us as one of the last lines of output
...
In case this success information is not appearing, the output shall give further information on the reasons. In case it's not helpful, further information can be found in the ServiceMix mailing lists and the Maven website.
Testing the code
Doing automated testing of the code is possible as well. As ServiceMix' root POM disables testing, it has we have to be activated activate it for the subprojects that shall be tested. To do so, the <build> entity of our pom.xml has to be enriched by
...
where <skip>false</skip> is the relevant line of code. Now, tests will be done when executing
No Format |
---|
mvn test |
...
tests will be done and Maven outputs the following (truncated to the relevant information):
No Format |
---|
[INFO] Scanning for projects... |
...
[INFO] ---------------------------------------------------------------------------- |
...
[INFO] Building A custom project |
...
[INFO] task-segment: [test |
...
] [INFO] ---------------------------------------------------------------------------- |
...
... |
...
[INFO] [compiler:compile] ... [INFO] [surefire:test] [INFO] Setting reports dir: c:\java\tmp\servicemix- |
...
helloWorldSE\target/surefire-reports |
...
------------------------------------------------------- |
...
T E S T S |
...
------------------------------------------------------- |
...
[surefire] Running org.apache.servicemix.samples.helloWorldSE.MySpringComponentTest |
...
... |
...
[surefire] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 1,422 sec |
...
[INFO] ------------------------------------------------------------------------ |
...
[INFO] BUILD SUCCESSFUL |
...
[INFO] ------------------------------------------------------------------------ |
...
...
|
Adding functionality to the stub of the SE
The default implementation of the component accepts InOut MEPs and return the input content as the out message.
...