יום שלישי, 14 במאי 2013

Simple felix osgi bundle

The Osgi felix framework can be download from here. Extract the zip file to your local storage and execute the following command in order to start the container :
java -jar bin/felix.jar

Capture6 
Then create a simple Osgi bundle (I used net beans )
Capture7 

In the default created Activator I add a prints command :

package com.mycompany.mybundle;
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("Hello World!" );
}
public void stop(BundleContext context) throws Exception {
System.out.println("Goodbye World!" );
}
}
I Compiled the program and copy the created jar into the felix bundle directory :\felix-framework-4.2.1\bundle

In order to  start the bungle follow the following steps :
Import an install the bundle :
felix:install file:bundle/myBundle-1.0-SNAPSHOT.jar
Start the bundle: start 5
Stop the bundle: stop 5
List all the bundles: felix lb
List all the bundles when my bundle is active : start 5 and then felix lb


Capture8 a good starting point to using felix  can be found here

אין תגובות:

הוסף רשומת תגובה