src/share/classes/com/sun/corba/se/impl/orb/ORBImpl.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 21,59 **** * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ ! package com.sun.corba.se.impl.orb ; import java.applet.Applet; ! import java.io.IOException ; import java.lang.reflect.Constructor; ! import java.lang.reflect.Field ; ! import java.lang.reflect.Modifier ; ! import java.lang.reflect.InvocationTargetException ; ! import java.util.ArrayList ; ! import java.util.Iterator ; ! import java.util.Properties ; ! import java.util.Vector ; ! import java.util.Hashtable ; ! import java.util.Map ; ! import java.util.HashMap ; ! import java.util.LinkedList ; ! import java.util.Collection ; ! import java.util.Collections ; ! import java.util.StringTokenizer ; ! import java.util.Enumeration ; ! import java.util.WeakHashMap ; ! import java.net.InetAddress ; import java.security.PrivilegedAction; ! import java.security.AccessController ; import javax.rmi.CORBA.Util; import javax.rmi.CORBA.ValueHandler; import org.omg.CORBA.Context; --- 21,61 ---- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ ! package com.sun.corba.se.impl.orb; import java.applet.Applet; ! import java.io.IOException; import java.lang.reflect.Constructor; ! import java.lang.reflect.Field; ! import java.lang.reflect.Modifier; ! import java.lang.reflect.InvocationTargetException; ! import java.util.Set; ! import java.util.HashSet; ! import java.util.ArrayList; ! import java.util.Iterator; ! import java.util.Properties; ! import java.util.Vector; ! import java.util.Hashtable; ! import java.util.Map; ! import java.util.HashMap; ! import java.util.LinkedList; ! import java.util.Collection; ! import java.util.Collections; ! import java.util.StringTokenizer; ! import java.util.Enumeration; ! import java.util.WeakHashMap; ! import java.net.InetAddress; import java.security.PrivilegedAction; ! import java.security.AccessController; import javax.rmi.CORBA.Util; import javax.rmi.CORBA.ValueHandler; import org.omg.CORBA.Context;
*** 80,101 **** import org.omg.CORBA.ORBPackage.InvalidName; import com.sun.org.omg.SendingContext.CodeBase; import com.sun.corba.se.pept.broker.Broker; ! import com.sun.corba.se.pept.protocol.ClientInvocationInfo ; import com.sun.corba.se.pept.transport.ContactInfo; import com.sun.corba.se.pept.transport.ConnectionCache; import com.sun.corba.se.pept.transport.TransportManager; import com.sun.corba.se.spi.ior.IOR; ! import com.sun.corba.se.spi.ior.IdentifiableFactoryFinder ; import com.sun.corba.se.spi.ior.TaggedComponentFactoryFinder; ! import com.sun.corba.se.spi.ior.IORFactories ; ! import com.sun.corba.se.spi.ior.ObjectKey ; ! import com.sun.corba.se.spi.ior.ObjectKeyFactory ; ! import com.sun.corba.se.spi.ior.iiop.IIOPFactories ; import com.sun.corba.se.spi.ior.iiop.GIOPVersion; import com.sun.corba.se.spi.oa.OAInvocationInfo; import com.sun.corba.se.spi.oa.ObjectAdapterFactory; import com.sun.corba.se.spi.orb.DataCollector; import com.sun.corba.se.spi.orb.Operation; --- 82,103 ---- import org.omg.CORBA.ORBPackage.InvalidName; import com.sun.org.omg.SendingContext.CodeBase; import com.sun.corba.se.pept.broker.Broker; ! import com.sun.corba.se.pept.protocol.ClientInvocationInfo; import com.sun.corba.se.pept.transport.ContactInfo; import com.sun.corba.se.pept.transport.ConnectionCache; import com.sun.corba.se.pept.transport.TransportManager; import com.sun.corba.se.spi.ior.IOR; ! import com.sun.corba.se.spi.ior.IdentifiableFactoryFinder; import com.sun.corba.se.spi.ior.TaggedComponentFactoryFinder; ! import com.sun.corba.se.spi.ior.IORFactories; ! import com.sun.corba.se.spi.ior.ObjectKey; ! import com.sun.corba.se.spi.ior.ObjectKeyFactory; ! import com.sun.corba.se.spi.ior.iiop.IIOPFactories; import com.sun.corba.se.spi.ior.iiop.GIOPVersion; import com.sun.corba.se.spi.oa.OAInvocationInfo; import com.sun.corba.se.spi.oa.ObjectAdapterFactory; import com.sun.corba.se.spi.orb.DataCollector; import com.sun.corba.se.spi.orb.Operation;
*** 120,133 **** import com.sun.corba.se.spi.orb.StringPair; import com.sun.corba.se.spi.orb.StringPair; import com.sun.corba.se.spi.transport.CorbaContactInfoListFactory; import com.sun.corba.se.spi.transport.CorbaTransportManager; import com.sun.corba.se.spi.legacy.connection.LegacyServerSocketManager; ! import com.sun.corba.se.spi.copyobject.CopierManager ; ! import com.sun.corba.se.spi.presentation.rmi.PresentationDefaults ; ! import com.sun.corba.se.spi.presentation.rmi.PresentationManager ; ! import com.sun.corba.se.spi.presentation.rmi.StubAdapter ; import com.sun.corba.se.spi.servicecontext.ServiceContextRegistry; import com.sun.corba.se.impl.corba.TypeCodeFactory; import com.sun.corba.se.impl.corba.TypeCodeImpl; import com.sun.corba.se.impl.corba.NVListImpl; --- 122,135 ---- import com.sun.corba.se.spi.orb.StringPair; import com.sun.corba.se.spi.orb.StringPair; import com.sun.corba.se.spi.transport.CorbaContactInfoListFactory; import com.sun.corba.se.spi.transport.CorbaTransportManager; import com.sun.corba.se.spi.legacy.connection.LegacyServerSocketManager; ! import com.sun.corba.se.spi.copyobject.CopierManager; ! import com.sun.corba.se.spi.presentation.rmi.PresentationDefaults; ! import com.sun.corba.se.spi.presentation.rmi.PresentationManager; ! import com.sun.corba.se.spi.presentation.rmi.StubAdapter; import com.sun.corba.se.spi.servicecontext.ServiceContextRegistry; import com.sun.corba.se.impl.corba.TypeCodeFactory; import com.sun.corba.se.impl.corba.TypeCodeImpl; import com.sun.corba.se.impl.corba.NVListImpl;
*** 138,147 **** --- 140,150 ---- import com.sun.corba.se.impl.corba.AsynchInvoke; import com.sun.corba.se.impl.corba.AnyImpl; import com.sun.corba.se.impl.corba.RequestImpl; import com.sun.corba.se.impl.dynamicany.DynAnyFactoryImpl; import com.sun.corba.se.impl.encoding.EncapsOutputStream; + import com.sun.corba.se.impl.encoding.CachedCodeBase; import com.sun.corba.se.impl.interceptors.PIHandlerImpl; import com.sun.corba.se.impl.interceptors.PINoOpHandlerImpl; import com.sun.corba.se.impl.ior.TaggedComponentFactoryFinderImpl; import com.sun.corba.se.impl.ior.TaggedProfileFactoryFinderImpl; import com.sun.corba.se.impl.ior.TaggedProfileTemplateFactoryFinderImpl;
*** 183,200 **** --- 186,205 ---- private Vector dynamicRequests ; private SynchVariable svResponseReceived ; private java.lang.Object runObj = new java.lang.Object(); private java.lang.Object shutdownObj = new java.lang.Object(); + private java.lang.Object waitForCompletionObj = new java.lang.Object(); private static final byte STATUS_OPERATING = 1; private static final byte STATUS_SHUTTING_DOWN = 2; private static final byte STATUS_SHUTDOWN = 3; private static final byte STATUS_DESTROYED = 4; private byte status = STATUS_OPERATING; // XXX Should we move invocation tracking to the first level server dispatcher? private java.lang.Object invocationObj = new java.lang.Object(); + private int numInvocations = 0; // thread local variable to store a boolean to detect deadlock in // ORB.shutdown(true). private ThreadLocal isProcessingInvocation = new ThreadLocal () { protected java.lang.Object initialValue() {
*** 218,229 **** private CopierManager copierManager ; private int transientServerId ; - private ThreadGroup threadGroup ; - private ServiceContextRegistry serviceContextRegistry ; // Needed here to implement connect/disconnect private TOAFactory toaFactory ; --- 223,232 ----
*** 263,272 **** --- 266,276 ---- // Converts strings to object references for resolvers and string_to_object private Operation urlOperation ; private final Object urlOperationLock = new java.lang.Object() ; private CorbaServerRequestDispatcher insNamingDelegate ; + // resolverLock must be used for all access to either resolver or // localResolver, since it is possible for the resolver to indirectly // refer to the localResolver. Also used to protect access to // insNamingDelegate. private final Object resolverLock = new Object() ;
*** 277,286 **** --- 281,292 ---- private IdentifiableFactoryFinder taggedProfileTemplateFactoryFinder ; private ObjectKeyFactory objectKeyFactory ; + private boolean orbOwnsThreadPoolManager = false ; + private ThreadPoolManager threadpoolMgr; private void dprint( String msg ) { ORBUtility.dprint( this, msg ) ;
*** 320,334 **** --- 326,346 ---- // All initialization is done through set_parameters(). } public ORBVersion getORBVersion() { + synchronized (this) { + checkShutdownState(); + } return (ORBVersion)(orbVersionThreadLocal.get()) ; } public void setORBVersion(ORBVersion verObj) { + synchronized (this) { + checkShutdownState(); + } orbVersionThreadLocal.set(verObj); } /**************************************************************************** * The following methods are ORB initialization
*** 345,394 **** // Interceptors to be invoked before the complete ORB initialization. // piHandler will be replaced by a real PIHandler implementation at the // end of this method. pihandler = new PINoOpHandlerImpl( ); - // See bugs 4916766 and 4936203 - // We intend to create new threads in a reliable thread group. - // This avoids problems if the application/applet - // creates a thread group, makes JavaIDL calls which create a new - // connection and ReaderThread, and then destroys the thread - // group. If our ReaderThreads were to be part of such destroyed thread - // group then it might get killed and cause other invoking threads - // sharing the same connection to get a non-restartable - // CommunicationFailure. We'd like to avoid that. - // - // Our solution is to create all of our threads in the highest thread - // group that we have access to, given our own security clearance. - // - try { - // try to get a thread group that's as high in the threadgroup - // parent-child hierarchy, as we can get to. - // this will prevent an ORB thread created during applet-init from - // being killed when an applet dies. - threadGroup = (ThreadGroup) AccessController.doPrivileged( - new PrivilegedAction() { - public Object run() { - ThreadGroup tg = Thread.currentThread().getThreadGroup() ; - ThreadGroup ptg = tg ; - try { - while (ptg != null) { - tg = ptg; - ptg = tg.getParent(); - } - } catch (SecurityException se) { - // Discontinue going higher on a security exception. - } - return new ThreadGroup(tg, "ORB ThreadGroup"); - } - } - ); - } catch (SecurityException e) { - // something wrong, we go back to the original code - threadGroup = Thread.currentThread().getThreadGroup(); - } - // This is the unique id of this server (JVM). Multiple incarnations // of this server will get different ids. // Compute transientServerId = milliseconds since Jan 1, 1970 // Note: transientServerId will wrap in about 2^32 / 86400000 = 49.7 days. // If two ORBS are started at the same time then there is a possibility --- 357,366 ----
*** 545,554 **** --- 517,529 ---- return toaFactory ; } public void set_parameters( Properties props ) { + synchronized (this) { + checkShutdownState(); + } preInit( null, props ) ; DataCollector dataCollector = DataCollectorFactory.create( props, getLocalHostName() ) ; postInit( null, dataCollector ) ; }
*** 786,795 **** --- 761,773 ---- /** * Notify response to ORB for get_next_response */ public void notifyORB() { + synchronized (this) { + checkShutdownState(); + } synchronized (this.svResponseReceived) { this.svResponseReceived.set(); this.svResponseReceived.notify(); } }
*** 852,861 **** --- 830,841 ---- // pure java orb support, moved this method from FVDCodeBaseImpl. // Note that we connect this if we have not already done so. public synchronized IOR getFVDCodeBaseIOR() { + checkShutdownState(); + if (codeBaseIOR != null) // i.e. We are already connected to it return codeBaseIOR; // backward compatability 4365188 CodeBase cb;
*** 1116,1125 **** --- 1096,1107 ---- // Keeping a cache of TypeCodes associated with the class // they got created from in Util.writeAny(). public synchronized void setTypeCodeForClass(Class c, TypeCodeImpl tci) { + checkShutdownState(); + if (typeCodeForClassMap == null) typeCodeForClassMap = Collections.synchronizedMap( new WeakHashMap(64)); // Store only one TypeCode per class. if ( ! typeCodeForClassMap.containsKey(c))
*** 1126,1135 **** --- 1108,1119 ---- typeCodeForClassMap.put(c, tci); } public synchronized TypeCodeImpl getTypeCodeForClass(Class c) { + checkShutdownState(); + if (typeCodeForClassMap == null) return null; return (TypeCodeImpl)typeCodeForClassMap.get(c); }
*** 1208,1217 **** --- 1192,1205 ---- public void register_initial_reference( String id, org.omg.CORBA.Object obj ) throws InvalidName { CorbaServerRequestDispatcher insnd ; + synchronized (this) { + checkShutdownState(); + } + if ((id == null) || (id.length() == 0)) throw new InvalidName() ; synchronized (this) { checkShutdownState();
*** 1251,1320 **** runObj.wait(); } catch ( InterruptedException ex ) {} } } ! public void shutdown(boolean wait_for_completion) ! { ! // to wait for completion, we would deadlock, so throw a standard ! // OMG exception. ! if (wait_for_completion && ((Boolean)isProcessingInvocation.get()).booleanValue()) { ! throw omgWrapper.shutdownWaitForCompletionDeadlock() ; ! } - boolean doShutdown = false ; - synchronized (this) { ! checkShutdownState() ; if (status == STATUS_SHUTTING_DOWN) { ! if (!wait_for_completion) ! // If we are already shutting down and don't want ! // to wait, nothing to do: return. ! return ; } else { ! // The ORB status was STATUS_OPERATING, so start the shutdown. ! status = STATUS_SHUTTING_DOWN ; ! doShutdown = true ; } } ! // At this point, status is SHUTTING_DOWN. ! // All shutdown calls with wait_for_completion == true must synchronize ! // here. Only the first call will be made with doShutdown == true. synchronized (shutdownObj) { ! if (doShutdown) { ! // shutdownServants will set all POAManagers into the ! // INACTIVE state, causing request to be rejected. ! // If wait_for_completion is true, this will not return until ! // all invocations have completed. shutdownServants(wait_for_completion); synchronized (runObj) { runObj.notifyAll(); } - synchronized (this) { status = STATUS_SHUTDOWN; } } } - } ! /** This method shuts down the ORB and causes orb.run() to return. ! * It will cause all POAManagers to be deactivated, which in turn ! * will cause all POAs to be deactivated. ! */ protected void shutdownServants(boolean wait_for_completion) { ! Iterator iter = requestDispatcherRegistry.getObjectAdapterFactories().iterator() ; ! while (iter.hasNext()) { ! ObjectAdapterFactory oaf = (ObjectAdapterFactory)iter.next() ; ! oaf.shutdown( wait_for_completion ) ; } } - // REVISIT: was protected - made public for framework // Note that the caller must hold the ORBImpl lock. public void checkShutdownState() { if (status == STATUS_DESTROYED) { throw wrapper.orbDestroyed() ; --- 1239,1330 ---- runObj.wait(); } catch ( InterruptedException ex ) {} } } ! public void shutdown(boolean wait_for_completion) { ! boolean wait = false; synchronized (this) { ! checkShutdownState(); + // This is to avoid deadlock: don't allow a thread that is + // processing a request to call shutdown( true ), because + // the shutdown would block waiting for the request to complete, + // while the request would block waiting for shutdown to complete. + if (wait_for_completion && + isProcessingInvocation.get() == Boolean.TRUE) { + throw omgWrapper.shutdownWaitForCompletionDeadlock(); + } + if (status == STATUS_SHUTTING_DOWN) { ! if (wait_for_completion) { ! wait = true; } else { ! return; } } ! status = STATUS_SHUTTING_DOWN; ! } ! ! // Avoid more than one thread performing shutdown at a time. synchronized (shutdownObj) { ! // At this point, the ORB status is certainly STATUS_SHUTTING_DOWN. ! // If wait is true, another thread already called shutdown( true ), ! // and so we wait for completion ! if (wait) { ! while (true) { ! synchronized (this) { ! if (status == STATUS_SHUTDOWN) ! break; ! } ! ! try { ! shutdownObj.wait(); ! } catch (InterruptedException exc) { ! // NOP: just loop and wait until state is changed ! } ! } ! } else { ! // perform the actual shutdown shutdownServants(wait_for_completion); + if (wait_for_completion) { + synchronized ( waitForCompletionObj ) { + while (numInvocations > 0) { + try { + waitForCompletionObj.wait(); + } catch (InterruptedException ex) {} + } + } + } + synchronized (runObj) { runObj.notifyAll(); } status = STATUS_SHUTDOWN; + + shutdownObj.notifyAll(); } } } ! // Cause all ObjectAdapaterFactories to clean up all of their internal state, which ! // may include activated objects that have associated state and callbacks that must ! // complete in order to shutdown. This will cause new request to be rejected. protected void shutdownServants(boolean wait_for_completion) { ! Set<ObjectAdapterFactory> oaset; ! synchronized (this) { ! oaset = new HashSet<>(requestDispatcherRegistry.getObjectAdapterFactories()); } + + for (ObjectAdapterFactory oaf : oaset) + oaf.shutdown(wait_for_completion); } // Note that the caller must hold the ORBImpl lock. public void checkShutdownState() { if (status == STATUS_DESTROYED) { throw wrapper.orbDestroyed() ;
*** 1325,1379 **** } } public boolean isDuringDispatch() { Boolean value = (Boolean)(isProcessingInvocation.get()) ; return value.booleanValue() ; } public void startingDispatch() { synchronized (invocationObj) { isProcessingInvocation.set(Boolean.TRUE); } } public void finishedDispatch() { synchronized (invocationObj) { ! isProcessingInvocation.set(Boolean.FALSE); } } /** * formal/99-10-07 p 159: "If destroy is called on an ORB that has * not been shut down, it will start the shutdown process and block until * the ORB has shut down before it destroys the ORB." */ ! public synchronized void destroy() { ! boolean shutdownFirst = false ; synchronized (this) { ! shutdownFirst = (status == STATUS_OPERATING) ; } if (shutdownFirst) { shutdown(true); } synchronized (this) { if (status < STATUS_DESTROYED) { getCorbaTransportManager().close(); ! getPIHandler().destroyInterceptors() ; status = STATUS_DESTROYED; } } } /** * Registers a value factory for a particular repository ID. * * @param repositoryID the repository ID. * @param factory the factory. --- 1335,1473 ---- } } public boolean isDuringDispatch() { + synchronized (this) { + checkShutdownState(); + } Boolean value = (Boolean)(isProcessingInvocation.get()) ; return value.booleanValue() ; } public void startingDispatch() { + synchronized (this) { + checkShutdownState(); + } synchronized (invocationObj) { isProcessingInvocation.set(Boolean.TRUE); + numInvocations++; } } public void finishedDispatch() { + synchronized (this) { + checkShutdownState(); + } synchronized (invocationObj) { ! numInvocations--; ! isProcessingInvocation.set(false); ! if (numInvocations == 0) { ! synchronized (waitForCompletionObj) { ! waitForCompletionObj.notifyAll(); } + } else if (numInvocations < 0) { + throw wrapper.numInvocationsAlreadyZero( + CompletionStatus.COMPLETED_YES); } + } + } /** * formal/99-10-07 p 159: "If destroy is called on an ORB that has * not been shut down, it will start the shutdown process and block until * the ORB has shut down before it destroys the ORB." */ ! public void destroy() { ! boolean shutdownFirst = false; synchronized (this) { ! shutdownFirst = (status == STATUS_OPERATING); } if (shutdownFirst) { shutdown(true); } synchronized (this) { if (status < STATUS_DESTROYED) { getCorbaTransportManager().close(); ! getPIHandler().destroyInterceptors(); status = STATUS_DESTROYED; } } + synchronized (threadPoolManagerAccessLock) { + if (orbOwnsThreadPoolManager) { + try { + threadpoolMgr.close(); + threadpoolMgr = null; + } catch (IOException exc) { + wrapper.ioExceptionOnClose(exc); + } + } + } + try { + monitoringManager.close(); + monitoringManager = null; + } catch (IOException exc) { + wrapper.ioExceptionOnClose(exc); } + CachedCodeBase.cleanCache(this); + try { + pihandler.close(); + } catch (IOException exc) { + wrapper.ioExceptionOnClose(exc); + } + + super.destroy(); + + badServerIdHandlerAccessLock = null; + clientDelegateFactoryAccessorLock = null; + corbaContactInfoListFactoryAccessLock = null; + + objectKeyFactoryAccessLock = null; + legacyServerSocketManagerAccessLock = null; + threadPoolManagerAccessLock = null; + transportManager = null; + legacyServerSocketManager = null; + OAInvocationInfoStack = null; + clientInvocationInfoStack = null; + codeBaseIOR = null; + dynamicRequests = null; + svResponseReceived = null; + runObj = null; + shutdownObj = null; + waitForCompletionObj = null; + invocationObj = null; + isProcessingInvocation = null; + typeCodeForClassMap = null; + valueFactoryCache = null; + orbVersionThreadLocal = null; + requestDispatcherRegistry = null; + copierManager = null; + toaFactory = null; + poaFactory = null; + pihandler = null; + configData = null; + badServerIdHandler = null; + clientDelegateFactory = null; + corbaContactInfoListFactory = null; + resolver = null; + localResolver = null; + insNamingDelegate = null; + urlOperation = null; + taggedComponentFactoryFinder = null; + taggedProfileFactoryFinder = null; + taggedProfileTemplateFactoryFinder = null; + objectKeyFactory = null; + } + /** * Registers a value factory for a particular repository ID. * * @param repositoryID the repository ID. * @param factory the factory.
*** 1432,1453 **** --- 1526,1556 ---- return factory ; } public OAInvocationInfo peekInvocationInfo() { + synchronized (this) { + checkShutdownState(); + } StackImpl stack = (StackImpl)(OAInvocationInfoStack.get()) ; return (OAInvocationInfo)(stack.peek()) ; } public void pushInvocationInfo( OAInvocationInfo info ) { + synchronized (this) { + checkShutdownState(); + } StackImpl stack = (StackImpl)(OAInvocationInfoStack.get()) ; stack.push( info ) ; } public OAInvocationInfo popInvocationInfo() { + synchronized (this) { + checkShutdownState(); + } StackImpl stack = (StackImpl)(OAInvocationInfoStack.get()) ; return (OAInvocationInfo)(stack.pop()) ; } /**
*** 1457,1466 **** --- 1560,1572 ---- private Object badServerIdHandlerAccessLock = new Object(); public void initBadServerIdHandler() { + synchronized (this) { + checkShutdownState(); + } synchronized (badServerIdHandlerAccessLock) { Class cls = configData.getBadServerIdHandler() ; if (cls != null) { try { Class[] params = new Class[] { org.omg.CORBA.ORB.class };
*** 1475,1491 **** --- 1581,1603 ---- } } public void setBadServerIdHandler( BadServerIdHandler handler ) { + synchronized (this) { + checkShutdownState(); + } synchronized (badServerIdHandlerAccessLock) { badServerIdHandler = handler; } } public void handleBadServerId( ObjectKey okey ) { + synchronized (this) { + checkShutdownState(); + } synchronized (badServerIdHandlerAccessLock) { if (badServerIdHandler == null) throw wrapper.badServerId() ; else badServerIdHandler.handle( okey ) ;
*** 1530,1553 **** --- 1642,1674 ---- } } public int getTransientServerId() { + synchronized (this) { + checkShutdownState(); + } if( configData.getORBServerIdPropertySpecified( ) ) { // ORBServerId is specified then use that value return configData.getPersistentServerId( ); } return transientServerId; } public RequestDispatcherRegistry getRequestDispatcherRegistry() { + synchronized (this) { + checkShutdownState(); + } return requestDispatcherRegistry; } public ServiceContextRegistry getServiceContextRegistry() { + synchronized (this) { + checkShutdownState(); + } return serviceContextRegistry ; } // XXX All of the isLocalXXX checking needs to be revisited. // First of all, all three of these methods are called from
*** 1561,1576 **** --- 1682,1703 ---- // LocalClientRequestDispatcher as well. Bottom line: this code needs to move. // XXX What about multi-homed host? public boolean isLocalHost( String hostName ) { + synchronized (this) { + checkShutdownState(); + } return hostName.equals( configData.getORBServerHost() ) || hostName.equals( getLocalHostName() ) ; } public boolean isLocalServerId( int subcontractId, int serverId ) { + synchronized (this) { + checkShutdownState(); + } if ((subcontractId < ORBConstants.FIRST_POA_SCID) || (subcontractId > ORBConstants.MAX_POA_SCID)) return serverId == getTransientServerId( ) ; // XXX isTransient info should be stored in subcontract registry
*** 1657,1666 **** --- 1784,1796 ---- // pept.broker.Broker // public ClientInvocationInfo createOrIncrementInvocationInfo() { + synchronized (this) { + checkShutdownState(); + } StackImpl invocationInfoStack = (StackImpl) clientInvocationInfoStack.get(); ClientInvocationInfo clientInvocationInfo = null; if (!invocationInfoStack.empty()) { clientInvocationInfo =
*** 1680,1693 **** return clientInvocationInfo; } public void releaseOrDecrementInvocationInfo() { ! StackImpl invocationInfoStack = ! (StackImpl)clientInvocationInfoStack.get(); int entryCount = -1; ClientInvocationInfo clientInvocationInfo = null; if (!invocationInfoStack.empty()) { clientInvocationInfo = (ClientInvocationInfo)invocationInfoStack.peek(); } else { throw wrapper.invocationInfoStackEmpty() ; --- 1810,1826 ---- return clientInvocationInfo; } public void releaseOrDecrementInvocationInfo() { ! synchronized (this) { ! checkShutdownState(); ! } int entryCount = -1; ClientInvocationInfo clientInvocationInfo = null; + StackImpl invocationInfoStack = + (StackImpl)clientInvocationInfoStack.get(); if (!invocationInfoStack.empty()) { clientInvocationInfo = (ClientInvocationInfo)invocationInfoStack.peek(); } else { throw wrapper.invocationInfoStackEmpty() ;
*** 1703,1712 **** --- 1836,1848 ---- } } public ClientInvocationInfo getInvocationInfo() { + synchronized (this) { + checkShutdownState(); + } StackImpl invocationInfoStack = (StackImpl) clientInvocationInfoStack.get(); return (ClientInvocationInfo) invocationInfoStack.peek(); }
*** 1717,1757 **** --- 1853,1906 ---- private Object clientDelegateFactoryAccessorLock = new Object(); public void setClientDelegateFactory( ClientDelegateFactory factory ) { + synchronized (this) { + checkShutdownState(); + } synchronized (clientDelegateFactoryAccessorLock) { clientDelegateFactory = factory ; } } public ClientDelegateFactory getClientDelegateFactory() { + synchronized (this) { + checkShutdownState(); + } synchronized (clientDelegateFactoryAccessorLock) { return clientDelegateFactory ; } } private Object corbaContactInfoListFactoryAccessLock = new Object(); public void setCorbaContactInfoListFactory( CorbaContactInfoListFactory factory ) { + synchronized (this) { + checkShutdownState(); + } synchronized (corbaContactInfoListFactoryAccessLock) { corbaContactInfoListFactory = factory ; } } public synchronized CorbaContactInfoListFactory getCorbaContactInfoListFactory() { + checkShutdownState(); return corbaContactInfoListFactory ; } /** Set the resolver used in this ORB. This resolver will be used for list_initial_services * and resolve_initial_references. */ public void setResolver( Resolver resolver ) { + synchronized (this) { + checkShutdownState(); + } synchronized (resolverLock) { this.resolver = resolver ; } }
*** 1758,1767 **** --- 1907,1919 ---- /** Get the resolver used in this ORB. This resolver will be used for list_initial_services * and resolve_initial_references. */ public Resolver getResolver() { + synchronized (this) { + checkShutdownState(); + } synchronized (resolverLock) { return resolver ; } }
*** 1768,1777 **** --- 1920,1932 ---- /** Set the LocalResolver used in this ORB. This LocalResolver is used for * register_initial_reference only. */ public void setLocalResolver( LocalResolver resolver ) { + synchronized (this) { + checkShutdownState(); + } synchronized (resolverLock) { this.localResolver = resolver ; } }
*** 1778,1787 **** --- 1933,1945 ---- /** Get the LocalResolver used in this ORB. This LocalResolver is used for * register_initial_reference only. */ public LocalResolver getLocalResolver() { + synchronized (this) { + checkShutdownState(); + } synchronized (resolverLock) { return localResolver ; } }
*** 1788,1797 **** --- 1946,1958 ---- /** Set the operation used in string_to_object calls. The Operation must expect a * String and return an org.omg.CORBA.Object. */ public void setURLOperation( Operation stringToObject ) { + synchronized (this) { + checkShutdownState(); + } synchronized (urlOperationLock) { urlOperation = stringToObject ; } }
*** 1798,1845 **** --- 1959,2027 ---- /** Get the operation used in string_to_object calls. The Operation must expect a * String and return an org.omg.CORBA.Object. */ public Operation getURLOperation() { + synchronized (this) { + checkShutdownState(); + } synchronized (urlOperationLock) { return urlOperation ; } } public void setINSDelegate( CorbaServerRequestDispatcher sdel ) { + synchronized (this) { + checkShutdownState(); + } synchronized (resolverLock) { insNamingDelegate = sdel ; } } public TaggedComponentFactoryFinder getTaggedComponentFactoryFinder() { + synchronized (this) { + checkShutdownState(); + } return taggedComponentFactoryFinder ; } public IdentifiableFactoryFinder getTaggedProfileFactoryFinder() { + synchronized (this) { + checkShutdownState(); + } return taggedProfileFactoryFinder ; } public IdentifiableFactoryFinder getTaggedProfileTemplateFactoryFinder() { + synchronized (this) { + checkShutdownState(); + } return taggedProfileTemplateFactoryFinder ; } private Object objectKeyFactoryAccessLock = new Object(); public ObjectKeyFactory getObjectKeyFactory() { + synchronized (this) { + checkShutdownState(); + } synchronized (objectKeyFactoryAccessLock) { return objectKeyFactory ; } } public void setObjectKeyFactory( ObjectKeyFactory factory ) { + synchronized (this) { + checkShutdownState(); + } synchronized (objectKeyFactoryAccessLock) { objectKeyFactory = factory ; } }
*** 1862,1871 **** --- 2044,2056 ---- private Object legacyServerSocketManagerAccessLock = new Object(); public LegacyServerSocketManager getLegacyServerSocketManager() { + synchronized (this) { + checkShutdownState(); + } synchronized (legacyServerSocketManagerAccessLock) { if (legacyServerSocketManager == null) { legacyServerSocketManager = new LegacyServerSocketManagerImpl(this); } return legacyServerSocketManager;
*** 1874,1900 **** private Object threadPoolManagerAccessLock = new Object(); public void setThreadPoolManager(ThreadPoolManager mgr) { synchronized (threadPoolManagerAccessLock) { threadpoolMgr = mgr; } } public ThreadPoolManager getThreadPoolManager() { synchronized (threadPoolManagerAccessLock) { if (threadpoolMgr == null) { ! threadpoolMgr = new ThreadPoolManagerImpl( threadGroup ); } return threadpoolMgr; } } public CopierManager getCopierManager() { return copierManager ; } } // Class ORBImpl //////////////////////////////////////////////////////////////////////// --- 2059,2095 ---- private Object threadPoolManagerAccessLock = new Object(); public void setThreadPoolManager(ThreadPoolManager mgr) { + synchronized (this) { + checkShutdownState(); + } synchronized (threadPoolManagerAccessLock) { threadpoolMgr = mgr; } } public ThreadPoolManager getThreadPoolManager() { + synchronized (this) { + checkShutdownState(); + } synchronized (threadPoolManagerAccessLock) { if (threadpoolMgr == null) { ! threadpoolMgr = new ThreadPoolManagerImpl(); ! orbOwnsThreadPoolManager = true; } return threadpoolMgr; } } public CopierManager getCopierManager() { + synchronized (this) { + checkShutdownState(); + } return copierManager ; } } // Class ORBImpl ////////////////////////////////////////////////////////////////////////