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

📄 orbutility.java

📁 java1.6众多例子参考
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
				"org.omg.CORBA.INITIALIZE");	exceptionClassNames.put("IDL:omg.org/CORBA/PERSIST_STORE:1.0",				"org.omg.CORBA.PERSIST_STORE");	exceptionClassNames.put("IDL:omg.org/CORBA/TRANSIENT:1.0",				"org.omg.CORBA.TRANSIENT");	exceptionClassNames.put("IDL:omg.org/CORBA/UNKNOWN:1.0",				"org.omg.CORBA.UNKNOWN");	exceptionClassNames.put("IDL:omg.org/CORBA/OBJECT_NOT_EXIST:1.0",				"org.omg.CORBA.OBJECT_NOT_EXIST");	// SystemExceptions from OMG Transactions Service Spec	exceptionClassNames.put("IDL:omg.org/CORBA/INVALID_TRANSACTION:1.0",				"org.omg.CORBA.INVALID_TRANSACTION");	exceptionClassNames.put("IDL:omg.org/CORBA/TRANSACTION_REQUIRED:1.0",				"org.omg.CORBA.TRANSACTION_REQUIRED");	exceptionClassNames.put("IDL:omg.org/CORBA/TRANSACTION_ROLLEDBACK:1.0",				"org.omg.CORBA.TRANSACTION_ROLLEDBACK");	// from portability RTF 98-07-01.txt	exceptionClassNames.put("IDL:omg.org/CORBA/INV_POLICY:1.0",				"org.omg.CORBA.INV_POLICY");	// from orbrev/00-09-01 (CORBA 2.4 Draft Specification)	exceptionClassNames.	    put("IDL:omg.org/CORBA/TRANSACTION_UNAVAILABLE:1.0",				"org.omg.CORBA.TRANSACTION_UNAVAILABLE");	exceptionClassNames.put("IDL:omg.org/CORBA/TRANSACTION_MODE:1.0",				"org.omg.CORBA.TRANSACTION_MODE");        // Exception types introduced between CORBA 2.4 and 3.0        exceptionClassNames.put("IDL:omg.org/CORBA/CODESET_INCOMPATIBLE:1.0",                                "org.omg.CORBA.CODESET_INCOMPATIBLE");        exceptionClassNames.put("IDL:omg.org/CORBA/REBIND:1.0",                                "org.omg.CORBA.REBIND");        exceptionClassNames.put("IDL:omg.org/CORBA/TIMEOUT:1.0",                                "org.omg.CORBA.TIMEOUT");        exceptionClassNames.put("IDL:omg.org/CORBA/BAD_QOS:1.0",                                "org.omg.CORBA.BAD_QOS");                // Exception types introduced in CORBA 3.0        exceptionClassNames.put("IDL:omg.org/CORBA/INVALID_ACTIVITY:1.0",				"org.omg.CORBA.INVALID_ACTIVITY");        exceptionClassNames.put("IDL:omg.org/CORBA/ACTIVITY_COMPLETED:1.0",				"org.omg.CORBA.ACTIVITY_COMPLETED");        exceptionClassNames.put("IDL:omg.org/CORBA/ACTIVITY_REQUIRED:1.0",				"org.omg.CORBA.ACTIVITY_REQUIRED");        	//	// construct className -> repositoryId hashtable	//	Enumeration keys = exceptionClassNames.keys();	java.lang.Object s;	String rId;	String cName;	try{            while (keys.hasMoreElements()) {                s = keys.nextElement();	        rId = (String) s;	        cName = (String) exceptionClassNames.get(rId);	        exceptionRepositoryIds.put (cName, rId);	    }	} catch (NoSuchElementException e) { }    }    /** Parse a version string such as "1.1.6" or "jdk1.2fcs" into	a version array of integers {1, 1, 6} or {1, 2}.	A string of "n." or "n..m" is equivalent to "n.0" or "n.0.m" respectively.    */    public static int[] parseVersion(String version) {	if (version == null)	    return new int[0];	char[] s = version.toCharArray();	//find the maximum span of the string "n.n.n..." where n is an integer	int start = 0;	for (; start < s.length  && (s[start] < '0' || s[start] > '9'); ++start)	    if (start == s.length)	//no digit found		return new int[0];	int end = start + 1;	int size = 1;	for (; end < s.length; ++end)	    if (s[end] == '.')		++size;	    else if (s[end] < '0' || s[end] > '9')		break;	int[] val = new int[size];	for (int i = 0; i < size; ++i) {	    int dot = version.indexOf('.', start);	    if (dot == -1 || dot > end)		dot = end;	    if (start >= dot)	//cases like "n." or "n..m"		val[i] = 0;	//convert equivalent to "n.0" or "n.0.m"	    else		val[i] = Integer.parseInt(version.substring(start, dot));	    start = dot + 1;	}	return val;    }    /** Compare two version arrays.	Return 1, 0 or -1 if v1 is greater than, equal to, or less than v2.    */    public static int compareVersion(int[] v1, int[] v2) {	if (v1 == null)	    v1 = new int[0];	if (v2 == null)	    v2 = new int[0];	for (int i = 0; i < v1.length; ++i) {	    if (i >= v2.length || v1[i] > v2[i])	//v1 is longer or greater than v2		return 1;	    if (v1[i] < v2[i])		return -1;	}	return v1.length == v2.length ? 0 : -1;    }    /** Compare two version strings.	Return 1, 0 or -1 if v1 is greater than, equal to, or less than v2.    */    public static synchronized int compareVersion(String v1, String v2) {	return compareVersion(parseVersion(v1), parseVersion(v2));    }    private static String compressClassName( String name )    {	// Note that this must end in . in order to be renamed correctly.	String prefix = "com.sun.corba.se." ;	if (name.startsWith( prefix ) ) {	    return "(ORB)." + name.substring( prefix.length() ) ;	} else	    return name ;    }    // Return a compressed representation of the thread name.  This is particularly    // useful on the server side, where there are many SelectReaderThreads, and    // we need a short unambiguous name for such threads.    public static String getThreadName( Thread thr )     {	if (thr == null)	    return "null" ;	// This depends on the formatting in SelectReaderThread and CorbaConnectionImpl.	// Pattern for SelectReaderThreads:	// SelectReaderThread CorbaConnectionImpl[ <host> <post> <state>]	// Any other pattern in the Thread's name is just returned.	String name = thr.getName() ;	StringTokenizer st = new StringTokenizer( name ) ;	int numTokens = st.countTokens() ;	if (numTokens != 5)	    return name ;	String[] tokens = new String[numTokens] ;	for (int ctr=0; ctr<numTokens; ctr++ ) 	    tokens[ctr] = st.nextToken() ;	if( !tokens[0].equals("SelectReaderThread"))	    return name ;	return "SelectReaderThread[" + tokens[2] + ":" + tokens[3] + "]" ;    }    private static String formatStackTraceElement( StackTraceElement ste )     {        return compressClassName( ste.getClassName() ) + "." + ste.getMethodName() +            (ste.isNativeMethod() ? "(Native Method)" :             (ste.getFileName() != null && ste.getLineNumber() >= 0 ?              "(" + ste.getFileName() + ":" + ste.getLineNumber() + ")" :              (ste.getFileName() != null ?  "("+ste.getFileName()+")" : "(Unknown Source)")));    }    private static void printStackTrace( StackTraceElement[] trace )     {	System.out.println( "    Stack Trace:" ) ;	// print the stack trace, ommitting the zeroth element, which is	// always this method.	for ( int ctr = 1; ctr < trace.length; ctr++ ) {	    System.out.print( "        >" ) ;	    System.out.println( formatStackTraceElement( trace[ctr] ) ) ;	}    }    //    // Implements all dprint calls in this package.    //    public static synchronized void dprint(java.lang.Object obj, String msg) {	System.out.println(	    compressClassName( obj.getClass().getName() ) + "("  +	    getThreadName( Thread.currentThread() ) + "): " + msg);    }    public static synchronized void dprint(String className, String msg) {	System.out.println(	    compressClassName( className ) + "("  +	    getThreadName( Thread.currentThread() ) + "): " + msg);    }    public synchronized void dprint(String msg) {	ORBUtility.dprint(this, msg);    }    public static synchronized void dprintTrace(Object obj, String msg) {	ORBUtility.dprint(obj, msg);	Throwable thr = new Throwable() ;	printStackTrace( thr.getStackTrace() ) ;    }    public static synchronized void dprint(java.lang.Object caller, 	String msg, Throwable t)     {         System.out.println(	    compressClassName( caller.getClass().getName() ) + 	    '(' + Thread.currentThread() + "): " + msg);        if (t != null)	    printStackTrace( t.getStackTrace() ) ;    }    public static String[] concatenateStringArrays( String[] arr1, String[] arr2 )     {	String[] result = new String[ 	    arr1.length + arr2.length ] ;	for (int ctr = 0; ctr<arr1.length; ctr++)	    result[ctr] = arr1[ctr] ;	for (int ctr = 0; ctr<arr2.length; ctr++)	    result[ctr + arr1.length] = arr2[ctr] ;	return result ;    }    /**     * Throws the CORBA equivalent of a java.io.NotSerializableException     *     * Duplicated from util/Utility for Pure ORB reasons.  There are two     * reasons for this:     *     * 1) We can't introduce dependencies on the util version from outside     * of the io/util packages since it will not exist in the pure ORB     * build running on JDK 1.3.x.     *     * 2) We need to pick up the correct minor code from OMGSystemException.     */    public static void throwNotSerializableForCorba(String className) {	throw omgWrapper.notSerializable( CompletionStatus.COMPLETED_MAYBE,	    className ) ;    }    /**     * Returns the maximum stream format version supported by our     * ValueHandler.     */    public static byte getMaxStreamFormatVersion() {        ValueHandler vh = Util.createValueHandler();        if (!(vh instanceof javax.rmi.CORBA.ValueHandlerMultiFormat))            return ORBConstants.STREAM_FORMAT_VERSION_1;        else            return ((ValueHandlerMultiFormat)vh).getMaximumStreamFormatVersion();    }        public static CorbaClientDelegate makeClientDelegate( IOR ior )    {	ORB orb = ior.getORB() ;	CorbaContactInfoList ccil = orb.getCorbaContactInfoListFactory().create( ior ) ;	CorbaClientDelegate del = orb.getClientDelegateFactory().create(ccil);	return del ;    }    /** This method is used to create untyped object references.    */    public static org.omg.CORBA.Object makeObjectReference( IOR ior )	    {	CorbaClientDelegate del = makeClientDelegate( ior ) ;	org.omg.CORBA.Object objectImpl = new CORBAObjectImpl() ;	StubAdapter.setDelegate( objectImpl, del ) ;	return objectImpl ;    }    /** This method obtains an IOR from a CORBA object reference.    * It will return null if obj is a local object, a null object,    * or an object implemented by a different ORB.  It will    * throw BAD_OPERATION if obj is an unconnected RMI-IIOP object.    * @return IOR the IOR that represents this objref.  This will    * never be null.    * @exception BAD_OPERATION (from oi._get_delegate) if obj is a    * normal objref, but does not have a delegate set.    * @exception BAD_PARAM if obj is a local object, or else was    * created by a foreign ORB.    */    public static IOR getIOR( org.omg.CORBA.Object obj )     {	if (obj == null)	    throw wrapper.nullObjectReference() ;	IOR ior = null ;	if (StubAdapter.isStub(obj)) {	    org.omg.CORBA.portable.Delegate del = StubAdapter.getDelegate( 		obj ) ;	    if (del instanceof CorbaClientDelegate) {		CorbaClientDelegate cdel = (CorbaClientDelegate)del ;		ContactInfoList cil = cdel.getContactInfoList() ;		if (cil instanceof CorbaContactInfoList) {		    CorbaContactInfoList ccil = (CorbaContactInfoList)cil ;		    ior = ccil.getTargetIOR() ;		    if (ior == null)			throw wrapper.nullIor() ;		    return ior ;		} else {		    // This is our code, but the ContactInfoList is not a 		    // CorbaContactInfoList.  This should not happen, because		    // we are in the CORBA application of the DCSA framework.		    // This is a coding error, and thus an INTERNAL exception		    // should be thrown.		    // XXX needs minor code		    throw new INTERNAL() ;		}	    } 	    // obj is implemented by a foreign ORB, because the Delegate is not a	    // ClientDelegate.	    // XXX this case could be handled by marshalling and	    // unmarshalling.  However, object_to_string cannot be used	    // here, as it is implemented with getIOR.  Note that this	    // will require access to an ORB, so that we can create streams	    // as needed.  The ORB is available simply as io._orb().	    throw wrapper.objrefFromForeignOrb() ;	} else	    throw wrapper.localObjectNotAllowed() ;    }    /** Obtains an IOR for the object reference obj, first connecting it to    * the ORB if necessary.    * @return IOR the IOR that represents this objref.  This will    * never be null.    * @exception BAD_OPERATION if the object could not be connected,     * if a connection attempt was needed.    * @exception BAD_PARAM if obj is a local object, or else was    * created by a foreign ORB.    */    public static IOR connectAndGetIOR( ORB orb, org.omg.CORBA.Object obj )    {	IOR result ;	try {	    result = getIOR( obj ) ;	} catch (BAD_OPERATION bop) {	    if (StubAdapter.isStub(obj)) {		try {		    StubAdapter.connect( obj, orb ) ;		} catch (java.rmi.RemoteException exc) {		    throw wrapper.connectingServant( exc ) ;		}	    } else {		orb.connect( obj ) ;	    }	    result = getIOR( obj ) ;	}    	return result ;    }    public static String operationNameAndRequestId(CorbaMessageMediator m)    {	return "op/" + m.getOperationName() + " id/" + m.getRequestId();    }    public static boolean isPrintable(char c)    {	if (Character.isJavaIdentifierStart(c)) {	    // Letters and $ _	    return true;	}	if (Character.isDigit(c)) {	    return true;	}	switch (Character.getType(c)) {	case Character.MODIFIER_SYMBOL : return true; // ` ^	case Character.DASH_PUNCTUATION : return true; // -	case Character.MATH_SYMBOL : return true; // = ~ + | < >	case Character.OTHER_PUNCTUATION : return true; // !@#%&*;':",./?	case Character.START_PUNCTUATION : return true; // ( [ {	case Character.END_PUNCTUATION : return true; // ) ] }	}	return false;    }    public static String getClassSecurityInfo(final Class cl)    {	// Returns a String which looks similar to:	// PermissionCollection java.security.Permissions@1053693 ... 	// (java.io.FilePermission <<ALL FILES>> ....)	// (java.io.FilePermission /export0/sunwappserv/lib/- ...)	// ... other permissions ...	// Domain ProtectionDomain  (file:/export0/sunwappserv/lib-)	// java.security.Permissions@141fedb (	// (java.io.FilePermission <<ALL FILES>> ...)	// (java.io.FilePermission /var/tmp//- ...)	String result =	    (String)AccessController.doPrivileged(new PrivilegedAction() {	        public java.lang.Object run() {		    StringBuffer sb = new StringBuffer(500);		    ProtectionDomain pd = cl.getProtectionDomain();                    Policy policy = Policy.getPolicy();	            PermissionCollection pc = policy.getPermissions(pd);	            sb.append("\nPermissionCollection ");	            sb.append(pc.toString());		    // Don't need to add 'Protection Domain' string, it's		    // in ProtectionDomain.toString() already.	            sb.append(pd.toString());                    return sb.toString();		}            });	return result;    }}// End of file.

⌨️ 快捷键说明

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