Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Eclipse Kura component

This documentation page covers the integration options of Camel with the Eclipse Kura M2M gateway.

KuraRouter activator

The easiest way to deploy Apache Camel routes into the Kura is to create an OSGi bundle containing the class extending org.apache.camel.kura.KuraRouter class:

...

Kura router starts its own OSGi-aware CamelContext. It means that for every class extending KuraRouter, there will be a dedicated CamelContext instance. Ideally we recommend to deploy one KuraRouter per OSGi bundle.

Deploying KuraRouter

Bundle containing your Kura router class should import the following bundles in the OSGi manifest:

...

Code Block
xml
xml
install file:///home/user/.m2/repository/com/example/myrouter/1.0/myrouter-1.0.jar
start <your-bundle-id>

KuraRouter utilities 

 Kura router base class provides many useful utilities. This section explores each of those.

SLF4J logger

Kura uses SLF4J facade for logging purposes. Protected member log returns SLF4J logger instance associated with the given Kura router.

Code Block
languagejava
public class MyKuraRouter extends KuraRouter {

    @Override
    public void configure() throws Exception {
		log.info("Configuring Camel routes!");
        ...
    }

}

BundleContext

Protected member bundleContext returns bundle context associated with the given Kura router.

Code Block
languagejava
public class MyKuraRouter extends KuraRouter {

    @Override
    public void configure() throws Exception {
		ServiceReference<MyService> serviceRef = bundleContext.getServiceReference(LogService.class.getName());
		MyService myService = content.getService(serviceRef);
        ...
    }

}

CamelContext

Protected member camelContext is the CamelContext associated with the given Kura router.

Code Block
languagejava
public class MyKuraRouter extends KuraRouter {

    @Override
    public void configure() throws Exception {
		camelContext.getStatus();
        ...
    }

}

OSGi service resolver

OSGi service resolver (service(Class<T> serviceType)) can be used to easily retrieve service by type from the OSGi bundle context.

...