⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 orbimpl.java

📁 JAVA 所有包
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
/* @(#)ORBImpl.java	1.69 06/08/12 * * Copyright 2006 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<args.length; ctr++ ) {            String token = args[ctr] ;            // If there is a public boolean data member in this class            // named token + "DebugFlag", set it to true.            try {                Field fld = this.getClass().getField( token + "DebugFlag" ) ;                int mod = fld.getModifiers() ;                if (Modifier.isPublic( mod ) && !Modifier.isStatic( mod ))                    if (fld.getType() == boolean.class)                        fld.setBoolean( this, true ) ;            } catch (Exception exc) {                // ignore it XXX log this as info            }        }    }    // Class that defines a parser that gets the name of the    // ORBConfigurator class.    private static class ConfigParser extends ParserImplBase {	// The default here is the ORBConfiguratorImpl that we define,	// but this can be replaced.	public Class configurator = ORBConfiguratorImpl.class ;	public PropertyParser makeParser()	{	    PropertyParser parser = new PropertyParser() ;	    parser.add( ORBConstants.SUN_PREFIX + "ORBConfigurator",		OperationFactory.classAction(), "configurator" ) ;	    return parser ;	}    }    private void postInit( String[] params, DataCollector dataCollector )    {	// First, create the standard ORB config data.	// This must be initialized before the ORBConfigurator	// is executed.	configData = new ORBDataParserImpl( this, dataCollector) ;	// Set the debug flags early so they can be used by other	// parts of the initialization.	setDebugFlags( configData.getORBDebugFlags() ) ;	// REVISIT: this should go away after more transport init cleanup	// and going to ORT based ORBD.  	getTransportManager();	getLegacyServerSocketManager();	// Create a parser to get the configured ORBConfigurator.	ConfigParser parser = new ConfigParser() ;	parser.init( dataCollector ) ;	ORBConfigurator configurator =  null ;	try {	    configurator = 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -