/* @(#)ORBImpl.java 1.68 06/01/03 * * Copyright 2004 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ 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; import org.omg.CORBA.ContextList; import org.omg.CORBA.Environment; import org.omg.CORBA.ExceptionList; import org.omg.CORBA.ORBPackage.InvalidName; import org.omg.CORBA.NVList; import org.omg.CORBA.TCKind; import org.omg.CORBA.NamedValue; import org.omg.CORBA.Request; import org.omg.CORBA.SystemException; import org.omg.CORBA.CompletionStatus; import org.omg.CORBA.TypeCode; import org.omg.CORBA.Any; import org.omg.CORBA.StructMember; import org.omg.CORBA.UnionMember; import org.omg.CORBA.ValueMember; import org.omg.CORBA.BAD_PARAM; import org.omg.CORBA.MARSHAL; import org.omg.CORBA.portable.ValueFactory; 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; import com.sun.corba.se.spi.orb.ORBData; import com.sun.corba.se.spi.orb.ORBConfigurator; import com.sun.corba.se.spi.orb.ParserImplBase; import com.sun.corba.se.spi.orb.PropertyParser; import com.sun.corba.se.spi.orb.OperationFactory; import com.sun.corba.se.spi.orb.ORBVersion; import com.sun.corba.se.spi.orb.ORBVersionFactory; import com.sun.corba.se.spi.orbutil.closure.ClosureFactory; import com.sun.corba.se.spi.orbutil.threadpool.ThreadPoolManager; import com.sun.corba.se.spi.protocol.ClientDelegateFactory; import com.sun.corba.se.spi.protocol.RequestDispatcherRegistry; import com.sun.corba.se.spi.protocol.CorbaServerRequestDispatcher; import com.sun.corba.se.spi.protocol.RequestDispatcherDefault; import com.sun.corba.se.spi.protocol.PIHandler; import com.sun.corba.se.spi.protocol.CorbaMessageMediator; import com.sun.corba.se.spi.protocol.ForwardException; import com.sun.corba.se.spi.resolver.Resolver; import com.sun.corba.se.spi.resolver.LocalResolver; 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; import com.sun.corba.se.impl.corba.ExceptionListImpl; import com.sun.corba.se.impl.corba.ContextListImpl; import com.sun.corba.se.impl.corba.NamedValueImpl; import com.sun.corba.se.impl.corba.EnvironmentImpl; 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.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; import com.sun.corba.se.impl.oa.toa.TOAFactory; import com.sun.corba.se.impl.oa.poa.BadServerIdHandler; import com.sun.corba.se.impl.oa.poa.DelegateImpl; import com.sun.corba.se.impl.oa.poa.POAFactory; import com.sun.corba.se.impl.orbutil.ORBClassLoader; import com.sun.corba.se.impl.orbutil.ORBConstants; import com.sun.corba.se.impl.orbutil.ORBUtility; import com.sun.corba.se.impl.orbutil.StackImpl; import com.sun.corba.se.impl.orbutil.threadpool.ThreadPoolImpl; import com.sun.corba.se.impl.orbutil.threadpool.ThreadPoolManagerImpl; import com.sun.corba.se.impl.protocol.RequestDispatcherRegistryImpl; import com.sun.corba.se.impl.protocol.CorbaInvocationInfo; import com.sun.corba.se.impl.transport.CorbaTransportManagerImpl; import com.sun.corba.se.impl.legacy.connection.LegacyServerSocketManagerImpl; import com.sun.corba.se.impl.util.Utility; import com.sun.corba.se.impl.logging.ORBUtilSystemException; import com.sun.corba.se.impl.copyobject.CopierManagerImpl; import com.sun.corba.se.impl.presentation.rmi.PresentationManagerImpl; /** * The JavaIDL ORB implementation. */ public class ORBImpl extends com.sun.corba.se.spi.orb.ORB { protected TransportManager transportManager; protected LegacyServerSocketManager legacyServerSocketManager; private ThreadLocal OAInvocationInfoStack ; private ThreadLocal clientInvocationInfoStack ; // pure java orb, caching the servant IOR per ORB private static IOR codeBaseIOR ; // Vector holding deferred Requests 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() { return Boolean.FALSE; } }; // This map is caching TypeCodes created for a certain class (key) // and is used in Util.writeAny() private Map typeCodeForClassMap ; // Cache to hold ValueFactories (Helper classes) keyed on repository ids private Hashtable valueFactoryCache = new Hashtable(); // thread local variable to store the current ORB version. // default ORB version is the version of ORB with correct Rep-id // changes private ThreadLocal orbVersionThreadLocal ; private RequestDispatcherRegistry requestDispatcherRegistry ; private CopierManager copierManager ; private int transientServerId ; private ThreadGroup threadGroup ; private ServiceContextRegistry serviceContextRegistry ; // Needed here to implement connect/disconnect private TOAFactory toaFactory ; // Needed here for set_delegate private POAFactory poaFactory ; // The interceptor handler, which provides portable interceptor services for // subcontracts and object adapters. private PIHandler pihandler ; private ORBData configData ; private BadServerIdHandler badServerIdHandler ; private ClientDelegateFactory clientDelegateFactory ; private CorbaContactInfoListFactory corbaContactInfoListFactory ; // All access to resolver, localResolver, and urlOperation must be protected using // resolverLock. Do not hold the ORBImpl lock while accessing // resolver, or deadlocks may occur. private Object resolverLock ; // Used for resolver_initial_references and list_initial_services private Resolver resolver ; // Used for register_initial_references private LocalResolver localResolver ; // Converts strings to object references for resolvers and string_to_object private Operation urlOperation ; private CorbaServerRequestDispatcher insNamingDelegate ; private TaggedComponentFactoryFinder taggedComponentFactoryFinder ; private IdentifiableFactoryFinder taggedProfileFactoryFinder ; private IdentifiableFactoryFinder taggedProfileTemplateFactoryFinder ; private ObjectKeyFactory objectKeyFactory ; private ThreadPoolManager threadpoolMgr; private void dprint( String msg ) { ORBUtility.dprint( this, msg ) ; } //////////////////////////////////////////////////// // // NOTE: // // Methods that are synchronized MUST stay synchronized. // // Methods that are NOT synchronized must stay that way to avoid deadlock. // // // REVISIT: // // checkShutDownState - lock on different object - and normalize usage. // starting/FinishDispatch and Shutdown // public ORBData getORBData() { return configData ; } public PIHandler getPIHandler() { return pihandler ; } /** * Create a new ORB. Should be followed by the appropriate * set_parameters() call. */ public ORBImpl() { // All initialization is done through set_parameters(). } public ORBVersion getORBVersion() { return (ORBVersion)(orbVersionThreadLocal.get()) ; } public void setORBVersion(ORBVersion verObj) { orbVersionThreadLocal.set(verObj); } /**************************************************************************** * The following methods are ORB initialization ****************************************************************************/ // preInit initializes all non-pluggable ORB data that is independent // of the property parsing. private void preInit( String[] params, Properties props ) { // Before ORBConfiguration we need to set a PINoOpHandlerImpl, // because PersisentServer Initialization inside configurator will // invoke orb.resolve_initial_references( ) which will result in a // check on piHandler to invoke Interceptors. We do not want any // 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 // of having the same transientServerId. This may result in collision // and may be a problem in ior.isLocal() check to see if the object // belongs to the current ORB. This problem is taken care of by checking // to see if the IOR port matches ORB server port in legacyIsLocalServerPort() // method. // // XXX need to move server ID to a string for CORBA 3.0. At that point, // make this more unique (possibly use java.rmi.server.UID). transientServerId = (int)System.currentTimeMillis(); orbVersionThreadLocal = new ThreadLocal () { protected java.lang.Object initialValue() { // set default to version of the ORB with correct Rep-ids return ORBVersionFactory.getORBVersion() ; } }; resolverLock = new java.lang.Object() ; requestDispatcherRegistry = new RequestDispatcherRegistryImpl( this, ORBConstants.DEFAULT_SCID); copierManager = new CopierManagerImpl( this ) ; taggedComponentFactoryFinder = new TaggedComponentFactoryFinderImpl(this) ; taggedProfileFactoryFinder = new TaggedProfileFactoryFinderImpl(this) ; taggedProfileTemplateFactoryFinder = new TaggedProfileTemplateFactoryFinderImpl(this) ; dynamicRequests = new Vector(); svResponseReceived = new SynchVariable(); OAInvocationInfoStack = new ThreadLocal () { protected java.lang.Object initialValue() { return new StackImpl(); } }; clientInvocationInfoStack = new ThreadLocal() { protected java.lang.Object initialValue() { return new StackImpl(); } }; serviceContextRegistry = new ServiceContextRegistry( this ) ; } protected void setDebugFlags( String[] args ) { for (int ctr=0; ctr"Y", and an * object, YY, then a subsequent call to * ORB.resolve_initial_references( "Y" ) will * return object YY. * * @param id The ID by which the initial reference will be known. * @param obj The initial reference itself. * @throws InvalidName if this operation is called with an empty string id * or this operation is called with an id that is already registered, * including the default names defined by OMG. * @throws BAD_PARAM if the obj parameter is null. */ public void register_initial_reference( String id, org.omg.CORBA.Object obj ) throws InvalidName { CorbaServerRequestDispatcher insnd ; if ((id == null) || (id.length() == 0)) throw new InvalidName() ; synchronized (this) { checkShutdownState(); } synchronized (resolverLock) { insnd = insNamingDelegate ; java.lang.Object obj2 = localResolver.resolve( id ) ; if (obj2 != null) throw new InvalidName(id + " already registered") ; localResolver.register( id, ClosureFactory.makeConstant( obj )) ; } synchronized (this) { if (StubAdapter.isStub(obj)) // Make all remote object references available for INS. requestDispatcherRegistry.registerServerRequestDispatcher( insnd, id ) ; } } /**************************************************************************** * The following methods (introduced in POA / CORBA2.1) deal with * shutdown / single threading. ****************************************************************************/ public void run() { synchronized (this) { checkShutdownState(); } synchronized (runObj) { try { runObj.wait(); } catch ( InterruptedException ex ) {} } } public void shutdown(boolean wait_for_completion) { synchronized (this) { checkShutdownState(); } // Avoid more than one thread performing shutdown at a time. synchronized (shutdownObj) { checkShutdownState(); // This is to avoid deadlock if (wait_for_completion && isProcessingInvocation.get() == Boolean.TRUE) { throw omgWrapper.shutdownWaitForCompletionDeadlock() ; } status = STATUS_SHUTTING_DOWN; // XXX access to requestDispatcherRegistry should be protected // by the ORBImpl instance monitor, but is not here in the // shutdownServants call. 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; } } /** 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() ; } if (status == STATUS_SHUTDOWN) { throw omgWrapper.badOperationAfterShutdown() ; } } public boolean isDuringDispatch() { Boolean value = (Boolean)(isProcessingInvocation.get()) ; return value.booleanValue() ; } public void startingDispatch() { synchronized (invocationObj) { isProcessingInvocation.set(Boolean.TRUE); numInvocations++; } } public void finishedDispatch() { synchronized (invocationObj) { numInvocations--; isProcessingInvocation.set(Boolean.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 synchronized void destroy() { if (status == STATUS_OPERATING) { shutdown(true); } 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. * @return the previously registered factory for the given repository ID, * or null if no such factory was previously registered. * @exception org.omg.CORBA.BAD_PARAM if the registration fails. **/ public synchronized ValueFactory register_value_factory(String repositoryID, ValueFactory factory) { checkShutdownState(); if ((repositoryID == null) || (factory == null)) throw omgWrapper.unableRegisterValueFactory() ; return (ValueFactory)valueFactoryCache.put(repositoryID, factory); } /** * Unregisters a value factory for a particular repository ID. * * @param repositoryID the repository ID. **/ public synchronized void unregister_value_factory(String repositoryID) { checkShutdownState(); if (valueFactoryCache.remove(repositoryID) == null) throw wrapper.nullParam() ; } /** * Finds and returns a value factory for the given repository ID. * The value factory returned was previously registered by a call to * {@link #register_value_factory} or is the default factory. * * @param repositoryID the repository ID. * @return the value factory. * @exception org.omg.CORBA.BAD_PARAM if unable to locate a factory. **/ public synchronized ValueFactory lookup_value_factory(String repositoryID) { checkShutdownState(); ValueFactory factory = (ValueFactory)valueFactoryCache.get(repositoryID); if (factory == null) { try { factory = Utility.getFactory(null, null, null, repositoryID); } catch(org.omg.CORBA.MARSHAL ex) { throw wrapper.unableFindValueFactory( ex ) ; } } return factory ; } public OAInvocationInfo peekInvocationInfo() { StackImpl stack = (StackImpl)(OAInvocationInfoStack.get()) ; return (OAInvocationInfo)(stack.peek()) ; } public void pushInvocationInfo( OAInvocationInfo info ) { StackImpl stack = (StackImpl)(OAInvocationInfoStack.get()) ; stack.push( info ) ; } public OAInvocationInfo popInvocationInfo() { StackImpl stack = (StackImpl)(OAInvocationInfoStack.get()) ; return (OAInvocationInfo)(stack.pop()) ; } /** * The bad server id handler is used by the Locator to * send back the location of a persistant server to the client. */ private Object badServerIdHandlerAccessLock = new Object(); public void initBadServerIdHandler() { synchronized (badServerIdHandlerAccessLock) { Class cls = configData.getBadServerIdHandler() ; if (cls != null) { try { Class[] params = new Class[] { org.omg.CORBA.ORB.class }; java.lang.Object[] args = new java.lang.Object[]{this}; Constructor cons = cls.getConstructor(params); badServerIdHandler = (BadServerIdHandler) cons.newInstance(args); } catch (Exception e) { throw wrapper.errorInitBadserveridhandler( e ) ; } } } } public void setBadServerIdHandler( BadServerIdHandler handler ) { synchronized (badServerIdHandlerAccessLock) { badServerIdHandler = handler; } } public void handleBadServerId( ObjectKey okey ) { synchronized (badServerIdHandlerAccessLock) { if (badServerIdHandler == null) throw wrapper.badServerId() ; else badServerIdHandler.handle( okey ) ; } } public synchronized org.omg.CORBA.Policy create_policy( int type, org.omg.CORBA.Any val ) throws org.omg.CORBA.PolicyError { checkShutdownState() ; return pihandler.create_policy( type, val ) ; } /** This is the implementation of the public API used to connect * a servant-skeleton to the ORB. */ public synchronized void connect(org.omg.CORBA.Object servant) { checkShutdownState(); if (getTOAFactory() == null) throw wrapper.noToa() ; try { String codebase = javax.rmi.CORBA.Util.getCodebase( servant.getClass() ) ; getTOAFactory().getTOA( codebase ).connect( servant ) ; } catch ( Exception ex ) { throw wrapper.orbConnectError( ex ) ; } } public synchronized void disconnect(org.omg.CORBA.Object obj) { checkShutdownState(); if (getTOAFactory() == null) throw wrapper.noToa() ; try { getTOAFactory().getTOA().disconnect( obj ) ; } catch ( Exception ex ) { throw wrapper.orbConnectError( ex ) ; } } public int getTransientServerId() { if( configData.getORBServerIdPropertySpecified( ) ) { // ORBServerId is specified then use that value return configData.getPersistentServerId( ); } return transientServerId; } public RequestDispatcherRegistry getRequestDispatcherRegistry() { return requestDispatcherRegistry; } public ServiceContextRegistry getServiceContextRegistry() { return serviceContextRegistry ; } // XXX All of the isLocalXXX checking needs to be revisited. // First of all, all three of these methods are called from // only one place in impl.ior.IORImpl. Second, we have problems // both with multi-homed hosts and with multi-profile IORs. // A possible strategy: like the LocalClientRequestDispatcher, we need // to determine this more abstractly at the ContactInfo level. // This level should probably just get the CorbaContactInfoList from // the IOR, then iterator over ContactInfo. If any ContactInfo is // local, the IOR is local, and we can pick one to create the // LocalClientRequestDispatcher as well. Bottom line: this code needs to move. // XXX What about multi-homed host? public boolean isLocalHost( String hostName ) { return hostName.equals( configData.getORBServerHost() ) || hostName.equals( getLocalHostName() ) ; } public boolean isLocalServerId( int subcontractId, int serverId ) { if ((subcontractId < ORBConstants.FIRST_POA_SCID) || (subcontractId > ORBConstants.MAX_POA_SCID)) return serverId == getTransientServerId( ) ; // XXX isTransient info should be stored in subcontract registry if (ORBConstants.isTransient( subcontractId )) return (serverId == getTransientServerId()) ; else if (configData.getPersistentServerIdInitialized()) return (serverId == configData.getPersistentServerId()) ; else return false ; } /************************************************************************* * The following public methods are for ORB shutdown. *************************************************************************/ private String getHostName(String host) throws java.net.UnknownHostException { return InetAddress.getByName( host ).getHostAddress(); } /* keeping a copy of the getLocalHostName so that it can only be called * internally and the unauthorized clients cannot have access to the * localHost information, originally, the above code was calling * getLocalHostName from Connection.java. If the hostname is cached in * Connection.java, then * it is a security hole, since any unauthorized client has access to * the host information. With this change it is used internally so the * security problem is resolved. Also in Connection.java, the * getLocalHost() implementation has changed to always call the * InetAddress.getLocalHost().getHostAddress() * The above mentioned method has been removed from the connection class */ private static String localHostString = null; private synchronized String getLocalHostName() { if (localHostString == null) { try { localHostString = InetAddress.getLocalHost().getHostAddress(); } catch (Exception ex) { throw wrapper.getLocalHostFailed( ex ) ; } } return localHostString ; } /****************************************************************************** * The following public methods are for ORB shutdown. * ******************************************************************************/ /** This method always returns false because the ORB never needs the * main thread to do work. */ public synchronized boolean work_pending() { checkShutdownState(); throw wrapper.genericNoImpl() ; } /** This method does nothing. It is not required by the spec to do anything! */ public synchronized void perform_work() { checkShutdownState(); throw wrapper.genericNoImpl() ; } public synchronized void set_delegate(java.lang.Object servant){ checkShutdownState(); POAFactory poaFactory = getPOAFactory() ; if (poaFactory != null) ((org.omg.PortableServer.Servant)servant) ._set_delegate( poaFactory.getDelegateImpl() ) ; else throw wrapper.noPoa() ; } //////////////////////////////////////////////////// // // pept.broker.Broker // public ClientInvocationInfo createOrIncrementInvocationInfo() { StackImpl invocationInfoStack = (StackImpl) clientInvocationInfoStack.get(); ClientInvocationInfo clientInvocationInfo = null; if (!invocationInfoStack.empty()) { clientInvocationInfo = (ClientInvocationInfo) invocationInfoStack.peek(); } if ((clientInvocationInfo == null) || (!clientInvocationInfo.isRetryInvocation())) { // This is a new call - not a retry. clientInvocationInfo = new CorbaInvocationInfo(this); startingDispatch(); invocationInfoStack.push(clientInvocationInfo); } // Reset retry so recursive calls will get a new info object. clientInvocationInfo.setIsRetryInvocation(false); clientInvocationInfo.incrementEntryCount(); return clientInvocationInfo; } public void releaseOrDecrementInvocationInfo() { StackImpl invocationInfoStack = (StackImpl)clientInvocationInfoStack.get(); ClientInvocationInfo clientInvocationInfo = null; if (!invocationInfoStack.empty()) { clientInvocationInfo = (ClientInvocationInfo)invocationInfoStack.peek(); } else { throw wrapper.invocationInfoStackEmpty() ; } clientInvocationInfo.decrementEntryCount(); if (clientInvocationInfo.getEntryCount() == 0) { invocationInfoStack.pop(); finishedDispatch(); } } public ClientInvocationInfo getInvocationInfo() { StackImpl invocationInfoStack = (StackImpl) clientInvocationInfoStack.get(); return (ClientInvocationInfo) invocationInfoStack.peek(); } //////////////////////////////////////////////////// // // // private Object clientDelegateFactoryAccessorLock = new Object(); public void setClientDelegateFactory( ClientDelegateFactory factory ) { synchronized (clientDelegateFactoryAccessorLock) { clientDelegateFactory = factory ; } } public ClientDelegateFactory getClientDelegateFactory() { synchronized (clientDelegateFactoryAccessorLock) { return clientDelegateFactory ; } } private Object corbaContactInfoListFactoryAccessLock = new Object(); public void setCorbaContactInfoListFactory( CorbaContactInfoListFactory factory ) { synchronized (corbaContactInfoListFactoryAccessLock) { corbaContactInfoListFactory = factory ; } } public synchronized CorbaContactInfoListFactory getCorbaContactInfoListFactory() { 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 (resolverLock) { this.resolver = resolver ; } } /** Get the resolver used in this ORB. This resolver will be used for list_initial_services * and resolve_initial_references. */ public Resolver getResolver() { synchronized (resolverLock) { return resolver ; } } /** Set the LocalResolver used in this ORB. This LocalResolver is used for * register_initial_reference only. */ public void setLocalResolver( LocalResolver resolver ) { synchronized (resolverLock) { this.localResolver = resolver ; } } /** Get the LocalResolver used in this ORB. This LocalResolver is used for * register_initial_reference only. */ public LocalResolver getLocalResolver() { synchronized (resolverLock) { return localResolver ; } } /** 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 (resolverLock) { urlOperation = stringToObject ; } } /** 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 (resolverLock) { return urlOperation ; } } public void setINSDelegate( CorbaServerRequestDispatcher sdel ) { synchronized (resolverLock) { insNamingDelegate = sdel ; } } public TaggedComponentFactoryFinder getTaggedComponentFactoryFinder() { return taggedComponentFactoryFinder ; } public IdentifiableFactoryFinder getTaggedProfileFactoryFinder() { return taggedProfileFactoryFinder ; } public IdentifiableFactoryFinder getTaggedProfileTemplateFactoryFinder() { return taggedProfileTemplateFactoryFinder ; } private Object objectKeyFactoryAccessLock = new Object(); public ObjectKeyFactory getObjectKeyFactory() { synchronized (objectKeyFactoryAccessLock) { return objectKeyFactory ; } } public void setObjectKeyFactory( ObjectKeyFactory factory ) { synchronized (objectKeyFactoryAccessLock) { objectKeyFactory = factory ; } } private Object transportManagerAccessorLock = new Object(); public TransportManager getTransportManager() { synchronized (transportManagerAccessorLock) { if (transportManager == null) { transportManager = new CorbaTransportManagerImpl(this); } return transportManager; } } public CorbaTransportManager getCorbaTransportManager() { return (CorbaTransportManager) getTransportManager(); } private Object legacyServerSocketManagerAccessLock = new Object(); public LegacyServerSocketManager getLegacyServerSocketManager() { synchronized (legacyServerSocketManagerAccessLock) { if (legacyServerSocketManager == null) { legacyServerSocketManager = new LegacyServerSocketManagerImpl(this); } return legacyServerSocketManager; } } 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 //////////////////////////////////////////////////////////////////////// /// Helper class for a Synchronization Variable //////////////////////////////////////////////////////////////////////// class SynchVariable { // Synchronization Variable public boolean _flag; // Constructor SynchVariable() { _flag = false; } // set Flag to true public void set() { _flag = true; } // get value public boolean value() { return _flag; } // reset Flag to true public void reset() { _flag = false; } } // End of file.