1 17 package org.apache.geronimo.client; 18 19 import java.util.Properties ; 20 21 import org.apache.geronimo.gbean.GBeanInfo; 22 import org.apache.geronimo.gbean.GBeanInfoBuilder; 23 import org.apache.geronimo.gbean.GBeanLifecycle; 24 import org.omg.CORBA.ORB ; 25 26 29 public class AppClientCORBABean implements GBeanLifecycle { 30 private final ClassLoader classLoader; 31 private ORB orb; 32 33 public AppClientCORBABean(ClassLoader classLoader) { 34 this.classLoader = classLoader; 35 } 36 37 public void doStart() throws Exception { 38 ClassLoader savedLoader = Thread.currentThread().getContextClassLoader(); 39 try { 40 Thread.currentThread().setContextClassLoader(classLoader); 41 42 orb = ORB.init(new String [0], new Properties ()); 43 new Thread (new ORBRunable(orb), "ORBInitialization").start(); 44 } finally { 45 Thread.currentThread().setContextClassLoader(savedLoader); 46 } 47 } 48 49 public void doStop() throws Exception { 50 orb.shutdown(true); 51 } 52 53 public void doFail() { 54 orb.shutdown(false); 55 } 56 57 public ORB getORB() { 58 return orb; 59 } 60 61 private static final class ORBRunable implements Runnable { 62 private final ORB orb; 63 64 public ORBRunable(ORB orb) { 65 this.orb = orb; 66 } 67 68 public void run() { 69 orb.run(); 70 } 71 } 72 73 public static final GBeanInfo GBEAN_INFO; 74 75 static { 76 GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(AppClientCORBABean.class); 77 78 infoFactory.addAttribute("classLoader", ClassLoader .class, false); 79 infoFactory.addAttribute("ORB", ORB .class, false); 80 81 infoFactory.setConstructor(new String []{"classLoader"}); 82 83 GBEAN_INFO = infoFactory.getBeanInfo(); 84 } 85 86 public static GBeanInfo getGBeanInfo() { 87 return GBEAN_INFO; 88 } 89 90 } 91 | Popular Tags |