Versions Compared

Key

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

...

 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.

Code Block
languagejava
public class MyKuraRouter extends KuraRouter {

    @Override
    public void configure() throws Exception {
		MyService myService = service(MyService.class);
        ...
    }

}

Include Page
Endpoint See Also
Endpoint See Also