1 22 package org.jboss.corba; 23 24 import java.security.AccessController ; 25 import java.security.PrivilegedAction ; 26 import java.util.Hashtable ; 27 import java.util.Properties ; 28 29 import org.jboss.logging.Logger; 30 import org.omg.CORBA.ORB ; 31 import org.omg.PortableServer.POA ; 32 33 39 public class ORBFactory 40 { 41 43 44 private static final Logger log = Logger.getLogger(ORBFactory.class); 45 46 47 private static ORB orb; 48 49 51 53 public static ORB getORB() 54 { 55 synchronized (ORBFactory.class) 56 { 57 if (orb == null) 58 { 59 Properties properties; 60 try 61 { 62 properties = (Properties ) AccessController.doPrivileged(new PrivilegedAction () 63 { 64 public Object run() 65 { 66 return System.getProperties(); 67 } 68 }); 69 } 70 catch (SecurityException ignored) 71 { 72 log.trace("Unable to retrieve system properties", ignored); 73 properties = null; 74 } 75 76 orb = ORB.init(new String [0], properties); 78 79 try 81 { 82 POA rootPOA = (POA ) orb.resolve_initial_references("RootPOA"); 83 rootPOA.the_POAManager().activate(); 84 } 85 catch (Throwable t) 86 { 87 log.warn("Unable to activate POA", t); 88 } 89 } 90 return orb; 91 } 92 } 93 94 public static void setORB(ORB orb) 95 { 96 if (ORBFactory.orb != null) 97 throw new IllegalStateException ("ORB has already been set"); 98 ORBFactory.orb = orb; 99 } 100 101 103 105 107 109 111 113 } 115 | Popular Tags |