Changes

Jump to: navigation, search

OSGi Concepts Bundle Life-Cycle

1,285 bytes added, 12:26, 21 January 2011
no edit summary
[[Image:bundle-lifecycle.png|thumb100px| ]] [http://static.springsource.org/s2-dmserver/2.0.x/getting-started/htmlsingle/getting-started.html SpringSource® dm Server™]
 
For instance a typical Java class implementing the <code>[http://www.osgi.org/javadoc/r4v42/org/osgi/framework/BundleActivator.html BundleActivator]</code> interface is implemented in the [https://zenit.senecac.on.ca/svn/ecl500/Lectures/trunk/w11-osgi-simple-serviceprovider/src/cs/ecl/osgi/simple/bookfinderservice/Activator.java Sample Bundle from your course] as shown below:
<source lang="java">
 
package cs.ecl.osgi.simple.bookfinderservice;
 
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
 
import cs.ecl.osgi.simple.bookfinder.BookFinder;
import cs.ecl.osgi.simple.bookfinderservice.internals.BookFinderImplementation;
 
 
public class Activator implements BundleActivator {
 
private static BundleContext context;
 
static BundleContext getContext() {
return context;
}
public void start(BundleContext bundleContext) throws Exception {
Activator.context = bundleContext;
BookFinder bookService = new BookFinderImplementation();
context.registerService(BookFinder.class.getName(), bookService, null);
System.out.println(" Bookfinder service registered ");
}
public void stop(BundleContext bundleContext) throws Exception {
Activator.context = null;
System.out.println(" Bookfinder service stopped ");
}
}
</source>
}

Navigation menu