Error CSS Stylesheet macro - Import URL '' is not on the allowlist. If you want to include this content, contact your Confluence administrator to request adding this URL to the Allowlist.
Error CSS Stylesheet macro - Import URL '' is not on the allowlist. If you want to include this content, contact your Confluence administrator to request adding this URL to the Allowlist.

Developing Camel mediators with iPOJO

The Camel OSGi tutorial provides a very simple and neat overview of Camel. This article mentions the usage of iPOJO to implement the mediator. This document provides this implementation.

Step 1 : Initial project setup

Instead of using the 'spring-osgi-bundle-archetype' maven archetype, we will use the iPOJO one to create the iPOJO bundle.
To create the simple iPOJO service project, execute the following command in your Unix/Dos console.

mvn archetype:create -DarchetypeGroupId=org.apache.felix -DarchetypeArtifactId=maven-ipojo-plugin -DarchetypeVersion=1.0.0 -DgroupId=demo -DartifactId=demo.service-ipojo-bundle -Dversion=0.1

Step 2 : Develop the interface

So now, it is time to create the interface that we will use in the project. Create a new folder "service" in src/main/java/demo tree. Add the interface and copy paste the code below:
package demo.service;
public interface TransformService {
    public Object transform(Object obj);

Step 3 : Create the class implementing the interface

Next, we will create the class TransformServiceImpl implementing the interface TransformService.
Create the class in the folder src/main/java/demo/service/
package demo.service;

import java.util.Date;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class TransformServiceImpl implements TransformService {
    private static final transient Log LOG = LogFactory.getLog(TransformServiceImpl.class);
    private boolean verbose = true;
    private String prefix = "MyTransform";

    public Object transform(Object body) {
        String answer = prefix + " set body:  " + new Date();
        if (verbose) {
            System.out.println(">> call >> " + answer);
        }">> call >>" + answer);
        return answer;

    public boolean isVerbose() {
        return verbose;

    public void setVerbose(boolean verbose) {
        this.verbose = verbose;

    public String getPrefix() {
        return prefix;

    public void setPrefix(String prefix) {
        this.prefix = prefix;

Step 4 : Create the iPOJO configuration files

The next step concerns the creation of the iPOJO configuration file who will allow the registration of the TranformService as an OSGi service.
Create or edit the file metadata.xml in the folder src/main/resources/

<?xml version="1.0" encoding="UTF-8"?>
	<component classname="demo.service.TransformServiceImpl" name="my-ipojo-transformer">
	<instance component="my-ipojo-transformer"/>

Step 5 : Generate the bundle

Before generating the bundle, we need to edit the pom.xml file to describe our bundle.


Step 6 & 7: Create the Camel context file and the bundle

These steps are exactly the same as into the OSGi Camel Tutorial. So refer to the step 6 and 7 of the article.

Step 8: Deploy the bundles

We will see how to execute the Canel route on ServiceMix Kernel.
As mentioned in the documentation, Apache ServiceMix Kernel is a small OSGi based runtime which provides a lightweight container onto which various components and applications can be deployed. Moreover, the server provides administration, security, logging and provisioning features that will help you during the deployment and administration steps.
If this is not yet done, download ServiceMix Kernel 1.0.0 server and install it. Launch the server by executing the command in the bin folder:


If this is the first time Servicemix is started, then you will see that a new data folder is created. Notes that this application requires Java 6.
In order to allow our bundles to work with Camel, execute the following commands to download and install the 'Camel and iPOJO bundles':

servicemix> osgi install -s mvn:org.springframework/spring-tx/2.5.5
servicemix> osgi install -s mvn:org.apache.camel/camel-core/1.5.0
servicemix> osgi install -s mvn:org.apache.camel/camel-spring/1.5.0
servicemix> osgi install -s mvn:org.apache.camel/camel-osgi/1.5.0
servicemix> osgi install -s mvn:org.apache.felix/org.apache.felix.ipojo/1.0.0

Next, copy the two jar files into the deploy folder, first the iPOJO service and next the Camel bundle. After a few seconds, you should see on the Servicemix log console the following text:

servicemix> >> call >> MyTransform set body:  Sat Dec 27 19:29:16 CET 2008

Remarks :

  • In case of trouble, use the command: osgi list to see if all the deployed bundles are installed correctly and have their status equals to active
  • To see the log of ServiceMix, use the command: log d

  • No labels