13. 建立 Bundle Activator package javatwo2009; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; /** * Hello world! */ public class Activator implements BundleActivator { public void start(BundleContext context) throws Exception { System. out .println("Hey!"); } public void stop(BundleContext context) throws Exception { System. out .println("Bye!"); } } #12 .. #13
14.
15. OSGi 怎麼跑? System Bundle B B B PID 永遠為 0 JVM OSGi Framework Module Life Cycle Service
16. OSGi 怎麼跑? Installed Resolving & Loading Classes Resolved JVM OSGi Framework System Bundle M O D U L E Export-Package: org.osgi.framework, org.osgi.framework.hooks.service, org.osgi.service.packageadmin, org.osgi.service.startlevel, org.osgi.service.url, org.osgi.util.tracker
17. OSGi 怎麼跑? Resolved public class Activator implements BundleActivator { public void start(BundleContext context) throws Exception { System. out .println("Hey!"); } public void stop(BundleContext context) throws Exception { System. out .println("Bye!"); } } JVM OSGi Framework System Bundle L I F E C Y C L E Starting Active Stopping Activator.stop() Activator.start()