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

Print this page

        

@@ -23,12 +23,10 @@
  * questions.
  */
 
 package com.sun.corba.se.spi.orb;
 
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
 import java.util.Map ;
 import java.util.HashMap ;
 import java.util.Properties ;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.logging.Logger ;

@@ -42,33 +40,25 @@
 import com.sun.corba.se.pept.transport.ByteBufferPool;
 
 import com.sun.corba.se.spi.protocol.RequestDispatcherRegistry ;
 import com.sun.corba.se.spi.protocol.ClientDelegateFactory ;
 import com.sun.corba.se.spi.protocol.CorbaServerRequestDispatcher ;
-import com.sun.corba.se.spi.protocol.CorbaMessageMediator ;
 import com.sun.corba.se.spi.protocol.PIHandler ;
 import com.sun.corba.se.spi.resolver.LocalResolver ;
 import com.sun.corba.se.spi.resolver.Resolver ;
 import com.sun.corba.se.spi.transport.CorbaContactInfoListFactory ;
-import com.sun.corba.se.spi.legacy.connection.LegacyServerSocketEndPointInfo;
 import com.sun.corba.se.spi.legacy.connection.LegacyServerSocketManager;
 import com.sun.corba.se.spi.monitoring.MonitoringConstants;
 import com.sun.corba.se.spi.monitoring.MonitoringManager;
-import com.sun.corba.se.spi.monitoring.MonitoringManagerFactory;
 import com.sun.corba.se.spi.monitoring.MonitoringFactories;
 
 import com.sun.corba.se.spi.ior.IdentifiableFactoryFinder ;
 import com.sun.corba.se.spi.ior.TaggedComponentFactoryFinder ;
 import com.sun.corba.se.spi.ior.ObjectKey ;
 import com.sun.corba.se.spi.ior.ObjectKeyFactory ;
 import com.sun.corba.se.spi.ior.IOR ;
 
-import com.sun.corba.se.spi.orbutil.closure.Closure ;
-
-import com.sun.corba.se.spi.orb.Operation ;
-import com.sun.corba.se.spi.orb.ORBData ;
-import com.sun.corba.se.spi.orb.ORBVersion ;
 import com.sun.corba.se.spi.orbutil.threadpool.ThreadPoolManager;
 
 import com.sun.corba.se.spi.oa.OAInvocationInfo ;
 import com.sun.corba.se.spi.transport.CorbaTransportManager;
 

@@ -97,12 +87,10 @@
 import com.sun.corba.se.impl.logging.ORBUtilSystemException ;
 import com.sun.corba.se.impl.logging.OMGSystemException ;
 
 import com.sun.corba.se.impl.presentation.rmi.PresentationManagerImpl ;
 
-import sun.misc.JavaAWTAccess;
-
 public abstract class ORB extends com.sun.corba.se.org.omg.CORBA.ORB
     implements Broker, TypeCodeFactory
 {
     // As much as possible, this class should be stateless.  However,
     // there are a few reasons why it is not:

@@ -144,13 +132,13 @@
     protected OMGSystemException omgWrapper ;
 
     // This map is needed for resolving recursive type code placeholders
     // based on the unique repository id.
     // XXX Should this be a WeakHashMap for GC?
-    private Map typeCodeMap ;
+    private Map<String, TypeCodeImpl> typeCodeMap;
 
-    private TypeCodeImpl[] primitiveTypeCodeConstants ;
+    private TypeCodeImpl[] primitiveTypeCodeConstants;
 
     // ByteBufferPool - needed by both ORBImpl and ORBSingleton
     ByteBufferPool byteBufferPool;
 
     // Local testing

@@ -167,20 +155,22 @@
     public abstract LegacyServerSocketManager getLegacyServerSocketManager();
 
     // wrapperMap maintains a table of LogWrapper instances used by
     // different classes to log exceptions.  The key is a StringPair
     // representing LogDomain and ExceptionGroup.
-    private Map wrapperMap ;
+    private Map<StringPair, LogWrapperBase> wrapperMap;
 
     static class Holder {
         static final PresentationManager defaultPresentationManager =
             setupPresentationManager();
     }
 
-    private static final Map<Object, PresentationManager> pmContexts = new HashMap<>();
+    private static final Map<Object, PresentationManager> pmContexts =
+            new ConcurrentHashMap<>();
 
-    private static Map staticWrapperMap = new ConcurrentHashMap();
+    private static Map<StringPair, LogWrapperBase> staticWrapperMap =
+            new ConcurrentHashMap<>();
 
     protected MonitoringManager monitoringManager;
 
     private static PresentationManager setupPresentationManager() {
         staticWrapper = ORBUtilSystemException.get(

@@ -243,34 +233,18 @@
      * AppContext to hold it. Creates and records one if needed.
      */
     public static PresentationManager getPresentationManager()
     {
         SecurityManager sm = System.getSecurityManager();
-        JavaAWTAccess javaAwtAccess = sun.misc.SharedSecrets.getJavaAWTAccess();
+        sun.misc.JavaAWTAccess javaAwtAccess = sun.misc.SharedSecrets.getJavaAWTAccess();
         if (sm != null && javaAwtAccess != null) {
-            Object appletContext;
-            try {
-                Class<?> clazz = JavaAWTAccess.class;
-                Method method = clazz.getMethod("getAppletContext");
-                appletContext = method.invoke(javaAwtAccess);
-            } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
-                InternalError err = new InternalError();
-                err.initCause(e);
-                throw err;
-            }
-
+            final Object appletContext = javaAwtAccess.getAppletContext();
             if (appletContext != null) {
-                synchronized (pmContexts) {
-                    PresentationManager pm = pmContexts.get(appletContext);
-                    if (pm == null) {
-                        pm = setupPresentationManager();
-                        pmContexts.put(appletContext, pm);
+                return pmContexts.computeIfAbsent(appletContext,
+                    x -> setupPresentationManager());
                     }
-                    return pm;
                 }
-            }
-        }
 
         // No security manager or AppletAppContext
         return Holder.defaultPresentationManager;
     }
 

@@ -288,17 +262,17 @@
 
     protected ORB()
     {
         // Initialize logging first, since it is needed nearly
         // everywhere (for example, in TypeCodeImpl).
-        wrapperMap = new ConcurrentHashMap();
+        wrapperMap = new ConcurrentHashMap<>();
         wrapper = ORBUtilSystemException.get( this,
             CORBALogDomains.RPC_PRESENTATION ) ;
         omgWrapper = OMGSystemException.get( this,
             CORBALogDomains.RPC_PRESENTATION ) ;
 
-        typeCodeMap = new HashMap();
+        typeCodeMap = new HashMap<>();
 
         primitiveTypeCodeConstants = new TypeCodeImpl[] {
             new TypeCodeImpl(this, TCKind._tk_null),
             new TypeCodeImpl(this, TCKind._tk_void),
             new TypeCodeImpl(this, TCKind._tk_short),

@@ -361,11 +335,11 @@
     }
 
     public synchronized TypeCodeImpl getTypeCode(String id)
     {
         checkShutdownState();
-        return (TypeCodeImpl)typeCodeMap.get(id);
+        return typeCodeMap.get(id);
     }
 
     public MonitoringManager getMonitoringManager( ) {
         synchronized (this) {
             checkShutdownState();

@@ -524,36 +498,36 @@
     }
 
     /** get the log wrapper class (its type is dependent on the exceptionGroup) for the
      * given log domain and exception group in this ORB instance.
      */
-    public LogWrapperBase getLogWrapper( String logDomain,
-        String exceptionGroup, LogWrapperFactory factory )
+    public LogWrapperBase getLogWrapper(String logDomain,
+        String exceptionGroup, LogWrapperFactory factory)
     {
-        StringPair key = new StringPair( logDomain, exceptionGroup ) ;
+        StringPair key = new StringPair(logDomain, exceptionGroup);
 
-        LogWrapperBase logWrapper = (LogWrapperBase)wrapperMap.get( key );
+        LogWrapperBase logWrapper = wrapperMap.get(key);
         if (logWrapper == null) {
-            logWrapper = factory.create( getLogger( logDomain ) );
-            wrapperMap.put( key, logWrapper );
+            logWrapper = factory.create(getLogger(logDomain));
+            wrapperMap.put(key, logWrapper);
         }
 
         return logWrapper;
     }
 
     /** get the log wrapper class (its type is dependent on the exceptionGroup) for the
      * given log domain and exception group in this ORB instance.
      */
-    public static LogWrapperBase staticGetLogWrapper( String logDomain,
-        String exceptionGroup, LogWrapperFactory factory )
+    public static LogWrapperBase staticGetLogWrapper(String logDomain,
+        String exceptionGroup, LogWrapperFactory factory)
     {
-        StringPair key = new StringPair( logDomain, exceptionGroup ) ;
+        StringPair key = new StringPair(logDomain, exceptionGroup);
 
-        LogWrapperBase logWrapper = (LogWrapperBase)staticWrapperMap.get( key );
+        LogWrapperBase logWrapper = staticWrapperMap.get(key);
         if (logWrapper == null) {
-            logWrapper = factory.create( staticGetLogger( logDomain ) );
-            staticWrapperMap.put( key, logWrapper );
+            logWrapper = factory.create( staticGetLogger(logDomain));
+            staticWrapperMap.put(key, logWrapper);
         }
 
         return logWrapper;
     }