82 import com.sun.corba.se.spi.presentation.rmi.PresentationDefaults ; 83 84 import com.sun.corba.se.spi.servicecontext.ServiceContextRegistry ; 85 86 // XXX needs an SPI or else it does not belong here 87 import com.sun.corba.se.impl.corba.TypeCodeImpl ; 88 import com.sun.corba.se.impl.corba.TypeCodeFactory ; 89 90 // XXX Should there be a SPI level constants ? 91 import com.sun.corba.se.impl.orbutil.ORBConstants ; 92 93 import com.sun.corba.se.impl.oa.poa.BadServerIdHandler ; 94 95 import com.sun.corba.se.impl.transport.ByteBufferPoolImpl; 96 97 import com.sun.corba.se.impl.logging.ORBUtilSystemException ; 98 import com.sun.corba.se.impl.logging.OMGSystemException ; 99 100 import com.sun.corba.se.impl.presentation.rmi.PresentationManagerImpl ; 101 102 import sun.misc.JavaAWTAccess; 103 104 public abstract class ORB extends com.sun.corba.se.org.omg.CORBA.ORB 105 implements Broker, TypeCodeFactory 106 { 107 // As much as possible, this class should be stateless. However, 108 // there are a few reasons why it is not: 109 // 110 // 1. The ORB debug flags are defined here because they are accessed 111 // frequently, and we do not want a cast to the impl just for that. 112 // 2. typeCodeMap and primitiveTypeCodeConstants are here because they 113 // are needed in both ORBImpl and ORBSingleton. 114 // 3. Logging support is here so that we can avoid problems with 115 // incompletely initialized ORBs that need to perform logging. 116 117 // Flag set at compile time to debug flag processing: this can't 118 // be one of the xxxDebugFlags because it is used to debug the mechanism 119 // that sets the xxxDebugFlags! 120 public static boolean ORBInitDebug = false; 121 122 // Currently defined debug flags. Any additions must be called xxxDebugFlag. 123 // All debug flags must be public boolean types. 228 PresentationDefaults.getStaticStubFactoryFactory() ) ; 229 pm.setStubFactoryFactory( true, dynamicStubFactoryFactory ) ; 230 return pm; 231 } 232 233 public void destroy() { 234 wrapper = null; 235 omgWrapper = null; 236 typeCodeMap = null; 237 primitiveTypeCodeConstants = null; 238 byteBufferPool = null; 239 } 240 241 /** 242 * Returns the Presentation Manager for the current thread group, using the ThreadGroup-specific 243 * AppContext to hold it. Creates and records one if needed. 244 */ 245 public static PresentationManager getPresentationManager() 246 { 247 SecurityManager sm = System.getSecurityManager(); 248 JavaAWTAccess javaAwtAccess = sun.misc.SharedSecrets.getJavaAWTAccess(); 249 if (sm != null && javaAwtAccess != null) { 250 Object appletContext; 251 try { 252 Class<?> clazz = JavaAWTAccess.class; 253 Method method = clazz.getMethod("getAppletContext"); 254 appletContext = method.invoke(javaAwtAccess); 255 } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { 256 InternalError err = new InternalError(); 257 err.initCause(e); 258 throw err; 259 } 260 261 if (appletContext != null) { 262 synchronized (pmContexts) { 263 PresentationManager pm = pmContexts.get(appletContext); 264 if (pm == null) { 265 pm = setupPresentationManager(); 266 pmContexts.put(appletContext, pm); 267 } 268 return pm; 269 } 270 } 271 } 272 273 // No security manager or AppletAppContext 274 return Holder.defaultPresentationManager; 275 } 276 277 /** Get the appropriate StubFactoryFactory. This 278 * will be dynamic or static depending on whether 279 * com.sun.CORBA.ORBUseDynamicStub is true or false. 280 */ 281 public static PresentationManager.StubFactoryFactory 282 getStubFactoryFactory() 283 { 284 PresentationManager gPM = getPresentationManager(); 285 boolean useDynamicStubs = gPM.useDynamicStubs() ; 286 return gPM.getStubFactoryFactory( useDynamicStubs ) ; 287 } 288 289 protected ORB() 290 { 291 // Initialize logging first, since it is needed nearly | 82 import com.sun.corba.se.spi.presentation.rmi.PresentationDefaults ; 83 84 import com.sun.corba.se.spi.servicecontext.ServiceContextRegistry ; 85 86 // XXX needs an SPI or else it does not belong here 87 import com.sun.corba.se.impl.corba.TypeCodeImpl ; 88 import com.sun.corba.se.impl.corba.TypeCodeFactory ; 89 90 // XXX Should there be a SPI level constants ? 91 import com.sun.corba.se.impl.orbutil.ORBConstants ; 92 93 import com.sun.corba.se.impl.oa.poa.BadServerIdHandler ; 94 95 import com.sun.corba.se.impl.transport.ByteBufferPoolImpl; 96 97 import com.sun.corba.se.impl.logging.ORBUtilSystemException ; 98 import com.sun.corba.se.impl.logging.OMGSystemException ; 99 100 import com.sun.corba.se.impl.presentation.rmi.PresentationManagerImpl ; 101 102 public abstract class ORB extends com.sun.corba.se.org.omg.CORBA.ORB 103 implements Broker, TypeCodeFactory 104 { 105 // As much as possible, this class should be stateless. However, 106 // there are a few reasons why it is not: 107 // 108 // 1. The ORB debug flags are defined here because they are accessed 109 // frequently, and we do not want a cast to the impl just for that. 110 // 2. typeCodeMap and primitiveTypeCodeConstants are here because they 111 // are needed in both ORBImpl and ORBSingleton. 112 // 3. Logging support is here so that we can avoid problems with 113 // incompletely initialized ORBs that need to perform logging. 114 115 // Flag set at compile time to debug flag processing: this can't 116 // be one of the xxxDebugFlags because it is used to debug the mechanism 117 // that sets the xxxDebugFlags! 118 public static boolean ORBInitDebug = false; 119 120 // Currently defined debug flags. Any additions must be called xxxDebugFlag. 121 // All debug flags must be public boolean types. 226 PresentationDefaults.getStaticStubFactoryFactory() ) ; 227 pm.setStubFactoryFactory( true, dynamicStubFactoryFactory ) ; 228 return pm; 229 } 230 231 public void destroy() { 232 wrapper = null; 233 omgWrapper = null; 234 typeCodeMap = null; 235 primitiveTypeCodeConstants = null; 236 byteBufferPool = null; 237 } 238 239 /** 240 * Returns the Presentation Manager for the current thread group, using the ThreadGroup-specific 241 * AppContext to hold it. Creates and records one if needed. 242 */ 243 public static PresentationManager getPresentationManager() 244 { 245 SecurityManager sm = System.getSecurityManager(); 246 try { 247 Method method = sun.misc.SharedSecrets.class.getMethod("getJavaAWTAccess"); 248 Object javaAwtAccess = method.invoke(sun.misc.SharedSecrets.class); 249 if (sm != null && javaAwtAccess != null) { 250 Class<?> javaAwtAccessClass = Class.forName("sun.misc.JavaAWTAccess"); 251 method = javaAwtAccessClass.getMethod("getAppletContext"); 252 Object appletContext = method.invoke(javaAwtAccess); 253 if (appletContext != null) { 254 synchronized (pmContexts) { 255 PresentationManager pm = pmContexts.get(appletContext); 256 if (pm == null) { 257 pm = setupPresentationManager(); 258 pmContexts.put(appletContext, pm); 259 } 260 return pm; 261 } 262 } 263 } 264 } catch (ClassNotFoundException | IllegalAccessException | 265 InvocationTargetException | NoSuchMethodException e) { 266 InternalError err = new InternalError(); 267 err.initCause(e); 268 throw err; 269 } 270 271 // No security manager or AppletAppContext 272 return Holder.defaultPresentationManager; 273 } 274 275 /** Get the appropriate StubFactoryFactory. This 276 * will be dynamic or static depending on whether 277 * com.sun.CORBA.ORBUseDynamicStub is true or false. 278 */ 279 public static PresentationManager.StubFactoryFactory 280 getStubFactoryFactory() 281 { 282 PresentationManager gPM = getPresentationManager(); 283 boolean useDynamicStubs = gPM.useDynamicStubs() ; 284 return gPM.getStubFactoryFactory( useDynamicStubs ) ; 285 } 286 287 protected ORB() 288 { 289 // Initialize logging first, since it is needed nearly |