1 36 package org.ungoverned.osgi.bundle.simple; 37 38 import javax.servlet.Servlet ; 39 40 import org.osgi.framework.BundleActivator; 41 import org.osgi.framework.BundleContext; 42 import org.ungoverned.osgi.bundle.simple.embedded.Embedded; 43 44 50 public class SimpleBundle implements BundleActivator 51 { 52 private BundleContext context = null; 53 54 public native String foo(); 55 56 public void start(BundleContext context) throws Exception 57 { 58 System.out.println("Simple Bundle " + context.getBundle().getBundleId() 59 + " has started."); 60 61 this.context = context; 62 63 String os = 65 context.getProperty("org.osgi.framework.os.name").toLowerCase(); 66 String processor = 67 context.getProperty("org.osgi.framework.processor").toLowerCase(); 68 69 if (os.equals("linux") && processor.endsWith("86")) 71 { 72 try { 73 System.loadLibrary("foo"); 74 } catch (Exception ex) { 75 System.out.println("No library: " + ex); 76 ex.printStackTrace(); 77 } 78 System.out.println("From native: " + foo()); 79 } 80 81 Embedded embedded = new Embedded(); 83 embedded.sayHello(); 84 85 try { 87 System.out.println("Resource = " + getClass().getResource("/javax/servlet/Servlet.class")); 88 } catch (Throwable ex) { 89 System.out.println("The 'javax.servlet' package is not available."); 90 } 91 try { 92 System.out.println("Class name = " + javax.servlet.http.HttpSession .class); 93 } catch (Throwable ex) { 94 System.out.println("The 'javax.servlet.http' package is not available."); 95 } 96 try { 97 System.out.println("Class name = " + Servlet .class); 98 } catch (Throwable ex) { 99 System.out.println("The 'javax.servlet' package is not available."); 100 } 101 } 102 103 public void stop(BundleContext context) 104 { 105 System.out.println("Simple Bundle " + context.getBundle().getBundleId() 106 + " has stopped."); 107 } 108 } 109 | Popular Tags |