1 28 package org.objectweb.carol.jndi.spi; 29 30 import java.util.Hashtable ; 31 32 import javax.naming.NamingException ; 33 import javax.naming.spi.InitialContextFactory ; 34 35 import org.omg.CORBA.ORB ; 36 import org.omg.PortableServer.POA ; 37 38 import org.objectweb.carol.jndi.ns.IIOPCosNaming; 39 import org.objectweb.carol.rmi.exception.NamingExceptionHelper; 40 import org.objectweb.carol.util.configuration.CarolDefaultValues; 41 42 50 public class IIOPContextWrapperFactory extends AbsInitialContextFactory implements InitialContextFactory { 51 52 55 public static final String REFERENCING_FACTORY = "com.sun.jndi.cosnaming.CNCtxFactory"; 56 57 60 protected String getReferencingFactory() { 61 return REFERENCING_FACTORY; 62 } 63 64 67 protected Class getWrapperClass() { 68 return IIOPContext.class; 69 } 70 71 74 private static ORB orb = null; 75 76 79 private static boolean orbStarted = false; 80 81 84 private static POA rootPOA = null; 85 86 90 protected void init() throws NamingException { 91 if (orb == null) { 93 orb = IIOPCosNaming.getOrb(); 94 } 95 96 if (!orbStarted && System.getProperty(CarolDefaultValues.SERVER_MODE, "false").equalsIgnoreCase("true")) { 97 new Thread (new Runnable () { 99 100 public void run() { 101 orb.run(); 102 } 103 }).start(); 104 orbStarted = true; 105 } 106 107 if (rootPOA == null) { 109 try { 110 rootPOA = org.omg.PortableServer.POAHelper.narrow(orb.resolve_initial_references("RootPOA")); 111 rootPOA.the_POAManager().activate(); 112 } catch (Exception e) { 113 throw NamingExceptionHelper.create("Cannot get a single instance of rootPOA : " + e.getMessage(), e); 114 } 115 } 116 117 } 118 119 123 protected void addExtraConfInEnvironment(Hashtable environment) { 124 environment.put("java.naming.corba.orb", orb); 125 } 126 } | Popular Tags |