Featured Post

Applying Email Validation to a JavaFX TextField Using Binding

This example uses the same controller as in a previous post but adds a use case to support email validation.  A Commons Validator object is ...

Saturday, January 26, 2013

Deploying an OSGI Bundle in Talend ESB

Use a Maven Archetype as the basis for an OSGI Bundle project that can be deployed into Talend ESB.

This is the first post in a series on developing web and integration services with Talend ESB.

The runtime part of Talend ESB is an OSGI container that manages dynamic modules.  An OSGI container is a cross between an application server (WebSphere, Tomcat, etc) and a dependency framework like Spring or Google Guice.  While the application server is limited to a particular set of artifacts (Java EE web applications and EJBs) and the dependency frameworks operate at the Java class levels, OSGI is focused on a coarser grain of objects with better operational and deployment characteristics.

Talend ESB also includes a Studio, like Talend Open Studio for Data Integration, which produces artifacts for the runtime.  For more on ESB Studio, check out the video series starting with "Simple Order Processing".

Talend ESB

  OSGI is a specification and there are two major implementations: Apache Felix and Eclipse Equinox.  Application servers like JBoss AS 7 are also implementing the specification.  OSGI implementations are supplemented with a command shell like Apache Karaf.  Talend ESB is Eclipse Equinox packaged with Apache Karaf and Talend-specific services to support Talend integration work.

This series of blog posts is working with Talend ESB v5.2.1 which is available here on Java 7

My IDE is Eclipse Juno also running Java 7.  I'm using m2e to integrate Maven with Eclipse.  I'm also using Eclipse Tycho to resolve some lifecyle warnings with the Felix plugin.

Maven Archetype

My demonstration project will use a Maven Archetype to construct a skeleton OSGI project.  Usually Maven projects result in a JAR or a WAR packaging.  This project will make a "bundle" using a special Felix plugin.

To start, create a New Maven Project.  Select the osgi-archetype artifact.

Select an Archetype
Next, add in your specific namespace information.

Customizing Project Info
Hand-edit the resulting pom.xml to use an earlier version of OSGI (4.2.0) and to also add in the OSGI Compendium.  The resulting Dependencies section should look like this


The archetype-generated POM with the above modifications is available here.

The Felix plugin will have generated an Activator class.  This class is referenced in the pom.xml and is the hook into which your application -- written in plain Java -- will integrate with OSGI.  For now, the Activator will execute some print statements when the bundle is started and stopped.

package com.bekwam.talend.osgi.talend_integration;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;

public class Activator implements BundleActivator {

 public void start(BundleContext context) throws Exception {
    System.out.println("start() Talend Integration");

 public void stop(BundleContext context) throws Exception {
   System.out.println("stop() Talend Integration");


Run a 'mvn install'.


Go to the ${tesb.home}/container/bin directory where ${tesb.home} is the unzipped Talend ESB Runtime download. Run the 'trun' command.  You should see the following screen appear.  If you don't, double-check your version of Java.

Starting Karaf
To install your bundle, enter the following command at the shell prompt.

> install mvn:com.bekwam.talend.osgi/talend-integration/0.0.1-SNAPSHOT

The system will respond with a Bundle ID (say '210').  Start the bundle

> start 210

You should see the System.out message.  You can also stop the bundle which will display another message

> stop 210

If you're interested, run the 'list' command to see the other non-hidden bundles that are loaded.  Notice the pre-loaded Talend bundles.  These aren't found in the standard Karaf distribution.

This post walked through a simple installation example of an OSGI bundle. Later posts will show more of what you can do with OSGI.  Note that you can always throw a bunch of JAR files onto the classpath for your program, but as programs grow larger, as they involve more people, and as they persist in an organization longer, you'll start to recognize deficiencies in what Java provides off-the-shelf.

No comments:

Post a Comment