orb.java
来自「java jdk 1.4的源码」· Java 代码 · 共 1,939 行 · 第 1/5 页
JAVA
1,939 行
/* * @(#)ORB.java 1.264 03/01/23 * * Copyright 2003 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. *//* * Licensed Materials - Property of IBM * RMI-IIOP v1.0 * Copyright IBM Corp. 1998 1999 All Rights Reserved * * US Government Users Restricted Rights - Use, duplication or * disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */package com.sun.corba.se.internal.corba;// Import JDK stuffimport java.net.*;import java.util.*;import java.applet.Applet;import java.lang.reflect.Constructor;import java.lang.reflect.Field ;import java.lang.reflect.Modifier ;import java.lang.ThreadLocal;import java.io.File ;import java.io.IOException ;import java.io.FileInputStream ;import java.io.FileNotFoundException ;// Import our stuffimport org.omg.CORBA.COMM_FAILURE;import org.omg.CORBA.DATA_CONVERSION;import org.omg.CORBA.INITIALIZE;import org.omg.CORBA.NO_IMPLEMENT;import org.omg.CORBA.INTERNAL;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.Object;import org.omg.CORBA.Request;import org.omg.CORBA.OBJ_ADAPTER;import org.omg.CORBA.OBJECT_NOT_EXIST;import org.omg.CORBA.INV_OBJREF;import org.omg.CORBA.MARSHAL;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.BAD_INV_ORDER;import org.omg.CORBA.portable.*;import org.omg.CORBA.portable.RemarshalException;import org.omg.CORBA.portable.ValueFactory;import org.omg.PortableServer.Servant;import com.sun.corba.se.connection.ORBSocketFactory;import com.sun.corba.se.internal.core.CodeSetComponentInfo;import com.sun.corba.se.internal.core.ClientSubcontract;import com.sun.corba.se.internal.core.ClientResponse;import com.sun.corba.se.internal.core.ClientRequest;import com.sun.corba.se.internal.iiop.Connection;import com.sun.corba.se.internal.ior.IIOPProfile;import com.sun.corba.se.internal.core.ServerSubcontract;import com.sun.corba.se.internal.core.ServiceContexts;import com.sun.corba.se.internal.core.SubcontractRegistry;import com.sun.corba.se.internal.core.ClientGIOP;import com.sun.corba.se.internal.core.ServerGIOP;import com.sun.corba.se.internal.core.ServerRequest;import com.sun.corba.se.internal.core.MarshalInputStream;import com.sun.corba.se.internal.core.MarshalOutputStream;import com.sun.corba.se.internal.core.InternalRuntimeForwardRequest;import com.sun.corba.se.internal.core.IOR;import com.sun.corba.se.internal.core.Future;import com.sun.corba.se.internal.core.Closure;import com.sun.corba.se.internal.core.Constant;import com.sun.corba.se.internal.core.GIOPVersion;import com.sun.corba.se.internal.core.ORBVersion;import com.sun.corba.se.internal.core.ORBVersionFactory;import com.sun.corba.se.internal.core.INSObjectKeyMap;import com.sun.corba.se.internal.core.INSObjectKeyEntry;import com.sun.corba.se.internal.core.StandardIIOPProfileTemplate;import com.sun.corba.se.internal.util.Utility;import com.sun.corba.se.internal.orbutil.ORBUtility;import com.sun.corba.se.internal.orbutil.ORBClassLoader;import com.sun.corba.se.internal.orbutil.ORBConstants;import com.sun.corba.se.internal.orbutil.ORBUtility;import com.sun.corba.se.internal.orbutil.MinorCodes;import com.sun.corba.se.internal.orbutil.SubcontractList;import com.sun.corba.se.internal.iiop.DefaultSocketFactory;import com.sun.corba.se.internal.iiop.messages.ReplyMessage;import com.sun.corba.se.internal.iiop.messages.KeyAddr;import com.sun.corba.se.internal.iiop.messages.ProfileAddr;import com.sun.corba.se.internal.iiop.messages.ReferenceAddr;import com.sun.corba.se.internal.ior.IIOPProfileTemplate;import com.sun.corba.se.internal.ior.IIOPAddress ;import com.sun.corba.se.internal.ior.IIOPAddressImpl ;import com.sun.corba.se.internal.ior.ObjectKey ;import com.sun.corba.se.internal.ior.ObjectKeyFactory ;import com.sun.corba.se.internal.ior.ObjectId;import com.sun.corba.se.internal.DynamicAny.DynAnyFactoryImpl;import com.sun.corba.se.internal.ior.ObjectKeyTemplate ;import java.security.AccessController;import java.security.PrivilegedAction;import sun.security.action.GetPropertyAction;import javax.rmi.CORBA.Util;import javax.rmi.CORBA.ValueHandler;import com.sun.org.omg.SendingContext.CodeBase;import com.sun.org.omg.SendingContext.CodeBaseHelper;/** * The JavaIDL ORB implementation. */public abstract class ORB extends com.sun.corba.se.internal.core.ORB implements TypeCodeFactory{ //d11638; pure java orb, caching the servant IOR per ORB private static IOR ior = null; protected void dprint( String msg ) { ORBUtility.dprint( this, msg ) ; } // Flag set at compile time to debug flag processing: this can't // be one of the xxxDebugFlags because it is used to debug the mechanism // that sets the xxxDebugFlags! public static boolean ORBInitDebug = false; // Currently defined debug flags. Any additions must be called xxxDebugFlag. // All debug flags must be public boolean types. // These are set by passing the flag -ORBDebug x,y,z in the ORB init args. // Note that x,y,z must not contain spaces. public boolean transportDebugFlag = false ; public boolean subcontractDebugFlag = false ; public boolean poaDebugFlag = false ; public boolean orbdDebugFlag = false ; public boolean namingDebugFlag = false ; public boolean serviceContextDebugFlag = false ; public boolean transientObjectManagerDebugFlag = false ; public boolean giopVersionDebugFlag = false; // public boolean iiopConnectionDebugFlag = false; public boolean shutdownDebugFlag = false; public boolean giopDebugFlag = false; private static final String[] JavaIDLPropertyNames = { ORBConstants.INITIAL_HOST_PROPERTY, ORBConstants.INITIAL_PORT_PROPERTY, ORBConstants.INITIAL_SERVICES_PROPERTY, ORBConstants.DEFAULT_INIT_REF_PROPERTY, ORBConstants.ORB_INIT_REF_PROPERTY, ORBConstants.SERVER_PORT_PROPERTY, ORBConstants.SERVER_HOST_PROPERTY, ORBConstants.ORB_ID_PROPERTY, ORBConstants.DEBUG_PROPERTY, ORBConstants.HIGH_WATER_MARK_PROPERTY, ORBConstants.LOW_WATER_MARK_PROPERTY, ORBConstants.NUMBER_TO_RECLAIM_PROPERTY, ORBConstants.SOCKET_FACTORY_CLASS_PROPERTY, ORBConstants.LISTEN_SOCKET_PROPERTY, //Temporary way of installing a version of GIOP on an ORB. //Can be beautified later. ORBConstants.GIOP_VERSION, ORBConstants.GIOP_FRAGMENT_SIZE, ORBConstants.GIOP_BUFFER_SIZE, ORBConstants.GIOP_11_BUFFMGR, ORBConstants.GIOP_12_BUFFMGR, ORBConstants.GIOP_TARGET_ADDRESSING, ORBConstants.ALWAYS_SEND_CODESET_CTX_PROPERTY, ORBConstants.USE_BOMS, ORBConstants.USE_BOMS_IN_ENCAPS, ORBConstants.CHAR_CODESETS, ORBConstants.WCHAR_CODESETS, ORBConstants.ALLOW_LOCAL_OPTIMIZATION }; private static final String[] JavaIDLPropertyNamePrefixes = { // Intentionally blank; }; private static final String[] JavaIDLURLPropertyNames = { ORBConstants.INITIAL_SERVICES_PROPERTY }; // // The following fields form our special little collection of global state. // We keep it bottled up here in the ORB class and attach a reference to // ourselves to every object reference that we create and handle. // // Vector holding deferred Requests private Vector _dynamicRequests; protected SynchVariable _svResponseReceived; // Applet/command-line parameters protected String ORBInitialHost = ""; protected int ORBInitialPort; protected String ORBServerHost = ""; protected int ORBServerPort = 0; protected String appletHost = ""; protected URL appletCodeBase = null; protected ORBSocketFactory socketFactory; protected String orbId = ""; public boolean allowLocalOptimization = false ; private Collection userSpecifiedListenPorts = new Vector(); //Connection management parameters protected int highWaterMark = 240; protected int lowWaterMark = 100; protected int numberToReclaim = 5; // GIOP Related Constants // Default is 1.0. We will change it to 1.2 later. protected GIOPVersion giopVersion = GIOPVersion.DEFAULT_VERSION; protected int giopFragmentSize = ORBConstants.GIOP_DEFAULT_FRAGMENT_SIZE; protected int giopBufferSize = ORBConstants.GIOP_DEFAULT_BUFFER_SIZE; protected int giop11BuffMgr = ORBConstants.DEFAULT_GIOP_11_BUFFMGR; protected int giop12BuffMgr = ORBConstants.DEFAULT_GIOP_12_BUFFMGR; protected short giopTargetAddressPreference = ORBConstants.ADDR_DISP_HANDLE_ALL; protected short giopAddressDisposition = KeyAddr.value; // Synchronization variable for shutdown 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 java.lang.Object invocationObj = new java.lang.Object(); private int numInvocations = 0; protected static final byte STATUS_OPERATING = 1; protected static final byte STATUS_SHUTTING_DOWN = 2; protected static final byte STATUS_SHUTDOWN = 3; protected static final byte STATUS_DESTROYED = 4; byte status = STATUS_OPERATING; // thread local variable to store a boolean to detect deadlock in ORB.shutdown(true). protected ThreadLocal isProcessingInvocation = new ThreadLocal () { protected java.lang.Object initialValue() { return Boolean.FALSE; } }; // Code set related protected boolean useByteOrderMarkers = ORBConstants.DEFAULT_USE_BYTE_ORDER_MARKERS; protected boolean useByteOrderMarkersInEncaps = ORBConstants.DEFAULT_USE_BYTE_ORDER_MARKERS_IN_ENCAPS; // Preferred native and conversion code sets for use with connections. Can // override or change with appropriate properties. protected CodeSetComponentInfo codesets = CodeSetComponentInfo.JAVASOFT_DEFAULT_CODESETS; protected boolean alwaysSendCodeSetCtx = ORBConstants.DEFAULT_ALWAYS_SEND_CODESET_CTX; InitialNamingClient initialNamingClient; DynAnyFactoryImpl dynAnyFactory = null; // This map is needed for resolving recursive type code placeholders // based on the unique repository id. private Map typeCodeMap = null; // This map is caching TypeCodes created for a certain class (key) // and is used in Util.writeAny() private Map typeCodeForClassMap = null; private String savedId = null; private TypeCodeImpl savedCode = null; // Cache to hold ValueFactories (Helper classes) keyed on repository ids protected Hashtable valueFactoryCache = new Hashtable(); // thread local variable to store the current ORB version private ThreadLocal orbVersionThreadLocal ; // Table used for all locally registered services. // This is used for register/resolve/list initial methods. // This table maps Strings to Closures. The evaluate method // of the Closure must return a CORBA.Object. private HashMap initialReferenceTable ; /** * Create a new ORB. Should only be invoked from the * CORBA ORB superclass. Should be followed by the appropriate * set_parameters() call. */ public ORB() { _dynamicRequests = new Vector(); _svResponseReceived = new SynchVariable(); initialNamingClient = new InitialNamingClient(this); initialReferenceTable = new HashMap() ; // default ORB version is the version of ORB with correct Rep-id // changes orbVersionThreadLocal = new ThreadLocal () { protected java.lang.Object initialValue() { // set default to version of the ORB with correct Rep-ids return ORBVersionFactory.getORBVersion() ; } }; // Register the Dynamic Any factory Closure closure = new Closure() { public java.lang.Object evaluate() { return new DynAnyFactoryImpl( ORB.this ) ; } } ; Future future = new Future( closure ) ; registerInitialReference( ORBConstants.DYN_ANY_FACTORY_NAME, future ) ; } public InitialNamingClient getInitialNamingClient( ) { return initialNamingClient; } public ORBVersion getORBVersion() { // return the thread local data return (ORBVersion)(orbVersionThreadLocal.get()) ; } public void setORBVersion(ORBVersion verObj) { // set the thread local data orbVersionThreadLocal.set(verObj); } /** * Should the client send the code set service context on every * request? */ public boolean alwaysSendCodeSetServiceContext() { return alwaysSendCodeSetCtx; } /** * Use byte order markers when applicable during character conversion? */ public boolean useByteOrderMarkers() { return useByteOrderMarkers; } /** * Use byte order markers even in encapsulations? */ public boolean useByteOrderMarkersInEncapsulations() { return useByteOrderMarkersInEncaps; } /** * Get the prefered code sets for connections. */ public CodeSetComponentInfo getCodeSetComponentInfo() { return codesets; } /**************************************************************************** * The following methods deal with parsing parameters and doing appropriate * initialization. ****************************************************************************/ /** * Initialize any necessary ORB state; get attributes if possible. * Called from org.omg.CORBA.ORB.init(). * @param app the applet * @param props the applet properties */ protected void set_parameters(Applet app, Properties props) { // Note: In some applet-development frameworks // the applet object may not be directly available and so it's
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?