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

Print this page


   1 /*
   2  * Copyright (c) 2002, 2004, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   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


 154     // Local testing
 155     // XXX clean this up, probably remove these
 156     public abstract boolean isLocalHost( String hostName ) ;
 157     public abstract boolean isLocalServerId( int subcontractId, int serverId ) ;
 158 
 159     // Invocation stack manipulation
 160     public abstract OAInvocationInfo peekInvocationInfo() ;
 161     public abstract void pushInvocationInfo( OAInvocationInfo info ) ;
 162     public abstract OAInvocationInfo popInvocationInfo() ;
 163 
 164     public abstract CorbaTransportManager getCorbaTransportManager();
 165     public abstract LegacyServerSocketManager getLegacyServerSocketManager();
 166 
 167     // wrapperMap maintains a table of LogWrapper instances used by
 168     // different classes to log exceptions.  The key is a StringPair
 169     // representing LogDomain and ExceptionGroup.
 170     private Map wrapperMap ;
 171 
 172     private static Map staticWrapperMap = new ConcurrentHashMap();
 173 
 174     private MonitoringManager monitoringManager;
 175 
 176     // There is only one instance of the PresentationManager
 177     // that is shared between all ORBs.  This is necessary
 178     // because RMI-IIOP requires the PresentationManager in
 179     // places where no ORB is available, so the PresentationManager
 180     // must be global.  It is initialized here as well.
 181     protected static PresentationManager globalPM = null ;
 182 
 183     static {
 184         staticWrapper = ORBUtilSystemException.get(
 185             CORBALogDomains.RPC_PRESENTATION ) ;
 186 
 187         boolean useDynamicStub =
 188             ((Boolean)AccessController.doPrivileged(
 189                 new PrivilegedAction() {
 190                     public java.lang.Object run() {
 191                         return Boolean.valueOf( Boolean.getBoolean (
 192                             ORBConstants.USE_DYNAMIC_STUB_PROPERTY ) ) ;
 193                     }
 194                 }


 209                             // First try the configured class name, if any
 210                             Class cls = ORBClassLoader.loadClass( className ) ;
 211                             sff = (PresentationManager.StubFactoryFactory)cls.newInstance() ;
 212                         } catch (Exception exc) {
 213                             // Use the default. Log the error as a warning.
 214                             staticWrapper.errorInSettingDynamicStubFactoryFactory(
 215                                 exc, className ) ;
 216                         }
 217 
 218                         return sff ;
 219                     }
 220                 }
 221             ) ;
 222 
 223         globalPM = new PresentationManagerImpl( useDynamicStub ) ;
 224         globalPM.setStubFactoryFactory( false,
 225             PresentationDefaults.getStaticStubFactoryFactory() ) ;
 226         globalPM.setStubFactoryFactory( true, dynamicStubFactoryFactory ) ;
 227     }
 228 








 229     /** Get the single instance of the PresentationManager
 230      */
 231     public static PresentationManager getPresentationManager()
 232     {
 233         return globalPM ;
 234     }
 235 
 236     /** Get the appropriate StubFactoryFactory.  This
 237      * will be dynamic or static depending on whether
 238      * com.sun.CORBA.ORBUseDynamicStub is true or false.
 239      */
 240     public static PresentationManager.StubFactoryFactory
 241         getStubFactoryFactory()
 242     {
 243         boolean useDynamicStubs = globalPM.useDynamicStubs() ;
 244         return globalPM.getStubFactoryFactory( useDynamicStubs ) ;
 245     }
 246 
 247     protected ORB()
 248     {


 285             new TypeCodeImpl(this, TCKind._tk_longdouble),
 286             new TypeCodeImpl(this, TCKind._tk_wchar),
 287             new TypeCodeImpl(this, TCKind._tk_wstring),
 288             new TypeCodeImpl(this, TCKind._tk_fixed),
 289             new TypeCodeImpl(this, TCKind._tk_value),
 290             new TypeCodeImpl(this, TCKind._tk_value_box),
 291             new TypeCodeImpl(this, TCKind._tk_native),
 292             new TypeCodeImpl(this, TCKind._tk_abstract_interface)
 293         } ;
 294 
 295         monitoringManager =
 296             MonitoringFactories.getMonitoringManagerFactory( ).
 297                 createMonitoringManager(
 298                 MonitoringConstants.DEFAULT_MONITORING_ROOT,
 299                 MonitoringConstants.DEFAULT_MONITORING_ROOT_DESCRIPTION);
 300     }
 301 
 302     // Typecode support: needed in both ORBImpl and ORBSingleton
 303     public TypeCodeImpl get_primitive_tc(int kind)
 304     {



 305         try {
 306             return primitiveTypeCodeConstants[kind] ;
 307         } catch (Throwable t) {
 308             throw wrapper.invalidTypecodeKind( t, new Integer(kind) ) ;
 309         }
 310     }
 311 
 312     public synchronized void setTypeCode(String id, TypeCodeImpl code)
 313     {

 314         typeCodeMap.put(id, code);
 315     }
 316 
 317     public synchronized TypeCodeImpl getTypeCode(String id)
 318     {

 319         return (TypeCodeImpl)typeCodeMap.get(id);
 320     }
 321 
 322     public MonitoringManager getMonitoringManager( ) {



 323         return monitoringManager;
 324     }
 325 
 326     // Special non-standard set_parameters method for
 327     // creating a precisely controlled ORB instance.
 328     // An ORB created by this call is affected only by
 329     // those properties passes explicitly in props, not by
 330     // the system properties and orb.properties files as
 331     // with the standard ORB.init methods.
 332     public abstract void set_parameters( Properties props ) ;
 333 
 334     // ORB versioning
 335     public abstract ORBVersion getORBVersion() ;
 336     public abstract void setORBVersion( ORBVersion version ) ;
 337 
 338     // XXX This needs a better name
 339     public abstract IOR getFVDCodeBaseIOR() ;
 340 
 341     /**
 342      * Handle a bad server id for the given object key.  This should


 417 
 418     // XXX The next 5 operations should be moved to an IORManager.
 419 
 420     /** Factory finders for the various parts of the IOR: tagged components, tagged
 421      * profiles, and tagged profile templates.
 422      */
 423     public abstract TaggedComponentFactoryFinder getTaggedComponentFactoryFinder() ;
 424     public abstract IdentifiableFactoryFinder getTaggedProfileFactoryFinder() ;
 425     public abstract IdentifiableFactoryFinder getTaggedProfileTemplateFactoryFinder() ;
 426 
 427     public abstract ObjectKeyFactory getObjectKeyFactory() ;
 428     public abstract void setObjectKeyFactory( ObjectKeyFactory factory ) ;
 429 
 430     // Logging SPI
 431 
 432     /**
 433      * Returns the logger based on the category.
 434      */
 435     public Logger getLogger( String domain )
 436     {



 437         ORBData odata = getORBData() ;
 438 
 439         // Determine the correct ORBId.  There are 3 cases:
 440         // 1. odata is null, which happens if we are getting a logger before
 441         //    ORB initialization is complete.  In this case we cannot determine
 442         //    the ORB ID (it's not known yet), so we set the ORBId to
 443         //    _INITIALIZING_.
 444         // 2. odata is not null, so initialization is complete, but ORBId is set to
 445         //    the default "".  To avoid a ".." in
 446         //    the log domain, we simply use _DEFAULT_ in this case.
 447         // 3. odata is not null, ORBId is not "": just use the ORBId.
 448         String ORBId ;
 449         if (odata == null)
 450             ORBId = "_INITIALIZING_" ;
 451         else {
 452             ORBId = odata.getORBId() ;
 453             if (ORBId.equals(""))
 454                 ORBId = "_DEFAULT_" ;
 455         }
 456 


 493     public static LogWrapperBase staticGetLogWrapper( String logDomain,
 494         String exceptionGroup, LogWrapperFactory factory )
 495     {
 496         StringPair key = new StringPair( logDomain, exceptionGroup ) ;
 497 
 498         LogWrapperBase logWrapper = (LogWrapperBase)staticWrapperMap.get( key );
 499         if (logWrapper == null) {
 500             logWrapper = factory.create( staticGetLogger( logDomain ) );
 501             staticWrapperMap.put( key, logWrapper );
 502         }
 503 
 504         return logWrapper;
 505     }
 506 
 507     // get a reference to a ByteBufferPool, a pool of NIO ByteBuffers
 508     // NOTE: ByteBuffer pool must be unique per ORB, not per process.
 509     //       There can be more than one ORB per process.
 510     //       This method must also be inherited by both ORB and ORBSingleton.
 511     public ByteBufferPool getByteBufferPool()
 512     {



 513         if (byteBufferPool == null)
 514             byteBufferPool = new ByteBufferPoolImpl(this);
 515 
 516         return byteBufferPool;
 517     }
 518 
 519     public abstract void setThreadPoolManager(ThreadPoolManager mgr);
 520 
 521     public abstract ThreadPoolManager getThreadPoolManager();
 522 
 523     public abstract CopierManager getCopierManager() ;
 524 }
 525 
 526 // End of file.
   1 /*
   2  * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   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


 154     // Local testing
 155     // XXX clean this up, probably remove these
 156     public abstract boolean isLocalHost( String hostName ) ;
 157     public abstract boolean isLocalServerId( int subcontractId, int serverId ) ;
 158 
 159     // Invocation stack manipulation
 160     public abstract OAInvocationInfo peekInvocationInfo() ;
 161     public abstract void pushInvocationInfo( OAInvocationInfo info ) ;
 162     public abstract OAInvocationInfo popInvocationInfo() ;
 163 
 164     public abstract CorbaTransportManager getCorbaTransportManager();
 165     public abstract LegacyServerSocketManager getLegacyServerSocketManager();
 166 
 167     // wrapperMap maintains a table of LogWrapper instances used by
 168     // different classes to log exceptions.  The key is a StringPair
 169     // representing LogDomain and ExceptionGroup.
 170     private Map wrapperMap ;
 171 
 172     private static Map staticWrapperMap = new ConcurrentHashMap();
 173 
 174     protected MonitoringManager monitoringManager;
 175 
 176     // There is only one instance of the PresentationManager
 177     // that is shared between all ORBs.  This is necessary
 178     // because RMI-IIOP requires the PresentationManager in
 179     // places where no ORB is available, so the PresentationManager
 180     // must be global.  It is initialized here as well.
 181     protected static PresentationManager globalPM = null ;
 182 
 183     static {
 184         staticWrapper = ORBUtilSystemException.get(
 185             CORBALogDomains.RPC_PRESENTATION ) ;
 186 
 187         boolean useDynamicStub =
 188             ((Boolean)AccessController.doPrivileged(
 189                 new PrivilegedAction() {
 190                     public java.lang.Object run() {
 191                         return Boolean.valueOf( Boolean.getBoolean (
 192                             ORBConstants.USE_DYNAMIC_STUB_PROPERTY ) ) ;
 193                     }
 194                 }


 209                             // First try the configured class name, if any
 210                             Class cls = ORBClassLoader.loadClass( className ) ;
 211                             sff = (PresentationManager.StubFactoryFactory)cls.newInstance() ;
 212                         } catch (Exception exc) {
 213                             // Use the default. Log the error as a warning.
 214                             staticWrapper.errorInSettingDynamicStubFactoryFactory(
 215                                 exc, className ) ;
 216                         }
 217 
 218                         return sff ;
 219                     }
 220                 }
 221             ) ;
 222 
 223         globalPM = new PresentationManagerImpl( useDynamicStub ) ;
 224         globalPM.setStubFactoryFactory( false,
 225             PresentationDefaults.getStaticStubFactoryFactory() ) ;
 226         globalPM.setStubFactoryFactory( true, dynamicStubFactoryFactory ) ;
 227     }
 228 
 229     public void destroy() {
 230         wrapper = null;
 231         omgWrapper = null;
 232         typeCodeMap = null;
 233         primitiveTypeCodeConstants = null;
 234         byteBufferPool = null;
 235     }
 236 
 237     /** Get the single instance of the PresentationManager
 238      */
 239     public static PresentationManager getPresentationManager()
 240     {
 241         return globalPM ;
 242     }
 243 
 244     /** Get the appropriate StubFactoryFactory.  This
 245      * will be dynamic or static depending on whether
 246      * com.sun.CORBA.ORBUseDynamicStub is true or false.
 247      */
 248     public static PresentationManager.StubFactoryFactory
 249         getStubFactoryFactory()
 250     {
 251         boolean useDynamicStubs = globalPM.useDynamicStubs() ;
 252         return globalPM.getStubFactoryFactory( useDynamicStubs ) ;
 253     }
 254 
 255     protected ORB()
 256     {


 293             new TypeCodeImpl(this, TCKind._tk_longdouble),
 294             new TypeCodeImpl(this, TCKind._tk_wchar),
 295             new TypeCodeImpl(this, TCKind._tk_wstring),
 296             new TypeCodeImpl(this, TCKind._tk_fixed),
 297             new TypeCodeImpl(this, TCKind._tk_value),
 298             new TypeCodeImpl(this, TCKind._tk_value_box),
 299             new TypeCodeImpl(this, TCKind._tk_native),
 300             new TypeCodeImpl(this, TCKind._tk_abstract_interface)
 301         } ;
 302 
 303         monitoringManager =
 304             MonitoringFactories.getMonitoringManagerFactory( ).
 305                 createMonitoringManager(
 306                 MonitoringConstants.DEFAULT_MONITORING_ROOT,
 307                 MonitoringConstants.DEFAULT_MONITORING_ROOT_DESCRIPTION);
 308     }
 309 
 310     // Typecode support: needed in both ORBImpl and ORBSingleton
 311     public TypeCodeImpl get_primitive_tc(int kind)
 312     {
 313         synchronized (this) {
 314             checkShutdownState();
 315         }
 316         try {
 317             return primitiveTypeCodeConstants[kind] ;
 318         } catch (Throwable t) {
 319             throw wrapper.invalidTypecodeKind( t, new Integer(kind) ) ;
 320         }
 321     }
 322 
 323     public synchronized void setTypeCode(String id, TypeCodeImpl code)
 324     {
 325         checkShutdownState();
 326         typeCodeMap.put(id, code);
 327     }
 328 
 329     public synchronized TypeCodeImpl getTypeCode(String id)
 330     {
 331         checkShutdownState();
 332         return (TypeCodeImpl)typeCodeMap.get(id);
 333     }
 334 
 335     public MonitoringManager getMonitoringManager( ) {
 336         synchronized (this) {
 337             checkShutdownState();
 338         }
 339         return monitoringManager;
 340     }
 341 
 342     // Special non-standard set_parameters method for
 343     // creating a precisely controlled ORB instance.
 344     // An ORB created by this call is affected only by
 345     // those properties passes explicitly in props, not by
 346     // the system properties and orb.properties files as
 347     // with the standard ORB.init methods.
 348     public abstract void set_parameters( Properties props ) ;
 349 
 350     // ORB versioning
 351     public abstract ORBVersion getORBVersion() ;
 352     public abstract void setORBVersion( ORBVersion version ) ;
 353 
 354     // XXX This needs a better name
 355     public abstract IOR getFVDCodeBaseIOR() ;
 356 
 357     /**
 358      * Handle a bad server id for the given object key.  This should


 433 
 434     // XXX The next 5 operations should be moved to an IORManager.
 435 
 436     /** Factory finders for the various parts of the IOR: tagged components, tagged
 437      * profiles, and tagged profile templates.
 438      */
 439     public abstract TaggedComponentFactoryFinder getTaggedComponentFactoryFinder() ;
 440     public abstract IdentifiableFactoryFinder getTaggedProfileFactoryFinder() ;
 441     public abstract IdentifiableFactoryFinder getTaggedProfileTemplateFactoryFinder() ;
 442 
 443     public abstract ObjectKeyFactory getObjectKeyFactory() ;
 444     public abstract void setObjectKeyFactory( ObjectKeyFactory factory ) ;
 445 
 446     // Logging SPI
 447 
 448     /**
 449      * Returns the logger based on the category.
 450      */
 451     public Logger getLogger( String domain )
 452     {
 453         synchronized (this) {
 454             checkShutdownState();
 455         }
 456         ORBData odata = getORBData() ;
 457 
 458         // Determine the correct ORBId.  There are 3 cases:
 459         // 1. odata is null, which happens if we are getting a logger before
 460         //    ORB initialization is complete.  In this case we cannot determine
 461         //    the ORB ID (it's not known yet), so we set the ORBId to
 462         //    _INITIALIZING_.
 463         // 2. odata is not null, so initialization is complete, but ORBId is set to
 464         //    the default "".  To avoid a ".." in
 465         //    the log domain, we simply use _DEFAULT_ in this case.
 466         // 3. odata is not null, ORBId is not "": just use the ORBId.
 467         String ORBId ;
 468         if (odata == null)
 469             ORBId = "_INITIALIZING_" ;
 470         else {
 471             ORBId = odata.getORBId() ;
 472             if (ORBId.equals(""))
 473                 ORBId = "_DEFAULT_" ;
 474         }
 475 


 512     public static LogWrapperBase staticGetLogWrapper( String logDomain,
 513         String exceptionGroup, LogWrapperFactory factory )
 514     {
 515         StringPair key = new StringPair( logDomain, exceptionGroup ) ;
 516 
 517         LogWrapperBase logWrapper = (LogWrapperBase)staticWrapperMap.get( key );
 518         if (logWrapper == null) {
 519             logWrapper = factory.create( staticGetLogger( logDomain ) );
 520             staticWrapperMap.put( key, logWrapper );
 521         }
 522 
 523         return logWrapper;
 524     }
 525 
 526     // get a reference to a ByteBufferPool, a pool of NIO ByteBuffers
 527     // NOTE: ByteBuffer pool must be unique per ORB, not per process.
 528     //       There can be more than one ORB per process.
 529     //       This method must also be inherited by both ORB and ORBSingleton.
 530     public ByteBufferPool getByteBufferPool()
 531     {
 532         synchronized (this) {
 533             checkShutdownState();
 534         }
 535         if (byteBufferPool == null)
 536             byteBufferPool = new ByteBufferPoolImpl(this);
 537 
 538         return byteBufferPool;
 539     }
 540 
 541     public abstract void setThreadPoolManager(ThreadPoolManager mgr);
 542 
 543     public abstract ThreadPoolManager getThreadPoolManager();
 544 
 545     public abstract CopierManager getCopierManager() ;
 546 }
 547 
 548 // End of file.