corba/src/share/classes/com/sun/corba/se/impl/orb/ORBImpl.java
changeset 13171 1ac5e9a54a6e
parent 7586 2c65d50ed930
child 16136 f5a39cbcd82f
equal deleted inserted replaced
13082:9b19b2302c28 13171:1ac5e9a54a6e
     1 /*
     1 /*
     2  * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
     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.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    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
    22  * or visit www.oracle.com if you need additional information or have any
    23  * questions.
    23  * questions.
    24  */
    24  */
    25 
    25 
    26 package com.sun.corba.se.impl.orb ;
    26 package com.sun.corba.se.impl.orb;
    27 
    27 
    28 import java.applet.Applet;
    28 import java.applet.Applet;
    29 
    29 
    30 import java.io.IOException ;
    30 import java.io.IOException;
    31 
    31 
    32 import java.lang.reflect.Constructor;
    32 import java.lang.reflect.Constructor;
    33 import java.lang.reflect.Field ;
    33 import java.lang.reflect.Field;
    34 import java.lang.reflect.Modifier ;
    34 import java.lang.reflect.Modifier;
    35 import java.lang.reflect.InvocationTargetException ;
    35 import java.lang.reflect.InvocationTargetException;
    36 
    36 
    37 import java.util.ArrayList ;
    37 import java.util.Set;
    38 import java.util.Iterator ;
    38 import java.util.HashSet;
    39 import java.util.Properties ;
    39 import java.util.ArrayList;
    40 import java.util.Vector ;
    40 import java.util.Iterator;
    41 import java.util.Hashtable ;
    41 import java.util.Properties;
    42 import java.util.Map ;
    42 import java.util.Vector;
    43 import java.util.HashMap ;
    43 import java.util.Hashtable;
    44 import java.util.LinkedList ;
    44 import java.util.Map;
    45 import java.util.Collection ;
    45 import java.util.HashMap;
    46 import java.util.Collections ;
    46 import java.util.LinkedList;
    47 import java.util.StringTokenizer ;
    47 import java.util.Collection;
    48 import java.util.Enumeration ;
    48 import java.util.Collections;
    49 import java.util.WeakHashMap ;
    49 import java.util.StringTokenizer;
    50 
    50 import java.util.Enumeration;
    51 import java.net.InetAddress ;
    51 import java.util.WeakHashMap;
       
    52 
       
    53 import java.net.InetAddress;
    52 
    54 
    53 import java.security.PrivilegedAction;
    55 import java.security.PrivilegedAction;
    54 import java.security.AccessController ;
    56 import java.security.AccessController;
    55 
    57 
    56 import javax.rmi.CORBA.Util;
    58 import javax.rmi.CORBA.Util;
    57 import javax.rmi.CORBA.ValueHandler;
    59 import javax.rmi.CORBA.ValueHandler;
    58 
    60 
    59 import org.omg.CORBA.Context;
    61 import org.omg.CORBA.Context;
    80 import org.omg.CORBA.ORBPackage.InvalidName;
    82 import org.omg.CORBA.ORBPackage.InvalidName;
    81 
    83 
    82 import com.sun.org.omg.SendingContext.CodeBase;
    84 import com.sun.org.omg.SendingContext.CodeBase;
    83 
    85 
    84 import com.sun.corba.se.pept.broker.Broker;
    86 import com.sun.corba.se.pept.broker.Broker;
    85 import com.sun.corba.se.pept.protocol.ClientInvocationInfo ;
    87 import com.sun.corba.se.pept.protocol.ClientInvocationInfo;
    86 import com.sun.corba.se.pept.transport.ContactInfo;
    88 import com.sun.corba.se.pept.transport.ContactInfo;
    87 import com.sun.corba.se.pept.transport.ConnectionCache;
    89 import com.sun.corba.se.pept.transport.ConnectionCache;
    88 import com.sun.corba.se.pept.transport.TransportManager;
    90 import com.sun.corba.se.pept.transport.TransportManager;
    89 
    91 
    90 import com.sun.corba.se.spi.ior.IOR;
    92 import com.sun.corba.se.spi.ior.IOR;
    91 import com.sun.corba.se.spi.ior.IdentifiableFactoryFinder ;
    93 import com.sun.corba.se.spi.ior.IdentifiableFactoryFinder;
    92 import com.sun.corba.se.spi.ior.TaggedComponentFactoryFinder;
    94 import com.sun.corba.se.spi.ior.TaggedComponentFactoryFinder;
    93 import com.sun.corba.se.spi.ior.IORFactories ;
    95 import com.sun.corba.se.spi.ior.IORFactories;
    94 import com.sun.corba.se.spi.ior.ObjectKey ;
    96 import com.sun.corba.se.spi.ior.ObjectKey;
    95 import com.sun.corba.se.spi.ior.ObjectKeyFactory ;
    97 import com.sun.corba.se.spi.ior.ObjectKeyFactory;
    96 import com.sun.corba.se.spi.ior.iiop.IIOPFactories ;
    98 import com.sun.corba.se.spi.ior.iiop.IIOPFactories;
    97 import com.sun.corba.se.spi.ior.iiop.GIOPVersion;
    99 import com.sun.corba.se.spi.ior.iiop.GIOPVersion;
    98 import com.sun.corba.se.spi.oa.OAInvocationInfo;
   100 import com.sun.corba.se.spi.oa.OAInvocationInfo;
    99 import com.sun.corba.se.spi.oa.ObjectAdapterFactory;
   101 import com.sun.corba.se.spi.oa.ObjectAdapterFactory;
   100 import com.sun.corba.se.spi.orb.DataCollector;
   102 import com.sun.corba.se.spi.orb.DataCollector;
   101 import com.sun.corba.se.spi.orb.Operation;
   103 import com.sun.corba.se.spi.orb.Operation;
   120 import com.sun.corba.se.spi.orb.StringPair;
   122 import com.sun.corba.se.spi.orb.StringPair;
   121 import com.sun.corba.se.spi.orb.StringPair;
   123 import com.sun.corba.se.spi.orb.StringPair;
   122 import com.sun.corba.se.spi.transport.CorbaContactInfoListFactory;
   124 import com.sun.corba.se.spi.transport.CorbaContactInfoListFactory;
   123 import com.sun.corba.se.spi.transport.CorbaTransportManager;
   125 import com.sun.corba.se.spi.transport.CorbaTransportManager;
   124 import com.sun.corba.se.spi.legacy.connection.LegacyServerSocketManager;
   126 import com.sun.corba.se.spi.legacy.connection.LegacyServerSocketManager;
   125 import com.sun.corba.se.spi.copyobject.CopierManager ;
   127 import com.sun.corba.se.spi.copyobject.CopierManager;
   126 import com.sun.corba.se.spi.presentation.rmi.PresentationDefaults ;
   128 import com.sun.corba.se.spi.presentation.rmi.PresentationDefaults;
   127 import com.sun.corba.se.spi.presentation.rmi.PresentationManager ;
   129 import com.sun.corba.se.spi.presentation.rmi.PresentationManager;
   128 import com.sun.corba.se.spi.presentation.rmi.StubAdapter ;
   130 import com.sun.corba.se.spi.presentation.rmi.StubAdapter;
   129 import com.sun.corba.se.spi.servicecontext.ServiceContextRegistry;
   131 import com.sun.corba.se.spi.servicecontext.ServiceContextRegistry;
   130 
   132 
   131 import com.sun.corba.se.impl.corba.TypeCodeFactory;
   133 import com.sun.corba.se.impl.corba.TypeCodeFactory;
   132 import com.sun.corba.se.impl.corba.TypeCodeImpl;
   134 import com.sun.corba.se.impl.corba.TypeCodeImpl;
   133 import com.sun.corba.se.impl.corba.NVListImpl;
   135 import com.sun.corba.se.impl.corba.NVListImpl;
   138 import com.sun.corba.se.impl.corba.AsynchInvoke;
   140 import com.sun.corba.se.impl.corba.AsynchInvoke;
   139 import com.sun.corba.se.impl.corba.AnyImpl;
   141 import com.sun.corba.se.impl.corba.AnyImpl;
   140 import com.sun.corba.se.impl.corba.RequestImpl;
   142 import com.sun.corba.se.impl.corba.RequestImpl;
   141 import com.sun.corba.se.impl.dynamicany.DynAnyFactoryImpl;
   143 import com.sun.corba.se.impl.dynamicany.DynAnyFactoryImpl;
   142 import com.sun.corba.se.impl.encoding.EncapsOutputStream;
   144 import com.sun.corba.se.impl.encoding.EncapsOutputStream;
       
   145 import com.sun.corba.se.impl.encoding.CachedCodeBase;
   143 import com.sun.corba.se.impl.interceptors.PIHandlerImpl;
   146 import com.sun.corba.se.impl.interceptors.PIHandlerImpl;
   144 import com.sun.corba.se.impl.interceptors.PINoOpHandlerImpl;
   147 import com.sun.corba.se.impl.interceptors.PINoOpHandlerImpl;
   145 import com.sun.corba.se.impl.ior.TaggedComponentFactoryFinderImpl;
   148 import com.sun.corba.se.impl.ior.TaggedComponentFactoryFinderImpl;
   146 import com.sun.corba.se.impl.ior.TaggedProfileFactoryFinderImpl;
   149 import com.sun.corba.se.impl.ior.TaggedProfileFactoryFinderImpl;
   147 import com.sun.corba.se.impl.ior.TaggedProfileTemplateFactoryFinderImpl;
   150 import com.sun.corba.se.impl.ior.TaggedProfileTemplateFactoryFinderImpl;
   183     private Vector            dynamicRequests ;
   186     private Vector            dynamicRequests ;
   184     private SynchVariable     svResponseReceived ;
   187     private SynchVariable     svResponseReceived ;
   185 
   188 
   186     private java.lang.Object runObj = new java.lang.Object();
   189     private java.lang.Object runObj = new java.lang.Object();
   187     private java.lang.Object shutdownObj = new java.lang.Object();
   190     private java.lang.Object shutdownObj = new java.lang.Object();
       
   191     private java.lang.Object waitForCompletionObj = new java.lang.Object();
   188     private static final byte STATUS_OPERATING = 1;
   192     private static final byte STATUS_OPERATING = 1;
   189     private static final byte STATUS_SHUTTING_DOWN = 2;
   193     private static final byte STATUS_SHUTTING_DOWN = 2;
   190     private static final byte STATUS_SHUTDOWN = 3;
   194     private static final byte STATUS_SHUTDOWN = 3;
   191     private static final byte STATUS_DESTROYED = 4;
   195     private static final byte STATUS_DESTROYED = 4;
   192     private byte status = STATUS_OPERATING;
   196     private byte status = STATUS_OPERATING;
   193 
   197 
   194     // XXX Should we move invocation tracking to the first level server dispatcher?
   198     // XXX Should we move invocation tracking to the first level server dispatcher?
   195     private java.lang.Object invocationObj = new java.lang.Object();
   199     private java.lang.Object invocationObj = new java.lang.Object();
       
   200     private int numInvocations = 0;
   196 
   201 
   197     // thread local variable to store a boolean to detect deadlock in
   202     // thread local variable to store a boolean to detect deadlock in
   198     // ORB.shutdown(true).
   203     // ORB.shutdown(true).
   199     private ThreadLocal isProcessingInvocation = new ThreadLocal () {
   204     private ThreadLocal isProcessingInvocation = new ThreadLocal () {
   200         protected java.lang.Object initialValue() {
   205         protected java.lang.Object initialValue() {
   217     private RequestDispatcherRegistry requestDispatcherRegistry ;
   222     private RequestDispatcherRegistry requestDispatcherRegistry ;
   218 
   223 
   219     private CopierManager copierManager ;
   224     private CopierManager copierManager ;
   220 
   225 
   221     private int transientServerId ;
   226     private int transientServerId ;
   222 
       
   223     private ThreadGroup threadGroup ;
       
   224 
   227 
   225     private ServiceContextRegistry serviceContextRegistry ;
   228     private ServiceContextRegistry serviceContextRegistry ;
   226 
   229 
   227     // Needed here to implement connect/disconnect
   230     // Needed here to implement connect/disconnect
   228     private TOAFactory toaFactory ;
   231     private TOAFactory toaFactory ;
   263     // Converts strings to object references for resolvers and string_to_object
   266     // Converts strings to object references for resolvers and string_to_object
   264     private Operation urlOperation ;
   267     private Operation urlOperation ;
   265     private final Object urlOperationLock = new java.lang.Object() ;
   268     private final Object urlOperationLock = new java.lang.Object() ;
   266 
   269 
   267     private CorbaServerRequestDispatcher insNamingDelegate ;
   270     private CorbaServerRequestDispatcher insNamingDelegate ;
       
   271 
   268     // resolverLock must be used for all access to either resolver or
   272     // resolverLock must be used for all access to either resolver or
   269     // localResolver, since it is possible for the resolver to indirectly
   273     // localResolver, since it is possible for the resolver to indirectly
   270     // refer to the localResolver.  Also used to protect access to
   274     // refer to the localResolver.  Also used to protect access to
   271     // insNamingDelegate.
   275     // insNamingDelegate.
   272     private final Object resolverLock = new Object() ;
   276     private final Object resolverLock = new Object() ;
   276     private IdentifiableFactoryFinder taggedProfileFactoryFinder ;
   280     private IdentifiableFactoryFinder taggedProfileFactoryFinder ;
   277 
   281 
   278     private IdentifiableFactoryFinder taggedProfileTemplateFactoryFinder ;
   282     private IdentifiableFactoryFinder taggedProfileTemplateFactoryFinder ;
   279 
   283 
   280     private ObjectKeyFactory objectKeyFactory ;
   284     private ObjectKeyFactory objectKeyFactory ;
       
   285 
       
   286     private boolean orbOwnsThreadPoolManager = false ;
   281 
   287 
   282     private ThreadPoolManager threadpoolMgr;
   288     private ThreadPoolManager threadpoolMgr;
   283 
   289 
   284     private void dprint( String msg )
   290     private void dprint( String msg )
   285     {
   291     {
   320         // All initialization is done through set_parameters().
   326         // All initialization is done through set_parameters().
   321     }
   327     }
   322 
   328 
   323     public ORBVersion getORBVersion()
   329     public ORBVersion getORBVersion()
   324     {
   330     {
       
   331         synchronized (this) {
       
   332                 checkShutdownState();
       
   333         }
   325         return (ORBVersion)(orbVersionThreadLocal.get()) ;
   334         return (ORBVersion)(orbVersionThreadLocal.get()) ;
   326     }
   335     }
   327 
   336 
   328     public void setORBVersion(ORBVersion verObj)
   337     public void setORBVersion(ORBVersion verObj)
   329     {
   338     {
       
   339         synchronized (this) {
       
   340                 checkShutdownState();
       
   341         }
   330         orbVersionThreadLocal.set(verObj);
   342         orbVersionThreadLocal.set(verObj);
   331     }
   343     }
   332 
   344 
   333 /****************************************************************************
   345 /****************************************************************************
   334  * The following methods are ORB initialization
   346  * The following methods are ORB initialization
   344         // check on piHandler to invoke Interceptors. We do not want any
   356         // check on piHandler to invoke Interceptors. We do not want any
   345         // Interceptors to be invoked before the complete ORB initialization.
   357         // Interceptors to be invoked before the complete ORB initialization.
   346         // piHandler will be replaced by a real PIHandler implementation at the
   358         // piHandler will be replaced by a real PIHandler implementation at the
   347         // end of this method.
   359         // end of this method.
   348         pihandler = new PINoOpHandlerImpl( );
   360         pihandler = new PINoOpHandlerImpl( );
   349 
       
   350         // See bugs 4916766 and 4936203
       
   351         // We intend to create new threads in a reliable thread group.
       
   352         // This avoids problems if the application/applet
       
   353         // creates a thread group, makes JavaIDL calls which create a new
       
   354         // connection and ReaderThread, and then destroys the thread
       
   355         // group. If our ReaderThreads were to be part of such destroyed thread
       
   356         // group then it might get killed and cause other invoking threads
       
   357         // sharing the same connection to get a non-restartable
       
   358         // CommunicationFailure. We'd like to avoid that.
       
   359         //
       
   360         // Our solution is to create all of our threads in the highest thread
       
   361         // group that we have access to, given our own security clearance.
       
   362         //
       
   363         try {
       
   364             // try to get a thread group that's as high in the threadgroup
       
   365             // parent-child hierarchy, as we can get to.
       
   366             // this will prevent an ORB thread created during applet-init from
       
   367             // being killed when an applet dies.
       
   368             threadGroup = (ThreadGroup) AccessController.doPrivileged(
       
   369                 new PrivilegedAction() {
       
   370                     public Object run() {
       
   371                         ThreadGroup tg = Thread.currentThread().getThreadGroup() ;
       
   372                         ThreadGroup ptg = tg ;
       
   373                         try {
       
   374                             while (ptg != null) {
       
   375                                 tg = ptg;
       
   376                                 ptg = tg.getParent();
       
   377                             }
       
   378                         } catch (SecurityException se) {
       
   379                             // Discontinue going higher on a security exception.
       
   380                         }
       
   381                         return new ThreadGroup(tg, "ORB ThreadGroup");
       
   382                     }
       
   383                 }
       
   384             );
       
   385         } catch (SecurityException e) {
       
   386             // something wrong, we go back to the original code
       
   387             threadGroup = Thread.currentThread().getThreadGroup();
       
   388         }
       
   389 
   361 
   390         // This is the unique id of this server (JVM). Multiple incarnations
   362         // This is the unique id of this server (JVM). Multiple incarnations
   391         // of this server will get different ids.
   363         // of this server will get different ids.
   392         // Compute transientServerId = milliseconds since Jan 1, 1970
   364         // Compute transientServerId = milliseconds since Jan 1, 1970
   393         // Note: transientServerId will wrap in about 2^32 / 86400000 = 49.7 days.
   365         // Note: transientServerId will wrap in about 2^32 / 86400000 = 49.7 days.
   545         return toaFactory ;
   517         return toaFactory ;
   546     }
   518     }
   547 
   519 
   548     public void set_parameters( Properties props )
   520     public void set_parameters( Properties props )
   549     {
   521     {
       
   522         synchronized (this) {
       
   523                 checkShutdownState();
       
   524         }
   550         preInit( null, props ) ;
   525         preInit( null, props ) ;
   551         DataCollector dataCollector =
   526         DataCollector dataCollector =
   552             DataCollectorFactory.create( props, getLocalHostName() ) ;
   527             DataCollectorFactory.create( props, getLocalHostName() ) ;
   553         postInit( null, dataCollector ) ;
   528         postInit( null, dataCollector ) ;
   554     }
   529     }
   786     /**
   761     /**
   787      * Notify response to ORB for get_next_response
   762      * Notify response to ORB for get_next_response
   788      */
   763      */
   789     public void notifyORB()
   764     public void notifyORB()
   790     {
   765     {
       
   766         synchronized (this) {
       
   767                 checkShutdownState();
       
   768         }
   791         synchronized (this.svResponseReceived) {
   769         synchronized (this.svResponseReceived) {
   792             this.svResponseReceived.set();
   770             this.svResponseReceived.set();
   793             this.svResponseReceived.notify();
   771             this.svResponseReceived.notify();
   794         }
   772         }
   795     }
   773     }
   852 
   830 
   853     // pure java orb support, moved this method from FVDCodeBaseImpl.
   831     // pure java orb support, moved this method from FVDCodeBaseImpl.
   854     // Note that we connect this if we have not already done so.
   832     // Note that we connect this if we have not already done so.
   855     public synchronized IOR getFVDCodeBaseIOR()
   833     public synchronized IOR getFVDCodeBaseIOR()
   856     {
   834     {
       
   835         checkShutdownState();
       
   836 
   857         if (codeBaseIOR != null) // i.e. We are already connected to it
   837         if (codeBaseIOR != null) // i.e. We are already connected to it
   858             return codeBaseIOR;
   838             return codeBaseIOR;
   859 
   839 
   860         // backward compatability 4365188
   840         // backward compatability 4365188
   861         CodeBase cb;
   841         CodeBase cb;
  1116     // Keeping a cache of TypeCodes associated with the class
  1096     // Keeping a cache of TypeCodes associated with the class
  1117     // they got created from in Util.writeAny().
  1097     // they got created from in Util.writeAny().
  1118 
  1098 
  1119     public synchronized void setTypeCodeForClass(Class c, TypeCodeImpl tci)
  1099     public synchronized void setTypeCodeForClass(Class c, TypeCodeImpl tci)
  1120     {
  1100     {
       
  1101         checkShutdownState();
       
  1102 
  1121         if (typeCodeForClassMap == null)
  1103         if (typeCodeForClassMap == null)
  1122             typeCodeForClassMap = Collections.synchronizedMap(
  1104             typeCodeForClassMap = Collections.synchronizedMap(
  1123                 new WeakHashMap(64));
  1105                 new WeakHashMap(64));
  1124         // Store only one TypeCode per class.
  1106         // Store only one TypeCode per class.
  1125         if ( ! typeCodeForClassMap.containsKey(c))
  1107         if ( ! typeCodeForClassMap.containsKey(c))
  1126             typeCodeForClassMap.put(c, tci);
  1108             typeCodeForClassMap.put(c, tci);
  1127     }
  1109     }
  1128 
  1110 
  1129     public synchronized TypeCodeImpl getTypeCodeForClass(Class c)
  1111     public synchronized TypeCodeImpl getTypeCodeForClass(Class c)
  1130     {
  1112     {
       
  1113         checkShutdownState();
       
  1114 
  1131         if (typeCodeForClassMap == null)
  1115         if (typeCodeForClassMap == null)
  1132             return null;
  1116             return null;
  1133         return (TypeCodeImpl)typeCodeForClassMap.get(c);
  1117         return (TypeCodeImpl)typeCodeForClassMap.get(c);
  1134     }
  1118     }
  1135 
  1119 
  1208     public void register_initial_reference(
  1192     public void register_initial_reference(
  1209         String id, org.omg.CORBA.Object obj ) throws InvalidName
  1193         String id, org.omg.CORBA.Object obj ) throws InvalidName
  1210     {
  1194     {
  1211         CorbaServerRequestDispatcher insnd ;
  1195         CorbaServerRequestDispatcher insnd ;
  1212 
  1196 
       
  1197         synchronized (this) {
       
  1198             checkShutdownState();
       
  1199         }
       
  1200 
  1213         if ((id == null) || (id.length() == 0))
  1201         if ((id == null) || (id.length() == 0))
  1214             throw new InvalidName() ;
  1202             throw new InvalidName() ;
  1215 
  1203 
  1216         synchronized (this) {
  1204         synchronized (this) {
  1217             checkShutdownState();
  1205             checkShutdownState();
  1251                 runObj.wait();
  1239                 runObj.wait();
  1252             } catch ( InterruptedException ex ) {}
  1240             } catch ( InterruptedException ex ) {}
  1253         }
  1241         }
  1254     }
  1242     }
  1255 
  1243 
  1256     public void shutdown(boolean wait_for_completion)
  1244     public void shutdown(boolean wait_for_completion) {
  1257     {
  1245         boolean wait = false;
  1258         // to wait for completion, we would deadlock, so throw a standard
  1246 
  1259         // OMG exception.
  1247         synchronized (this) {
  1260         if (wait_for_completion && ((Boolean)isProcessingInvocation.get()).booleanValue()) {
  1248             checkShutdownState();
  1261             throw omgWrapper.shutdownWaitForCompletionDeadlock() ;
  1249 
  1262         }
  1250             // This is to avoid deadlock: don't allow a thread that is
  1263 
  1251             // processing a request to call shutdown( true ), because
  1264         boolean doShutdown = false ;
  1252             // the shutdown would block waiting for the request to complete,
  1265 
  1253             // while the request would block waiting for shutdown to complete.
  1266         synchronized (this) {
  1254             if (wait_for_completion &&
  1267             checkShutdownState() ;
  1255                 isProcessingInvocation.get() == Boolean.TRUE) {
       
  1256                 throw omgWrapper.shutdownWaitForCompletionDeadlock();
       
  1257             }
  1268 
  1258 
  1269             if (status == STATUS_SHUTTING_DOWN) {
  1259             if (status == STATUS_SHUTTING_DOWN) {
  1270                 if (!wait_for_completion)
  1260                 if (wait_for_completion) {
  1271                 // If we are already shutting down and don't want
  1261                     wait = true;
  1272                 // to wait, nothing to do: return.
  1262                 } else {
  1273                 return ;
  1263                     return;
       
  1264                 }
       
  1265             }
       
  1266 
       
  1267             status = STATUS_SHUTTING_DOWN;
       
  1268         }
       
  1269 
       
  1270         // Avoid more than one thread performing shutdown at a time.
       
  1271         synchronized (shutdownObj) {
       
  1272             // At this point, the ORB status is certainly STATUS_SHUTTING_DOWN.
       
  1273             // If wait is true, another thread already called shutdown( true ),
       
  1274             // and so we wait for completion
       
  1275             if (wait) {
       
  1276                 while (true) {
       
  1277                     synchronized (this) {
       
  1278                         if (status == STATUS_SHUTDOWN)
       
  1279                             break;
       
  1280                     }
       
  1281 
       
  1282                     try {
       
  1283                         shutdownObj.wait();
       
  1284                     } catch (InterruptedException exc) {
       
  1285                         // NOP: just loop and wait until state is changed
       
  1286                     }
       
  1287                 }
  1274             } else {
  1288             } else {
  1275                 // The ORB status was STATUS_OPERATING, so start the shutdown.
  1289                 // perform the actual shutdown
  1276                 status = STATUS_SHUTTING_DOWN ;
       
  1277                 doShutdown = true ;
       
  1278             }
       
  1279         }
       
  1280 
       
  1281         // At this point, status is SHUTTING_DOWN.
       
  1282         // All shutdown calls with wait_for_completion == true must synchronize
       
  1283         // here.  Only the first call will be made with doShutdown == true.
       
  1284         synchronized (shutdownObj) {
       
  1285             if (doShutdown) {
       
  1286                 // shutdownServants will set all POAManagers into the
       
  1287                 // INACTIVE state, causing request to be rejected.
       
  1288                 // If wait_for_completion is true, this will not return until
       
  1289                 // all invocations have completed.
       
  1290                 shutdownServants(wait_for_completion);
  1290                 shutdownServants(wait_for_completion);
       
  1291 
       
  1292                 if (wait_for_completion) {
       
  1293                     synchronized ( waitForCompletionObj ) {
       
  1294                         while (numInvocations > 0) {
       
  1295                             try {
       
  1296                                 waitForCompletionObj.wait();
       
  1297                             } catch (InterruptedException ex) {}
       
  1298                         }
       
  1299                     }
       
  1300                 }
  1291 
  1301 
  1292                 synchronized (runObj) {
  1302                 synchronized (runObj) {
  1293                     runObj.notifyAll();
  1303                     runObj.notifyAll();
  1294                 }
  1304                 }
  1295 
  1305 
  1296                 synchronized (this) {
  1306                 status = STATUS_SHUTDOWN;
  1297                     status = STATUS_SHUTDOWN;
  1307 
  1298                 }
  1308                 shutdownObj.notifyAll();
  1299             }
  1309             }
  1300         }
  1310         }
  1301     }
  1311     }
  1302 
  1312 
  1303     /** This method shuts down the ORB and causes orb.run() to return.
  1313     // Cause all ObjectAdapaterFactories to clean up all of their internal state, which
  1304      *  It will cause all POAManagers to be deactivated, which in turn
  1314     // may include activated objects that have associated state and callbacks that must
  1305      *  will cause all POAs to be deactivated.
  1315     // complete in order to shutdown.  This will cause new request to be rejected.
  1306      */
       
  1307     protected void shutdownServants(boolean wait_for_completion) {
  1316     protected void shutdownServants(boolean wait_for_completion) {
  1308         Iterator iter = requestDispatcherRegistry.getObjectAdapterFactories().iterator() ;
  1317         Set<ObjectAdapterFactory> oaset;
  1309         while (iter.hasNext()) {
  1318         synchronized (this) {
  1310             ObjectAdapterFactory oaf = (ObjectAdapterFactory)iter.next() ;
  1319             oaset = new HashSet<>(requestDispatcherRegistry.getObjectAdapterFactories());
  1311             oaf.shutdown( wait_for_completion ) ;
  1320         }
  1312         }
  1321 
  1313     }
  1322         for (ObjectAdapterFactory oaf : oaset)
  1314 
  1323             oaf.shutdown(wait_for_completion);
  1315     // REVISIT: was protected - made public for framework
  1324     }
       
  1325 
  1316     // Note that the caller must hold the ORBImpl lock.
  1326     // Note that the caller must hold the ORBImpl lock.
  1317     public void checkShutdownState()
  1327     public void checkShutdownState()
  1318     {
  1328     {
  1319         if (status == STATUS_DESTROYED) {
  1329         if (status == STATUS_DESTROYED) {
  1320             throw wrapper.orbDestroyed() ;
  1330             throw wrapper.orbDestroyed() ;
  1325         }
  1335         }
  1326     }
  1336     }
  1327 
  1337 
  1328     public boolean isDuringDispatch()
  1338     public boolean isDuringDispatch()
  1329     {
  1339     {
       
  1340         synchronized (this) {
       
  1341                 checkShutdownState();
       
  1342         }
  1330         Boolean value = (Boolean)(isProcessingInvocation.get()) ;
  1343         Boolean value = (Boolean)(isProcessingInvocation.get()) ;
  1331         return value.booleanValue() ;
  1344         return value.booleanValue() ;
  1332     }
  1345     }
  1333 
  1346 
  1334     public void startingDispatch()
  1347     public void startingDispatch()
  1335     {
  1348     {
       
  1349         synchronized (this) {
       
  1350                 checkShutdownState();
       
  1351         }
  1336         synchronized (invocationObj) {
  1352         synchronized (invocationObj) {
  1337             isProcessingInvocation.set(Boolean.TRUE);
  1353             isProcessingInvocation.set(Boolean.TRUE);
       
  1354             numInvocations++;
  1338         }
  1355         }
  1339     }
  1356     }
  1340 
  1357 
  1341     public void finishedDispatch()
  1358     public void finishedDispatch()
  1342     {
  1359     {
       
  1360         synchronized (this) {
       
  1361                 checkShutdownState();
       
  1362         }
  1343         synchronized (invocationObj) {
  1363         synchronized (invocationObj) {
  1344             isProcessingInvocation.set(Boolean.FALSE);
  1364             numInvocations--;
       
  1365             isProcessingInvocation.set(false);
       
  1366             if (numInvocations == 0) {
       
  1367                 synchronized (waitForCompletionObj) {
       
  1368                     waitForCompletionObj.notifyAll();
       
  1369                 }
       
  1370             } else if (numInvocations < 0) {
       
  1371                 throw wrapper.numInvocationsAlreadyZero(
       
  1372                     CompletionStatus.COMPLETED_YES);
       
  1373             }
  1345         }
  1374         }
  1346     }
  1375     }
  1347 
  1376 
  1348     /**
  1377     /**
  1349      *  formal/99-10-07 p 159: "If destroy is called on an ORB that has
  1378      *  formal/99-10-07 p 159: "If destroy is called on an ORB that has
  1350      *  not been shut down, it will start the shutdown process and block until
  1379      *  not been shut down, it will start the shutdown process and block until
  1351      *  the ORB has shut down before it destroys the ORB."
  1380      *  the ORB has shut down before it destroys the ORB."
  1352      */
  1381      */
  1353     public synchronized void destroy()
  1382     public void destroy()
  1354     {
  1383     {
  1355         boolean shutdownFirst = false ;
  1384         boolean shutdownFirst = false;
  1356 
  1385 
  1357         synchronized (this) {
  1386         synchronized (this) {
  1358             shutdownFirst = (status == STATUS_OPERATING) ;
  1387             shutdownFirst = (status == STATUS_OPERATING);
  1359         }
  1388         }
  1360 
  1389 
  1361         if (shutdownFirst) {
  1390         if (shutdownFirst) {
  1362             shutdown(true);
  1391             shutdown(true);
  1363         }
  1392         }
  1364 
  1393 
  1365         synchronized (this) {
  1394         synchronized (this) {
  1366             if (status < STATUS_DESTROYED) {
  1395             if (status < STATUS_DESTROYED) {
  1367                 getCorbaTransportManager().close();
  1396                 getCorbaTransportManager().close();
  1368                 getPIHandler().destroyInterceptors() ;
  1397                 getPIHandler().destroyInterceptors();
  1369                 status = STATUS_DESTROYED;
  1398                 status = STATUS_DESTROYED;
  1370             }
  1399             }
  1371         }
  1400         }
  1372 
  1401         synchronized (threadPoolManagerAccessLock) {
       
  1402             if (orbOwnsThreadPoolManager) {
       
  1403                 try {
       
  1404                     threadpoolMgr.close();
       
  1405                     threadpoolMgr = null;
       
  1406                 } catch (IOException exc) {
       
  1407                     wrapper.ioExceptionOnClose(exc);
       
  1408                 }
       
  1409             }
       
  1410         }
       
  1411 
       
  1412         try {
       
  1413             monitoringManager.close();
       
  1414             monitoringManager = null;
       
  1415         } catch (IOException exc) {
       
  1416             wrapper.ioExceptionOnClose(exc);
       
  1417         }
       
  1418 
       
  1419         CachedCodeBase.cleanCache(this);
       
  1420         try {
       
  1421             pihandler.close();
       
  1422         } catch (IOException exc) {
       
  1423             wrapper.ioExceptionOnClose(exc);
       
  1424         }
       
  1425 
       
  1426         super.destroy();
       
  1427 
       
  1428         badServerIdHandlerAccessLock = null;
       
  1429         clientDelegateFactoryAccessorLock = null;
       
  1430         corbaContactInfoListFactoryAccessLock = null;
       
  1431 
       
  1432         objectKeyFactoryAccessLock = null;
       
  1433         legacyServerSocketManagerAccessLock = null;
       
  1434         threadPoolManagerAccessLock = null;
       
  1435         transportManager = null;
       
  1436         legacyServerSocketManager = null;
       
  1437         OAInvocationInfoStack  = null;
       
  1438         clientInvocationInfoStack  = null;
       
  1439         codeBaseIOR = null;
       
  1440         dynamicRequests  = null;
       
  1441         svResponseReceived  = null;
       
  1442         runObj = null;
       
  1443         shutdownObj = null;
       
  1444         waitForCompletionObj = null;
       
  1445         invocationObj = null;
       
  1446         isProcessingInvocation = null;
       
  1447         typeCodeForClassMap  = null;
       
  1448         valueFactoryCache = null;
       
  1449         orbVersionThreadLocal = null;
       
  1450         requestDispatcherRegistry = null;
       
  1451         copierManager = null;
       
  1452         toaFactory = null;
       
  1453         poaFactory = null;
       
  1454         pihandler = null;
       
  1455         configData = null;
       
  1456         badServerIdHandler = null;
       
  1457         clientDelegateFactory = null;
       
  1458         corbaContactInfoListFactory = null;
       
  1459         resolver = null;
       
  1460         localResolver = null;
       
  1461         insNamingDelegate = null;
       
  1462         urlOperation = null;
       
  1463         taggedComponentFactoryFinder = null;
       
  1464         taggedProfileFactoryFinder = null;
       
  1465         taggedProfileTemplateFactoryFinder = null;
       
  1466         objectKeyFactory = null;
  1373     }
  1467     }
  1374 
  1468 
  1375     /**
  1469     /**
  1376      * Registers a value factory for a particular repository ID.
  1470      * Registers a value factory for a particular repository ID.
  1377      *
  1471      *
  1432         return factory ;
  1526         return factory ;
  1433     }
  1527     }
  1434 
  1528 
  1435     public OAInvocationInfo peekInvocationInfo()
  1529     public OAInvocationInfo peekInvocationInfo()
  1436     {
  1530     {
       
  1531         synchronized (this) {
       
  1532                 checkShutdownState();
       
  1533         }
  1437         StackImpl stack = (StackImpl)(OAInvocationInfoStack.get()) ;
  1534         StackImpl stack = (StackImpl)(OAInvocationInfoStack.get()) ;
  1438         return (OAInvocationInfo)(stack.peek()) ;
  1535         return (OAInvocationInfo)(stack.peek()) ;
  1439     }
  1536     }
  1440 
  1537 
  1441     public void pushInvocationInfo( OAInvocationInfo info )
  1538     public void pushInvocationInfo( OAInvocationInfo info )
  1442     {
  1539     {
       
  1540         synchronized (this) {
       
  1541                 checkShutdownState();
       
  1542         }
  1443         StackImpl stack = (StackImpl)(OAInvocationInfoStack.get()) ;
  1543         StackImpl stack = (StackImpl)(OAInvocationInfoStack.get()) ;
  1444         stack.push( info ) ;
  1544         stack.push( info ) ;
  1445     }
  1545     }
  1446 
  1546 
  1447     public OAInvocationInfo popInvocationInfo()
  1547     public OAInvocationInfo popInvocationInfo()
  1448     {
  1548     {
       
  1549         synchronized (this) {
       
  1550                 checkShutdownState();
       
  1551         }
  1449         StackImpl stack = (StackImpl)(OAInvocationInfoStack.get()) ;
  1552         StackImpl stack = (StackImpl)(OAInvocationInfoStack.get()) ;
  1450         return (OAInvocationInfo)(stack.pop()) ;
  1553         return (OAInvocationInfo)(stack.pop()) ;
  1451     }
  1554     }
  1452 
  1555 
  1453     /**
  1556     /**
  1457 
  1560 
  1458     private Object badServerIdHandlerAccessLock = new Object();
  1561     private Object badServerIdHandlerAccessLock = new Object();
  1459 
  1562 
  1460     public void initBadServerIdHandler()
  1563     public void initBadServerIdHandler()
  1461     {
  1564     {
       
  1565         synchronized (this) {
       
  1566                 checkShutdownState();
       
  1567         }
  1462         synchronized (badServerIdHandlerAccessLock) {
  1568         synchronized (badServerIdHandlerAccessLock) {
  1463             Class cls = configData.getBadServerIdHandler() ;
  1569             Class cls = configData.getBadServerIdHandler() ;
  1464             if (cls != null) {
  1570             if (cls != null) {
  1465                 try {
  1571                 try {
  1466                     Class[] params = new Class[] { org.omg.CORBA.ORB.class };
  1572                     Class[] params = new Class[] { org.omg.CORBA.ORB.class };
  1475         }
  1581         }
  1476     }
  1582     }
  1477 
  1583 
  1478     public void setBadServerIdHandler( BadServerIdHandler handler )
  1584     public void setBadServerIdHandler( BadServerIdHandler handler )
  1479     {
  1585     {
       
  1586         synchronized (this) {
       
  1587                 checkShutdownState();
       
  1588         }
  1480         synchronized (badServerIdHandlerAccessLock) {
  1589         synchronized (badServerIdHandlerAccessLock) {
  1481             badServerIdHandler = handler;
  1590             badServerIdHandler = handler;
  1482         }
  1591         }
  1483     }
  1592     }
  1484 
  1593 
  1485     public void handleBadServerId( ObjectKey okey )
  1594     public void handleBadServerId( ObjectKey okey )
  1486     {
  1595     {
       
  1596         synchronized (this) {
       
  1597                 checkShutdownState();
       
  1598         }
  1487         synchronized (badServerIdHandlerAccessLock) {
  1599         synchronized (badServerIdHandlerAccessLock) {
  1488             if (badServerIdHandler == null)
  1600             if (badServerIdHandler == null)
  1489                 throw wrapper.badServerId() ;
  1601                 throw wrapper.badServerId() ;
  1490             else
  1602             else
  1491                 badServerIdHandler.handle( okey ) ;
  1603                 badServerIdHandler.handle( okey ) ;
  1530         }
  1642         }
  1531     }
  1643     }
  1532 
  1644 
  1533     public int getTransientServerId()
  1645     public int getTransientServerId()
  1534     {
  1646     {
       
  1647         synchronized (this) {
       
  1648                 checkShutdownState();
       
  1649         }
  1535         if( configData.getORBServerIdPropertySpecified( ) ) {
  1650         if( configData.getORBServerIdPropertySpecified( ) ) {
  1536             // ORBServerId is specified then use that value
  1651             // ORBServerId is specified then use that value
  1537             return configData.getPersistentServerId( );
  1652             return configData.getPersistentServerId( );
  1538         }
  1653         }
  1539         return transientServerId;
  1654         return transientServerId;
  1540     }
  1655     }
  1541 
  1656 
  1542     public RequestDispatcherRegistry getRequestDispatcherRegistry()
  1657     public RequestDispatcherRegistry getRequestDispatcherRegistry()
  1543     {
  1658     {
       
  1659         synchronized (this) {
       
  1660                 checkShutdownState();
       
  1661         }
  1544         return requestDispatcherRegistry;
  1662         return requestDispatcherRegistry;
  1545     }
  1663     }
  1546 
  1664 
  1547     public ServiceContextRegistry getServiceContextRegistry()
  1665     public ServiceContextRegistry getServiceContextRegistry()
  1548     {
  1666     {
       
  1667         synchronized (this) {
       
  1668                 checkShutdownState();
       
  1669         }
  1549         return serviceContextRegistry ;
  1670         return serviceContextRegistry ;
  1550     }
  1671     }
  1551 
  1672 
  1552     // XXX All of the isLocalXXX checking needs to be revisited.
  1673     // XXX All of the isLocalXXX checking needs to be revisited.
  1553     // First of all, all three of these methods are called from
  1674     // First of all, all three of these methods are called from
  1561     // LocalClientRequestDispatcher as well.  Bottom line: this code needs to move.
  1682     // LocalClientRequestDispatcher as well.  Bottom line: this code needs to move.
  1562 
  1683 
  1563     // XXX What about multi-homed host?
  1684     // XXX What about multi-homed host?
  1564     public boolean isLocalHost( String hostName )
  1685     public boolean isLocalHost( String hostName )
  1565     {
  1686     {
       
  1687         synchronized (this) {
       
  1688                 checkShutdownState();
       
  1689         }
  1566         return hostName.equals( configData.getORBServerHost() ) ||
  1690         return hostName.equals( configData.getORBServerHost() ) ||
  1567             hostName.equals( getLocalHostName() ) ;
  1691             hostName.equals( getLocalHostName() ) ;
  1568     }
  1692     }
  1569 
  1693 
  1570     public boolean isLocalServerId( int subcontractId, int serverId )
  1694     public boolean isLocalServerId( int subcontractId, int serverId )
  1571     {
  1695     {
       
  1696         synchronized (this) {
       
  1697                 checkShutdownState();
       
  1698         }
  1572         if ((subcontractId < ORBConstants.FIRST_POA_SCID) ||
  1699         if ((subcontractId < ORBConstants.FIRST_POA_SCID) ||
  1573             (subcontractId > ORBConstants.MAX_POA_SCID))
  1700             (subcontractId > ORBConstants.MAX_POA_SCID))
  1574             return serverId == getTransientServerId( ) ;
  1701             return serverId == getTransientServerId( ) ;
  1575 
  1702 
  1576         // XXX isTransient info should be stored in subcontract registry
  1703         // XXX isTransient info should be stored in subcontract registry
  1657     // pept.broker.Broker
  1784     // pept.broker.Broker
  1658     //
  1785     //
  1659 
  1786 
  1660     public ClientInvocationInfo createOrIncrementInvocationInfo()
  1787     public ClientInvocationInfo createOrIncrementInvocationInfo()
  1661     {
  1788     {
       
  1789         synchronized (this) {
       
  1790                 checkShutdownState();
       
  1791         }
  1662         StackImpl invocationInfoStack =
  1792         StackImpl invocationInfoStack =
  1663             (StackImpl) clientInvocationInfoStack.get();
  1793             (StackImpl) clientInvocationInfoStack.get();
  1664         ClientInvocationInfo clientInvocationInfo = null;
  1794         ClientInvocationInfo clientInvocationInfo = null;
  1665         if (!invocationInfoStack.empty()) {
  1795         if (!invocationInfoStack.empty()) {
  1666             clientInvocationInfo =
  1796             clientInvocationInfo =
  1680         return clientInvocationInfo;
  1810         return clientInvocationInfo;
  1681     }
  1811     }
  1682 
  1812 
  1683     public void releaseOrDecrementInvocationInfo()
  1813     public void releaseOrDecrementInvocationInfo()
  1684     {
  1814     {
       
  1815         synchronized (this) {
       
  1816                 checkShutdownState();
       
  1817         }
       
  1818         int entryCount = -1;
       
  1819         ClientInvocationInfo clientInvocationInfo = null;
  1685         StackImpl invocationInfoStack =
  1820         StackImpl invocationInfoStack =
  1686             (StackImpl)clientInvocationInfoStack.get();
  1821             (StackImpl)clientInvocationInfoStack.get();
  1687         int entryCount = -1;
       
  1688         ClientInvocationInfo clientInvocationInfo = null;
       
  1689         if (!invocationInfoStack.empty()) {
  1822         if (!invocationInfoStack.empty()) {
  1690             clientInvocationInfo =
  1823             clientInvocationInfo =
  1691                 (ClientInvocationInfo)invocationInfoStack.peek();
  1824                 (ClientInvocationInfo)invocationInfoStack.peek();
  1692         } else {
  1825         } else {
  1693             throw wrapper.invocationInfoStackEmpty() ;
  1826             throw wrapper.invocationInfoStackEmpty() ;
  1703         }
  1836         }
  1704     }
  1837     }
  1705 
  1838 
  1706     public ClientInvocationInfo getInvocationInfo()
  1839     public ClientInvocationInfo getInvocationInfo()
  1707     {
  1840     {
       
  1841         synchronized (this) {
       
  1842                 checkShutdownState();
       
  1843         }
  1708         StackImpl invocationInfoStack =
  1844         StackImpl invocationInfoStack =
  1709             (StackImpl) clientInvocationInfoStack.get();
  1845             (StackImpl) clientInvocationInfoStack.get();
  1710         return (ClientInvocationInfo) invocationInfoStack.peek();
  1846         return (ClientInvocationInfo) invocationInfoStack.peek();
  1711     }
  1847     }
  1712 
  1848 
  1717 
  1853 
  1718     private Object clientDelegateFactoryAccessorLock = new Object();
  1854     private Object clientDelegateFactoryAccessorLock = new Object();
  1719 
  1855 
  1720     public void setClientDelegateFactory( ClientDelegateFactory factory )
  1856     public void setClientDelegateFactory( ClientDelegateFactory factory )
  1721     {
  1857     {
       
  1858         synchronized (this) {
       
  1859                 checkShutdownState();
       
  1860         }
  1722         synchronized (clientDelegateFactoryAccessorLock) {
  1861         synchronized (clientDelegateFactoryAccessorLock) {
  1723             clientDelegateFactory = factory ;
  1862             clientDelegateFactory = factory ;
  1724         }
  1863         }
  1725     }
  1864     }
  1726 
  1865 
  1727     public ClientDelegateFactory getClientDelegateFactory()
  1866     public ClientDelegateFactory getClientDelegateFactory()
  1728     {
  1867     {
       
  1868         synchronized (this) {
       
  1869                 checkShutdownState();
       
  1870         }
  1729         synchronized (clientDelegateFactoryAccessorLock) {
  1871         synchronized (clientDelegateFactoryAccessorLock) {
  1730             return clientDelegateFactory ;
  1872             return clientDelegateFactory ;
  1731         }
  1873         }
  1732     }
  1874     }
  1733 
  1875 
  1734     private Object corbaContactInfoListFactoryAccessLock = new Object();
  1876     private Object corbaContactInfoListFactoryAccessLock = new Object();
  1735 
  1877 
  1736     public void setCorbaContactInfoListFactory( CorbaContactInfoListFactory factory )
  1878     public void setCorbaContactInfoListFactory( CorbaContactInfoListFactory factory )
  1737     {
  1879     {
       
  1880         synchronized (this) {
       
  1881                 checkShutdownState();
       
  1882         }
  1738         synchronized (corbaContactInfoListFactoryAccessLock) {
  1883         synchronized (corbaContactInfoListFactoryAccessLock) {
  1739             corbaContactInfoListFactory = factory ;
  1884             corbaContactInfoListFactory = factory ;
  1740         }
  1885         }
  1741     }
  1886     }
  1742 
  1887 
  1743     public synchronized CorbaContactInfoListFactory getCorbaContactInfoListFactory()
  1888     public synchronized CorbaContactInfoListFactory getCorbaContactInfoListFactory()
  1744     {
  1889     {
       
  1890         checkShutdownState();
  1745         return corbaContactInfoListFactory ;
  1891         return corbaContactInfoListFactory ;
  1746     }
  1892     }
  1747 
  1893 
  1748     /** Set the resolver used in this ORB.  This resolver will be used for list_initial_services
  1894     /** Set the resolver used in this ORB.  This resolver will be used for list_initial_services
  1749      * and resolve_initial_references.
  1895      * and resolve_initial_references.
  1750      */
  1896      */
  1751     public void setResolver( Resolver resolver )
  1897     public void setResolver( Resolver resolver )
  1752     {
  1898     {
       
  1899         synchronized (this) {
       
  1900                 checkShutdownState();
       
  1901         }
  1753         synchronized (resolverLock) {
  1902         synchronized (resolverLock) {
  1754             this.resolver = resolver ;
  1903             this.resolver = resolver ;
  1755         }
  1904         }
  1756     }
  1905     }
  1757 
  1906 
  1758     /** Get the resolver used in this ORB.  This resolver will be used for list_initial_services
  1907     /** Get the resolver used in this ORB.  This resolver will be used for list_initial_services
  1759      * and resolve_initial_references.
  1908      * and resolve_initial_references.
  1760      */
  1909      */
  1761     public Resolver getResolver()
  1910     public Resolver getResolver()
  1762     {
  1911     {
       
  1912         synchronized (this) {
       
  1913                 checkShutdownState();
       
  1914         }
  1763         synchronized (resolverLock) {
  1915         synchronized (resolverLock) {
  1764             return resolver ;
  1916             return resolver ;
  1765         }
  1917         }
  1766     }
  1918     }
  1767 
  1919 
  1768     /** Set the LocalResolver used in this ORB.  This LocalResolver is used for
  1920     /** Set the LocalResolver used in this ORB.  This LocalResolver is used for
  1769      * register_initial_reference only.
  1921      * register_initial_reference only.
  1770      */
  1922      */
  1771     public void setLocalResolver( LocalResolver resolver )
  1923     public void setLocalResolver( LocalResolver resolver )
  1772     {
  1924     {
       
  1925         synchronized (this) {
       
  1926                 checkShutdownState();
       
  1927         }
  1773         synchronized (resolverLock) {
  1928         synchronized (resolverLock) {
  1774             this.localResolver = resolver ;
  1929             this.localResolver = resolver ;
  1775         }
  1930         }
  1776     }
  1931     }
  1777 
  1932 
  1778     /** Get the LocalResolver used in this ORB.  This LocalResolver is used for
  1933     /** Get the LocalResolver used in this ORB.  This LocalResolver is used for
  1779      * register_initial_reference only.
  1934      * register_initial_reference only.
  1780      */
  1935      */
  1781     public LocalResolver getLocalResolver()
  1936     public LocalResolver getLocalResolver()
  1782     {
  1937     {
       
  1938         synchronized (this) {
       
  1939                 checkShutdownState();
       
  1940         }
  1783         synchronized (resolverLock) {
  1941         synchronized (resolverLock) {
  1784             return localResolver ;
  1942             return localResolver ;
  1785         }
  1943         }
  1786     }
  1944     }
  1787 
  1945 
  1788     /** Set the operation used in string_to_object calls.  The Operation must expect a
  1946     /** Set the operation used in string_to_object calls.  The Operation must expect a
  1789      * String and return an org.omg.CORBA.Object.
  1947      * String and return an org.omg.CORBA.Object.
  1790      */
  1948      */
  1791     public void setURLOperation( Operation stringToObject )
  1949     public void setURLOperation( Operation stringToObject )
  1792     {
  1950     {
       
  1951         synchronized (this) {
       
  1952                 checkShutdownState();
       
  1953         }
  1793         synchronized (urlOperationLock) {
  1954         synchronized (urlOperationLock) {
  1794             urlOperation = stringToObject ;
  1955             urlOperation = stringToObject ;
  1795         }
  1956         }
  1796     }
  1957     }
  1797 
  1958 
  1798     /** Get the operation used in string_to_object calls.  The Operation must expect a
  1959     /** Get the operation used in string_to_object calls.  The Operation must expect a
  1799      * String and return an org.omg.CORBA.Object.
  1960      * String and return an org.omg.CORBA.Object.
  1800      */
  1961      */
  1801     public Operation getURLOperation()
  1962     public Operation getURLOperation()
  1802     {
  1963     {
       
  1964         synchronized (this) {
       
  1965                 checkShutdownState();
       
  1966         }
  1803         synchronized (urlOperationLock) {
  1967         synchronized (urlOperationLock) {
  1804             return urlOperation ;
  1968             return urlOperation ;
  1805         }
  1969         }
  1806     }
  1970     }
  1807 
  1971 
  1808     public void setINSDelegate( CorbaServerRequestDispatcher sdel )
  1972     public void setINSDelegate( CorbaServerRequestDispatcher sdel )
  1809     {
  1973     {
       
  1974         synchronized (this) {
       
  1975                 checkShutdownState();
       
  1976         }
  1810         synchronized (resolverLock) {
  1977         synchronized (resolverLock) {
  1811             insNamingDelegate = sdel ;
  1978             insNamingDelegate = sdel ;
  1812         }
  1979         }
  1813     }
  1980     }
  1814 
  1981 
  1815     public TaggedComponentFactoryFinder getTaggedComponentFactoryFinder()
  1982     public TaggedComponentFactoryFinder getTaggedComponentFactoryFinder()
  1816     {
  1983     {
       
  1984         synchronized (this) {
       
  1985                 checkShutdownState();
       
  1986         }
  1817         return taggedComponentFactoryFinder ;
  1987         return taggedComponentFactoryFinder ;
  1818     }
  1988     }
  1819 
  1989 
  1820     public IdentifiableFactoryFinder getTaggedProfileFactoryFinder()
  1990     public IdentifiableFactoryFinder getTaggedProfileFactoryFinder()
  1821     {
  1991     {
       
  1992         synchronized (this) {
       
  1993                 checkShutdownState();
       
  1994         }
  1822         return taggedProfileFactoryFinder ;
  1995         return taggedProfileFactoryFinder ;
  1823     }
  1996     }
  1824 
  1997 
  1825     public IdentifiableFactoryFinder getTaggedProfileTemplateFactoryFinder()
  1998     public IdentifiableFactoryFinder getTaggedProfileTemplateFactoryFinder()
  1826     {
  1999     {
       
  2000         synchronized (this) {
       
  2001                 checkShutdownState();
       
  2002         }
  1827         return taggedProfileTemplateFactoryFinder ;
  2003         return taggedProfileTemplateFactoryFinder ;
  1828     }
  2004     }
  1829 
  2005 
  1830     private Object objectKeyFactoryAccessLock = new Object();
  2006     private Object objectKeyFactoryAccessLock = new Object();
  1831 
  2007 
  1832     public ObjectKeyFactory getObjectKeyFactory()
  2008     public ObjectKeyFactory getObjectKeyFactory()
  1833     {
  2009     {
       
  2010         synchronized (this) {
       
  2011                 checkShutdownState();
       
  2012         }
  1834         synchronized (objectKeyFactoryAccessLock) {
  2013         synchronized (objectKeyFactoryAccessLock) {
  1835             return objectKeyFactory ;
  2014             return objectKeyFactory ;
  1836         }
  2015         }
  1837     }
  2016     }
  1838 
  2017 
  1839     public void setObjectKeyFactory( ObjectKeyFactory factory )
  2018     public void setObjectKeyFactory( ObjectKeyFactory factory )
  1840     {
  2019     {
       
  2020         synchronized (this) {
       
  2021                 checkShutdownState();
       
  2022         }
  1841         synchronized (objectKeyFactoryAccessLock) {
  2023         synchronized (objectKeyFactoryAccessLock) {
  1842             objectKeyFactory = factory ;
  2024             objectKeyFactory = factory ;
  1843         }
  2025         }
  1844     }
  2026     }
  1845 
  2027 
  1862 
  2044 
  1863     private Object legacyServerSocketManagerAccessLock = new Object();
  2045     private Object legacyServerSocketManagerAccessLock = new Object();
  1864 
  2046 
  1865     public LegacyServerSocketManager getLegacyServerSocketManager()
  2047     public LegacyServerSocketManager getLegacyServerSocketManager()
  1866     {
  2048     {
       
  2049         synchronized (this) {
       
  2050                 checkShutdownState();
       
  2051         }
  1867         synchronized (legacyServerSocketManagerAccessLock) {
  2052         synchronized (legacyServerSocketManagerAccessLock) {
  1868             if (legacyServerSocketManager == null) {
  2053             if (legacyServerSocketManager == null) {
  1869                 legacyServerSocketManager = new LegacyServerSocketManagerImpl(this);
  2054                 legacyServerSocketManager = new LegacyServerSocketManagerImpl(this);
  1870             }
  2055             }
  1871             return legacyServerSocketManager;
  2056             return legacyServerSocketManager;
  1874 
  2059 
  1875     private Object threadPoolManagerAccessLock = new Object();
  2060     private Object threadPoolManagerAccessLock = new Object();
  1876 
  2061 
  1877     public void setThreadPoolManager(ThreadPoolManager mgr)
  2062     public void setThreadPoolManager(ThreadPoolManager mgr)
  1878     {
  2063     {
       
  2064         synchronized (this) {
       
  2065                 checkShutdownState();
       
  2066         }
  1879         synchronized (threadPoolManagerAccessLock) {
  2067         synchronized (threadPoolManagerAccessLock) {
  1880             threadpoolMgr = mgr;
  2068             threadpoolMgr = mgr;
  1881         }
  2069         }
  1882     }
  2070     }
  1883 
  2071 
  1884     public ThreadPoolManager getThreadPoolManager()
  2072     public ThreadPoolManager getThreadPoolManager()
  1885     {
  2073     {
       
  2074         synchronized (this) {
       
  2075                 checkShutdownState();
       
  2076         }
  1886         synchronized (threadPoolManagerAccessLock) {
  2077         synchronized (threadPoolManagerAccessLock) {
  1887             if (threadpoolMgr == null) {
  2078             if (threadpoolMgr == null) {
  1888                 threadpoolMgr = new ThreadPoolManagerImpl( threadGroup );
  2079                 threadpoolMgr = new ThreadPoolManagerImpl();
       
  2080                 orbOwnsThreadPoolManager = true;
  1889             }
  2081             }
  1890             return threadpoolMgr;
  2082             return threadpoolMgr;
  1891         }
  2083         }
  1892     }
  2084     }
  1893 
  2085 
  1894     public CopierManager getCopierManager()
  2086     public CopierManager getCopierManager()
  1895     {
  2087     {
       
  2088         synchronized (this) {
       
  2089                 checkShutdownState();
       
  2090         }
  1896         return copierManager ;
  2091         return copierManager ;
  1897     }
  2092     }
  1898 } // Class ORBImpl
  2093 } // Class ORBImpl
  1899 
  2094 
  1900 ////////////////////////////////////////////////////////////////////////
  2095 ////////////////////////////////////////////////////////////////////////