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 ;


  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     {




   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.CorbaMessageMediator ;
  46 import com.sun.corba.se.spi.protocol.PIHandler ;
  47 import com.sun.corba.se.spi.resolver.LocalResolver ;


  80 import com.sun.corba.se.spi.presentation.rmi.PresentationDefaults ;
  81 
  82 import com.sun.corba.se.spi.servicecontext.ServiceContextRegistry ;
  83 
  84 // XXX needs an SPI or else it does not belong here
  85 import com.sun.corba.se.impl.corba.TypeCodeImpl ;
  86 import com.sun.corba.se.impl.corba.TypeCodeFactory ;
  87 
  88 // XXX Should there be a SPI level constants ?
  89 import com.sun.corba.se.impl.orbutil.ORBConstants ;
  90 
  91 import com.sun.corba.se.impl.oa.poa.BadServerIdHandler ;
  92 
  93 import com.sun.corba.se.impl.transport.ByteBufferPoolImpl;
  94 
  95 import com.sun.corba.se.impl.logging.ORBUtilSystemException ;
  96 import com.sun.corba.se.impl.logging.OMGSystemException ;
  97 
  98 import com.sun.corba.se.impl.presentation.rmi.PresentationManagerImpl ;
  99 


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


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










 247             if (appletContext != null) {
 248                 synchronized (pmContexts) {
 249                     return pmContexts.putIfAbsent(appletContext, setupPresentationManager());



 250                 }

 251             }

 252         }
 253 
 254         // No security manager or AppletAppContext
 255         return Holder.defaultPresentationManager;
 256     }
 257 
 258     /** Get the appropriate StubFactoryFactory.  This
 259      * will be dynamic or static depending on whether
 260      * com.sun.CORBA.ORBUseDynamicStub is true or false.
 261      */
 262     public static PresentationManager.StubFactoryFactory
 263         getStubFactoryFactory()
 264     {
 265         PresentationManager gPM = getPresentationManager();
 266         boolean useDynamicStubs = gPM.useDynamicStubs() ;
 267         return gPM.getStubFactoryFactory( useDynamicStubs ) ;
 268     }
 269 
 270     protected ORB()
 271     {