Created
November 7, 2014 19:58
-
-
Save rafaeltuelho/a8dd453a4093167bce17 to your computer and use it in GitHub Desktop.
OSGI Bundle Activator class to activate a Bundle inside a OSGI Container (eg: Apache Karaf)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.redhat.camel.java; | |
import org.apache.camel.impl.DefaultCamelContext; | |
import org.osgi.framework.BundleActivator; | |
import org.osgi.framework.BundleContext; | |
/** | |
* A Camel Application | |
*/ | |
public class MainActivation implements BundleActivator{ | |
private DefaultCamelContext camelContext; | |
private String bundleName; | |
@Override | |
public void start(BundleContext bundleContext) throws Exception { | |
camelContext = new DefaultCamelContext(); | |
bundleName = bundleContext.getBundle().getSymbolicName(); | |
camelContext.setName(bundleName); | |
camelContext.addRoutes(new MyRouteBuilder()); | |
camelContext.start(); | |
} | |
@Override | |
public void stop(BundleContext bundleContext) throws Exception { | |
camelContext.stop(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use the maven bundle plugin to indicate to generate the Bundle OSGI JAR: