Changes

Jump to: navigation, search

OSGi : Install Eclipse Plugins

1,680 bytes added, 23:53, 22 January 2011
no edit summary
[[Category:ECL_Activities]]__NOTOC__
{{Ecl_installation|type=OSGi|type-small=osgi|name=Eclipse Classic|install=Follow this [http://www.vogella.de/articles/OSGi/article.html tutorial to build OSGi bundels after you install Elcipse Classic]}}
 
<h3>Steps for Building the first Bundle</h3>
 
<h4>1. Study the Interfaces</h4>
 
* [http://www.osgi.org/javadoc/r4v42/org/osgi/framework/Bundle.html Bundle]
* [http://www.osgi.org/javadoc/r4v42/org/osgi/framework/BundleContext.html BundleContext]
* [http://www.osgi.org/javadoc/r4v42/org/osgi/framework/BundleActivator.html BundleActivator]
----------
 
<h4>2. Define the BundleActivator class</h4>
 
The ''BundleActivator'' customizes the starting and stopping of a bundle.
 
''BundleActivator'' is an interface that may be implemented when a bundle is started or stopped. The Framework can create instances of a bundle's ''BundleActivator'' as required. If an instance's ''BundleActivator.start'' method executes successfully, it is guaranteed that the same instance's ''BundleActivator.stop'' method will be called when the bundle is to be stopped. The Framework must not concurrently call a BundleActivator object.
 
''BundleActivator'' is specified through the Bundle-Activator Manifest header.
<source lang="java">
package cs.ecl.osgi.simple.helloworld;
 
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
 
public class Activator implements BundleActivator {
 
private static BundleContext context;
 
static BundleContext getContext() {
return context;
}
public void start(BundleContext bundleContext) throws Exception {
Activator.context = bundleContext;
System.out.println("Hello World from OSGi - start method in BundleActivator!");
}
public void stop(BundleContext bundleContext) throws Exception {
Activator.context = null;
System.out.println("Goodby World from OSGi - stop method in BundleActivator!");
}
 
}
</source>

Navigation menu