src/share/classes/com/sun/corba/se/spi/orb/ORB.java

Print this page




   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.corba.se.spi.orb;
  27 
  28 import java.lang.reflect.InvocationTargetException;
  29 import java.lang.reflect.Method;
  30 import java.util.Map ;
  31 import java.util.HashMap ;
  32 import java.util.Properties ;
  33 import java.util.concurrent.ConcurrentHashMap;
  34 import java.util.logging.Logger ;
  35 
  36 import java.security.AccessController ;
  37 import java.security.PrivilegedAction ;
  38 
  39 import org.omg.CORBA.TCKind ;
  40 
  41 import com.sun.corba.se.pept.broker.Broker ;
  42 import com.sun.corba.se.pept.transport.ByteBufferPool;
  43 
  44 import com.sun.corba.se.spi.protocol.RequestDispatcherRegistry ;
  45 import com.sun.corba.se.spi.protocol.ClientDelegateFactory ;
  46 import com.sun.corba.se.spi.protocol.CorbaServerRequestDispatcher ;
  47 import com.sun.corba.se.spi.protocol.CorbaMessageMediator ;
  48 import com.sun.corba.se.spi.protocol.PIHandler ;
  49 import com.sun.corba.se.spi.resolver.LocalResolver ;
  50 import com.sun.corba.se.spi.resolver.Resolver ;
  51 import com.sun.corba.se.spi.transport.CorbaContactInfoListFactory ;
  52 import com.sun.corba.se.spi.legacy.connection.LegacyServerSocketEndPointInfo;
  53 import com.sun.corba.se.spi.legacy.connection.LegacyServerSocketManager;
  54 import com.sun.corba.se.spi.monitoring.MonitoringConstants;
  55 import com.sun.corba.se.spi.monitoring.MonitoringManager;
  56 import com.sun.corba.se.spi.monitoring.MonitoringManagerFactory;
  57 import com.sun.corba.se.spi.monitoring.MonitoringFactories;
  58 
  59 import com.sun.corba.se.spi.ior.IdentifiableFactoryFinder ;
  60 import com.sun.corba.se.spi.ior.TaggedComponentFactoryFinder ;
  61 import com.sun.corba.se.spi.ior.ObjectKey ;
  62 import com.sun.corba.se.spi.ior.ObjectKeyFactory ;
  63 import com.sun.corba.se.spi.ior.IOR ;
  64 
  65 import com.sun.corba.se.spi.orbutil.closure.Closure ;
  66 
  67 import com.sun.corba.se.spi.orb.Operation ;
  68 import com.sun.corba.se.spi.orb.ORBData ;
  69 import com.sun.corba.se.spi.orb.ORBVersion ;
  70 import com.sun.corba.se.spi.orbutil.threadpool.ThreadPoolManager;
  71 
  72 import com.sun.corba.se.spi.oa.OAInvocationInfo ;
  73 import com.sun.corba.se.spi.transport.CorbaTransportManager;
  74 
  75 import com.sun.corba.se.spi.logging.LogWrapperFactory ;
  76 import com.sun.corba.se.spi.logging.LogWrapperBase ;
  77 import com.sun.corba.se.spi.logging.CORBALogDomains ;
  78 
  79 import com.sun.corba.se.spi.copyobject.CopierManager ;
  80 
  81 import com.sun.corba.se.spi.presentation.rmi.PresentationManager ;
  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.


 129     public boolean poaConcurrencyDebugFlag = false ;
 130     public boolean poaFSMDebugFlag = false ;
 131     public boolean orbdDebugFlag = false ;
 132     public boolean namingDebugFlag = false ;
 133     public boolean serviceContextDebugFlag = false ;
 134     public boolean transientObjectManagerDebugFlag = false ;
 135     public boolean giopVersionDebugFlag = false;
 136     public boolean shutdownDebugFlag = false;
 137     public boolean giopDebugFlag = false;
 138     public boolean invocationTimingDebugFlag = false ;
 139 
 140     // SystemException log wrappers.  Protected so that they can be used in
 141     // subclasses.
 142     protected static ORBUtilSystemException staticWrapper ;
 143     protected ORBUtilSystemException wrapper ;
 144     protected OMGSystemException omgWrapper ;
 145 
 146     // This map is needed for resolving recursive type code placeholders
 147     // based on the unique repository id.
 148     // XXX Should this be a WeakHashMap for GC?
 149     private Map typeCodeMap ;
 150 
 151     private TypeCodeImpl[] primitiveTypeCodeConstants ;
 152 
 153     // ByteBufferPool - needed by both ORBImpl and ORBSingleton
 154     ByteBufferPool byteBufferPool;
 155 
 156     // Local testing
 157     // XXX clean this up, probably remove these
 158     public abstract boolean isLocalHost( String hostName ) ;
 159     public abstract boolean isLocalServerId( int subcontractId, int serverId ) ;
 160 
 161     // Invocation stack manipulation
 162     public abstract OAInvocationInfo peekInvocationInfo() ;
 163     public abstract void pushInvocationInfo( OAInvocationInfo info ) ;
 164     public abstract OAInvocationInfo popInvocationInfo() ;
 165 
 166     public abstract CorbaTransportManager getCorbaTransportManager();
 167     public abstract LegacyServerSocketManager getLegacyServerSocketManager();
 168 
 169     // wrapperMap maintains a table of LogWrapper instances used by
 170     // different classes to log exceptions.  The key is a StringPair
 171     // representing LogDomain and ExceptionGroup.
 172     private Map wrapperMap ;
 173 
 174     static class Holder {
 175         static final PresentationManager defaultPresentationManager =
 176             setupPresentationManager();
 177     }
 178 
 179     private static final Map<Object, PresentationManager> pmContexts = new HashMap<>();

 180 
 181     private static Map staticWrapperMap = new ConcurrentHashMap();

 182 
 183     protected MonitoringManager monitoringManager;
 184 
 185     private static PresentationManager setupPresentationManager() {
 186         staticWrapper = ORBUtilSystemException.get(
 187             CORBALogDomains.RPC_PRESENTATION ) ;
 188 
 189         boolean useDynamicStub =
 190             ((Boolean)AccessController.doPrivileged(
 191                 new PrivilegedAction() {
 192                     public java.lang.Object run() {
 193                         return Boolean.valueOf( Boolean.getBoolean (
 194                             ORBConstants.USE_DYNAMIC_STUB_PROPERTY ) ) ;
 195                     }
 196                 }
 197             )).booleanValue() ;
 198 
 199         PresentationManager.StubFactoryFactory dynamicStubFactoryFactory =
 200             (PresentationManager.StubFactoryFactory)AccessController.doPrivileged(
 201                 new PrivilegedAction() {


 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
 292         // everywhere (for example, in TypeCodeImpl).
 293         wrapperMap = new ConcurrentHashMap();
 294         wrapper = ORBUtilSystemException.get( this,
 295             CORBALogDomains.RPC_PRESENTATION ) ;
 296         omgWrapper = OMGSystemException.get( this,
 297             CORBALogDomains.RPC_PRESENTATION ) ;
 298 
 299         typeCodeMap = new HashMap();
 300 
 301         primitiveTypeCodeConstants = new TypeCodeImpl[] {
 302             new TypeCodeImpl(this, TCKind._tk_null),
 303             new TypeCodeImpl(this, TCKind._tk_void),
 304             new TypeCodeImpl(this, TCKind._tk_short),
 305             new TypeCodeImpl(this, TCKind._tk_long),
 306             new TypeCodeImpl(this, TCKind._tk_ushort),
 307             new TypeCodeImpl(this, TCKind._tk_ulong),
 308             new TypeCodeImpl(this, TCKind._tk_float),
 309             new TypeCodeImpl(this, TCKind._tk_double),
 310             new TypeCodeImpl(this, TCKind._tk_boolean),
 311             new TypeCodeImpl(this, TCKind._tk_char),
 312             new TypeCodeImpl(this, TCKind._tk_octet),
 313             new TypeCodeImpl(this, TCKind._tk_any),
 314             new TypeCodeImpl(this, TCKind._tk_TypeCode),
 315             new TypeCodeImpl(this, TCKind._tk_Principal),
 316             new TypeCodeImpl(this, TCKind._tk_objref),
 317             null,       // tk_struct
 318             null,       // tk_union
 319             null,       // tk_enum


 346     {
 347         synchronized (this) {
 348             checkShutdownState();
 349         }
 350         try {
 351             return primitiveTypeCodeConstants[kind] ;
 352         } catch (Throwable t) {
 353             throw wrapper.invalidTypecodeKind( t, new Integer(kind) ) ;
 354         }
 355     }
 356 
 357     public synchronized void setTypeCode(String id, TypeCodeImpl code)
 358     {
 359         checkShutdownState();
 360         typeCodeMap.put(id, code);
 361     }
 362 
 363     public synchronized TypeCodeImpl getTypeCode(String id)
 364     {
 365         checkShutdownState();
 366         return (TypeCodeImpl)typeCodeMap.get(id);
 367     }
 368 
 369     public MonitoringManager getMonitoringManager( ) {
 370         synchronized (this) {
 371             checkShutdownState();
 372         }
 373         return monitoringManager;
 374     }
 375 
 376     // Special non-standard set_parameters method for
 377     // creating a precisely controlled ORB instance.
 378     // An ORB created by this call is affected only by
 379     // those properties passes explicitly in props, not by
 380     // the system properties and orb.properties files as
 381     // with the standard ORB.init methods.
 382     public abstract void set_parameters( Properties props ) ;
 383 
 384     // ORB versioning
 385     public abstract ORBVersion getORBVersion() ;
 386     public abstract void setORBVersion( ORBVersion version ) ;


 509 
 510         return getCORBALogger( ORBId, domain ) ;
 511     }
 512 
 513     public static Logger staticGetLogger( String domain )
 514     {
 515         return getCORBALogger( "_CORBA_", domain ) ;
 516     }
 517 
 518     private static Logger getCORBALogger( String ORBId, String domain )
 519     {
 520         String fqLogDomain = CORBALogDomains.TOP_LEVEL_DOMAIN + "." +
 521             ORBId + "." + domain;
 522 
 523         return Logger.getLogger( fqLogDomain, ORBConstants.LOG_RESOURCE_FILE );
 524     }
 525 
 526     /** get the log wrapper class (its type is dependent on the exceptionGroup) for the
 527      * given log domain and exception group in this ORB instance.
 528      */
 529     public LogWrapperBase getLogWrapper( String logDomain,
 530         String exceptionGroup, LogWrapperFactory factory )
 531     {
 532         StringPair key = new StringPair( logDomain, exceptionGroup ) ;
 533 
 534         LogWrapperBase logWrapper = (LogWrapperBase)wrapperMap.get( key );
 535         if (logWrapper == null) {
 536             logWrapper = factory.create( getLogger( logDomain ) );
 537             wrapperMap.put( key, logWrapper );
 538         }
 539 
 540         return logWrapper;
 541     }
 542 
 543     /** get the log wrapper class (its type is dependent on the exceptionGroup) for the
 544      * given log domain and exception group in this ORB instance.
 545      */
 546     public static LogWrapperBase staticGetLogWrapper( String logDomain,
 547         String exceptionGroup, LogWrapperFactory factory )
 548     {
 549         StringPair key = new StringPair( logDomain, exceptionGroup ) ;
 550 
 551         LogWrapperBase logWrapper = (LogWrapperBase)staticWrapperMap.get( key );
 552         if (logWrapper == null) {
 553             logWrapper = factory.create( staticGetLogger( logDomain ) );
 554             staticWrapperMap.put( key, logWrapper );
 555         }
 556 
 557         return logWrapper;
 558     }
 559 
 560     // get a reference to a ByteBufferPool, a pool of NIO ByteBuffers
 561     // NOTE: ByteBuffer pool must be unique per ORB, not per process.
 562     //       There can be more than one ORB per process.
 563     //       This method must also be inherited by both ORB and ORBSingleton.
 564     public ByteBufferPool getByteBufferPool()
 565     {
 566         synchronized (this) {
 567             checkShutdownState();
 568         }
 569         if (byteBufferPool == null)
 570             byteBufferPool = new ByteBufferPoolImpl(this);
 571 
 572         return byteBufferPool;
 573     }
 574 


   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.corba.se.spi.orb;
  27 


  28 import java.util.Map ;
  29 import java.util.HashMap ;
  30 import java.util.Properties ;
  31 import java.util.concurrent.ConcurrentHashMap;
  32 import java.util.logging.Logger ;
  33 
  34 import java.security.AccessController ;
  35 import java.security.PrivilegedAction ;
  36 
  37 import org.omg.CORBA.TCKind ;
  38 
  39 import com.sun.corba.se.pept.broker.Broker ;
  40 import com.sun.corba.se.pept.transport.ByteBufferPool;
  41 
  42 import com.sun.corba.se.spi.protocol.RequestDispatcherRegistry ;
  43 import com.sun.corba.se.spi.protocol.ClientDelegateFactory ;
  44 import com.sun.corba.se.spi.protocol.CorbaServerRequestDispatcher ;

  45 import com.sun.corba.se.spi.protocol.PIHandler ;
  46 import com.sun.corba.se.spi.resolver.LocalResolver ;
  47 import com.sun.corba.se.spi.resolver.Resolver ;
  48 import com.sun.corba.se.spi.transport.CorbaContactInfoListFactory ;

  49 import com.sun.corba.se.spi.legacy.connection.LegacyServerSocketManager;
  50 import com.sun.corba.se.spi.monitoring.MonitoringConstants;
  51 import com.sun.corba.se.spi.monitoring.MonitoringManager;

  52 import com.sun.corba.se.spi.monitoring.MonitoringFactories;
  53 
  54 import com.sun.corba.se.spi.ior.IdentifiableFactoryFinder ;
  55 import com.sun.corba.se.spi.ior.TaggedComponentFactoryFinder ;
  56 import com.sun.corba.se.spi.ior.ObjectKey ;
  57 import com.sun.corba.se.spi.ior.ObjectKeyFactory ;
  58 import com.sun.corba.se.spi.ior.IOR ;
  59 





  60 import com.sun.corba.se.spi.orbutil.threadpool.ThreadPoolManager;
  61 
  62 import com.sun.corba.se.spi.oa.OAInvocationInfo ;
  63 import com.sun.corba.se.spi.transport.CorbaTransportManager;
  64 
  65 import com.sun.corba.se.spi.logging.LogWrapperFactory ;
  66 import com.sun.corba.se.spi.logging.LogWrapperBase ;
  67 import com.sun.corba.se.spi.logging.CORBALogDomains ;
  68 
  69 import com.sun.corba.se.spi.copyobject.CopierManager ;
  70 
  71 import com.sun.corba.se.spi.presentation.rmi.PresentationManager ;
  72 import com.sun.corba.se.spi.presentation.rmi.PresentationDefaults ;
  73 
  74 import com.sun.corba.se.spi.servicecontext.ServiceContextRegistry ;
  75 
  76 // XXX needs an SPI or else it does not belong here
  77 import com.sun.corba.se.impl.corba.TypeCodeImpl ;
  78 import com.sun.corba.se.impl.corba.TypeCodeFactory ;
  79 
  80 // XXX Should there be a SPI level constants ?
  81 import com.sun.corba.se.impl.orbutil.ORBConstants ;
  82 
  83 import com.sun.corba.se.impl.oa.poa.BadServerIdHandler ;
  84 
  85 import com.sun.corba.se.impl.transport.ByteBufferPoolImpl;
  86 
  87 import com.sun.corba.se.impl.logging.ORBUtilSystemException ;
  88 import com.sun.corba.se.impl.logging.OMGSystemException ;
  89 
  90 import com.sun.corba.se.impl.presentation.rmi.PresentationManagerImpl ;
  91 


  92 public abstract class ORB extends com.sun.corba.se.org.omg.CORBA.ORB
  93     implements Broker, TypeCodeFactory
  94 {
  95     // As much as possible, this class should be stateless.  However,
  96     // there are a few reasons why it is not:
  97     //
  98     // 1. The ORB debug flags are defined here because they are accessed
  99     //    frequently, and we do not want a cast to the impl just for that.
 100     // 2. typeCodeMap and primitiveTypeCodeConstants are here because they
 101     //    are needed in both ORBImpl and ORBSingleton.
 102     // 3. Logging support is here so that we can avoid problems with
 103     //    incompletely initialized ORBs that need to perform logging.
 104 
 105     // Flag set at compile time to debug flag processing: this can't
 106     // be one of the xxxDebugFlags because it is used to debug the mechanism
 107     // that sets the xxxDebugFlags!
 108     public static boolean ORBInitDebug = false;
 109 
 110     // Currently defined debug flags.  Any additions must be called xxxDebugFlag.
 111     // All debug flags must be public boolean types.


 117     public boolean poaConcurrencyDebugFlag = false ;
 118     public boolean poaFSMDebugFlag = false ;
 119     public boolean orbdDebugFlag = false ;
 120     public boolean namingDebugFlag = false ;
 121     public boolean serviceContextDebugFlag = false ;
 122     public boolean transientObjectManagerDebugFlag = false ;
 123     public boolean giopVersionDebugFlag = false;
 124     public boolean shutdownDebugFlag = false;
 125     public boolean giopDebugFlag = false;
 126     public boolean invocationTimingDebugFlag = false ;
 127 
 128     // SystemException log wrappers.  Protected so that they can be used in
 129     // subclasses.
 130     protected static ORBUtilSystemException staticWrapper ;
 131     protected ORBUtilSystemException wrapper ;
 132     protected OMGSystemException omgWrapper ;
 133 
 134     // This map is needed for resolving recursive type code placeholders
 135     // based on the unique repository id.
 136     // XXX Should this be a WeakHashMap for GC?
 137     private Map<String, TypeCodeImpl> typeCodeMap;
 138 
 139     private TypeCodeImpl[] primitiveTypeCodeConstants;
 140 
 141     // ByteBufferPool - needed by both ORBImpl and ORBSingleton
 142     ByteBufferPool byteBufferPool;
 143 
 144     // Local testing
 145     // XXX clean this up, probably remove these
 146     public abstract boolean isLocalHost( String hostName ) ;
 147     public abstract boolean isLocalServerId( int subcontractId, int serverId ) ;
 148 
 149     // Invocation stack manipulation
 150     public abstract OAInvocationInfo peekInvocationInfo() ;
 151     public abstract void pushInvocationInfo( OAInvocationInfo info ) ;
 152     public abstract OAInvocationInfo popInvocationInfo() ;
 153 
 154     public abstract CorbaTransportManager getCorbaTransportManager();
 155     public abstract LegacyServerSocketManager getLegacyServerSocketManager();
 156 
 157     // wrapperMap maintains a table of LogWrapper instances used by
 158     // different classes to log exceptions.  The key is a StringPair
 159     // representing LogDomain and ExceptionGroup.
 160     private Map<StringPair, LogWrapperBase> wrapperMap;
 161 
 162     static class Holder {
 163         static final PresentationManager defaultPresentationManager =
 164             setupPresentationManager();
 165     }
 166 
 167     private static final Map<Object, PresentationManager> pmContexts =
 168             new ConcurrentHashMap<>();
 169 
 170     private static Map<StringPair, LogWrapperBase> staticWrapperMap =
 171             new ConcurrentHashMap<>();
 172 
 173     protected MonitoringManager monitoringManager;
 174 
 175     private static PresentationManager setupPresentationManager() {
 176         staticWrapper = ORBUtilSystemException.get(
 177             CORBALogDomains.RPC_PRESENTATION ) ;
 178 
 179         boolean useDynamicStub =
 180             ((Boolean)AccessController.doPrivileged(
 181                 new PrivilegedAction() {
 182                     public java.lang.Object run() {
 183                         return Boolean.valueOf( Boolean.getBoolean (
 184                             ORBConstants.USE_DYNAMIC_STUB_PROPERTY ) ) ;
 185                     }
 186                 }
 187             )).booleanValue() ;
 188 
 189         PresentationManager.StubFactoryFactory dynamicStubFactoryFactory =
 190             (PresentationManager.StubFactoryFactory)AccessController.doPrivileged(
 191                 new PrivilegedAction() {


 218             PresentationDefaults.getStaticStubFactoryFactory() ) ;
 219         pm.setStubFactoryFactory( true, dynamicStubFactoryFactory ) ;
 220         return pm;
 221     }
 222 
 223     public void destroy() {
 224         wrapper = null;
 225         omgWrapper = null;
 226         typeCodeMap = null;
 227         primitiveTypeCodeConstants = null;
 228         byteBufferPool = null;
 229     }
 230 
 231     /**
 232      * Returns the Presentation Manager for the current thread group, using the ThreadGroup-specific
 233      * AppContext to hold it. Creates and records one if needed.
 234      */
 235     public static PresentationManager getPresentationManager()
 236     {
 237         SecurityManager sm = System.getSecurityManager();
 238         sun.misc.JavaAWTAccess javaAwtAccess = sun.misc.SharedSecrets.getJavaAWTAccess();
 239         if (sm != null && javaAwtAccess != null) {
 240             final Object appletContext = javaAwtAccess.getAppletContext();










 241             if (appletContext != null) {
 242                 return pmContexts.computeIfAbsent(appletContext,
 243                     x -> setupPresentationManager());



 244             }

 245         }


 246 
 247         // No security manager or AppletAppContext
 248         return Holder.defaultPresentationManager;
 249     }
 250 
 251     /** Get the appropriate StubFactoryFactory.  This
 252      * will be dynamic or static depending on whether
 253      * com.sun.CORBA.ORBUseDynamicStub is true or false.
 254      */
 255     public static PresentationManager.StubFactoryFactory
 256         getStubFactoryFactory()
 257     {
 258         PresentationManager gPM = getPresentationManager();
 259         boolean useDynamicStubs = gPM.useDynamicStubs() ;
 260         return gPM.getStubFactoryFactory( useDynamicStubs ) ;
 261     }
 262 
 263     protected ORB()
 264     {
 265         // Initialize logging first, since it is needed nearly
 266         // everywhere (for example, in TypeCodeImpl).
 267         wrapperMap = new ConcurrentHashMap<>();
 268         wrapper = ORBUtilSystemException.get( this,
 269             CORBALogDomains.RPC_PRESENTATION ) ;
 270         omgWrapper = OMGSystemException.get( this,
 271             CORBALogDomains.RPC_PRESENTATION ) ;
 272 
 273         typeCodeMap = new HashMap<>();
 274 
 275         primitiveTypeCodeConstants = new TypeCodeImpl[] {
 276             new TypeCodeImpl(this, TCKind._tk_null),
 277             new TypeCodeImpl(this, TCKind._tk_void),
 278             new TypeCodeImpl(this, TCKind._tk_short),
 279             new TypeCodeImpl(this, TCKind._tk_long),
 280             new TypeCodeImpl(this, TCKind._tk_ushort),
 281             new TypeCodeImpl(this, TCKind._tk_ulong),
 282             new TypeCodeImpl(this, TCKind._tk_float),
 283             new TypeCodeImpl(this, TCKind._tk_double),
 284             new TypeCodeImpl(this, TCKind._tk_boolean),
 285             new TypeCodeImpl(this, TCKind._tk_char),
 286             new TypeCodeImpl(this, TCKind._tk_octet),
 287             new TypeCodeImpl(this, TCKind._tk_any),
 288             new TypeCodeImpl(this, TCKind._tk_TypeCode),
 289             new TypeCodeImpl(this, TCKind._tk_Principal),
 290             new TypeCodeImpl(this, TCKind._tk_objref),
 291             null,       // tk_struct
 292             null,       // tk_union
 293             null,       // tk_enum


 320     {
 321         synchronized (this) {
 322             checkShutdownState();
 323         }
 324         try {
 325             return primitiveTypeCodeConstants[kind] ;
 326         } catch (Throwable t) {
 327             throw wrapper.invalidTypecodeKind( t, new Integer(kind) ) ;
 328         }
 329     }
 330 
 331     public synchronized void setTypeCode(String id, TypeCodeImpl code)
 332     {
 333         checkShutdownState();
 334         typeCodeMap.put(id, code);
 335     }
 336 
 337     public synchronized TypeCodeImpl getTypeCode(String id)
 338     {
 339         checkShutdownState();
 340         return typeCodeMap.get(id);
 341     }
 342 
 343     public MonitoringManager getMonitoringManager( ) {
 344         synchronized (this) {
 345             checkShutdownState();
 346         }
 347         return monitoringManager;
 348     }
 349 
 350     // Special non-standard set_parameters method for
 351     // creating a precisely controlled ORB instance.
 352     // An ORB created by this call is affected only by
 353     // those properties passes explicitly in props, not by
 354     // the system properties and orb.properties files as
 355     // with the standard ORB.init methods.
 356     public abstract void set_parameters( Properties props ) ;
 357 
 358     // ORB versioning
 359     public abstract ORBVersion getORBVersion() ;
 360     public abstract void setORBVersion( ORBVersion version ) ;


 483 
 484         return getCORBALogger( ORBId, domain ) ;
 485     }
 486 
 487     public static Logger staticGetLogger( String domain )
 488     {
 489         return getCORBALogger( "_CORBA_", domain ) ;
 490     }
 491 
 492     private static Logger getCORBALogger( String ORBId, String domain )
 493     {
 494         String fqLogDomain = CORBALogDomains.TOP_LEVEL_DOMAIN + "." +
 495             ORBId + "." + domain;
 496 
 497         return Logger.getLogger( fqLogDomain, ORBConstants.LOG_RESOURCE_FILE );
 498     }
 499 
 500     /** get the log wrapper class (its type is dependent on the exceptionGroup) for the
 501      * given log domain and exception group in this ORB instance.
 502      */
 503     public LogWrapperBase getLogWrapper(String logDomain,
 504         String exceptionGroup, LogWrapperFactory factory)
 505     {
 506         StringPair key = new StringPair(logDomain, exceptionGroup);
 507 
 508         LogWrapperBase logWrapper = wrapperMap.get(key);
 509         if (logWrapper == null) {
 510             logWrapper = factory.create(getLogger(logDomain));
 511             wrapperMap.put(key, logWrapper);
 512         }
 513 
 514         return logWrapper;
 515     }
 516 
 517     /** get the log wrapper class (its type is dependent on the exceptionGroup) for the
 518      * given log domain and exception group in this ORB instance.
 519      */
 520     public static LogWrapperBase staticGetLogWrapper(String logDomain,
 521         String exceptionGroup, LogWrapperFactory factory)
 522     {
 523         StringPair key = new StringPair(logDomain, exceptionGroup);
 524 
 525         LogWrapperBase logWrapper = staticWrapperMap.get(key);
 526         if (logWrapper == null) {
 527             logWrapper = factory.create( staticGetLogger(logDomain));
 528             staticWrapperMap.put(key, logWrapper);
 529         }
 530 
 531         return logWrapper;
 532     }
 533 
 534     // get a reference to a ByteBufferPool, a pool of NIO ByteBuffers
 535     // NOTE: ByteBuffer pool must be unique per ORB, not per process.
 536     //       There can be more than one ORB per process.
 537     //       This method must also be inherited by both ORB and ORBSingleton.
 538     public ByteBufferPool getByteBufferPool()
 539     {
 540         synchronized (this) {
 541             checkShutdownState();
 542         }
 543         if (byteBufferPool == null)
 544             byteBufferPool = new ByteBufferPoolImpl(this);
 545 
 546         return byteBufferPool;
 547     }
 548