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

📄 utility.java

📁 java1.6众多例子参考
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
                } catch( Exception e ) {                    // Exception is caught because of any of the                     // following reasons                    // 1) POA is not associated with the TIE                     // 2) POA Policies for the tie-associated POA                    //    does not support _this_object() call. 		    throw wrapper.noPoa( e ) ;                }            }            // Update the cache...            entry = new StubEntry(stub,onlyMostDerived);            tieToStubCache.put(tie,entry);        }                     return entry;    }                                       /*     * If we loadStub(Tie,...) stashed away a tie which was     * not connected, remove it from the cache and return     * it.     */    public static Tie getAndForgetTie (org.omg.CORBA.Object stub) {        synchronized (stubToTieCache) {            return (Tie) stubToTieCache.remove(stub);        }    }        /*     * Remove any cached Stub for the given tie.     */    public static void purgeStubForTie (Tie tie) {        StubEntry entry;        synchronized (tieToStubCache) {            entry = (StubEntry)tieToStubCache.remove(tie);        }	if (entry != null) {            synchronized (stubToTieCache) {                stubToTieCache.remove(entry.stub);            }	}    }        /*     * Remove cached tie/servant pair.     */    public static void purgeTieAndServant (Tie tie) {	synchronized (tieCache) {	    Object target = tie.getTarget();	    if (target != null)		tieCache.remove(target);	}    }    /*     * Convert a RepId to a stubName...     */    public static String stubNameFromRepID (String repID) {                // Convert the typeid to a RepositoryId instance, get        // the className and mangle it as needed...        RepositoryId id = RepositoryId.cache.getId(repID);        String className = id.getClassName();                if (id.isIDLType()) {            className = idlStubName(className);        } else {            className = stubName(className);        }        return className;    }          /*     * Load an RMI-IIOP Stub.  This is used in PortableRemoteObject.narrow.     */    public static Remote loadStub (org.omg.CORBA.Object narrowFrom,                                   Class narrowTo)     {        Remote result = null;            	try {            // Get the codebase from the delegate to use when loading            // the new stub, if possible...            String codebase = null;            try {                // We can't assume that narrowFrom is a CORBA_2_3 stub, yet                // it may have a 2_3 Delegate that provides a codebase.  Swallow                // the ClassCastException otherwise.		Delegate delegate = StubAdapter.getDelegate( narrowFrom ) ;                codebase = ((org.omg.CORBA_2_3.portable.Delegate)delegate).		    get_codebase(narrowFrom);            } catch (ClassCastException e) {		wrapper.classCastExceptionInLoadStub( e ) ;            }	    PresentationManager.StubFactoryFactory sff = 		com.sun.corba.se.spi.orb.ORB.getStubFactoryFactory() ;	    PresentationManager.StubFactory sf = sff.createStubFactory( 		narrowTo.getName(), false, codebase, narrowTo, 		narrowTo.getClassLoader() ) ;	    result = (Remote)sf.makeStub() ;	    StubAdapter.setDelegate( result, 		StubAdapter.getDelegate( narrowFrom ) ) ;        } catch (Exception err) {	    wrapper.exceptionInLoadStub( err ) ;        }                return result;    }            /*     * Load an RMI-IIOP Stub class.  This is used in the      * StaticStubFactoryFactory code.     */    public static Class loadStubClass(String repID,                                      String remoteCodebase,				      Class expectedType) 	throws ClassNotFoundException     {	                                            // Get the repID and check for "" special case.        // We should never be called with it (See CDRInputStream        // and the loadStub() method)...                if (repID.length() == 0) {            throw new ClassNotFoundException();           }                // Get the stubname from the repID and load        // the class. If we have a valid 'sender', fall        // back to using its codebase if we need to...        String className = Utility.stubNameFromRepID(repID);        ClassLoader expectedTypeClassLoader = (expectedType == null ? null : 	    expectedType.getClassLoader());        try {              return loadClassOfType(className,                                       remoteCodebase,                                       expectedTypeClassLoader,                                       expectedType,                                       expectedTypeClassLoader);        } catch (ClassNotFoundException e) {	    return loadClassOfType(PackagePrefixChecker.packagePrefix() + className,                                   remoteCodebase,                                   expectedTypeClassLoader,                                   expectedType,                                   expectedTypeClassLoader);        }    }    /**     * Create an RMI stub name.     */    public static String stubName (String className)     {	return stubName( className, false ) ;    }    public static String dynamicStubName( String className )    {	return stubName( className, true ) ;    }    private static String stubName( String className,	boolean isDynamic )     {	String name = stubNameForCompiler( className, isDynamic ) ;	if (PackagePrefixChecker.hasOffendingPrefix( name ))	    name = PackagePrefixChecker.packagePrefix() + name ;	return name ;    }    public static String stubNameForCompiler (String className)     {	return stubNameForCompiler( className, false ) ;    }    private static String stubNameForCompiler( String className, 	boolean isDynamic )    {        int index = className.indexOf('$');        if (index < 0) {            index = className.lastIndexOf('.');        }	String suffix = isDynamic ? DYNAMIC_STUB_SUFFIX : 	    RMI_STUB_SUFFIX ;            if (index > 0) {            return className.substring(0,index+1) + STUB_PREFIX + 		className.substring(index+1) + suffix;        } else {            return STUB_PREFIX + className + suffix;        }    }    /**     * Create an RMI tie name.     */    public static String tieName (String className)     {        return            PackagePrefixChecker.hasOffendingPrefix(tieNameForCompiler(className)) ?            PackagePrefixChecker.packagePrefix() + tieNameForCompiler(className) :            tieNameForCompiler(className);    }    public static String tieNameForCompiler (String className)     {        int index = className.indexOf('$');        if (index < 0) {            index = className.lastIndexOf('.');        }        if (index > 0) {            return className.substring(0,index+1) +		STUB_PREFIX +		className.substring(index+1) +		TIE_SUFIX;        } else {            return STUB_PREFIX +		className +		TIE_SUFIX;        }    }    /**     * Throws the CORBA equivalent of a java.io.NotSerializableException     */    public static void throwNotSerializableForCorba(String className) {	throw omgWrapper.notSerializable( CompletionStatus.COMPLETED_MAYBE, 	    className ) ;    }    /**     * Create an IDL stub name.     */    public static String idlStubName(String className)     {        String result = null;        int index = className.lastIndexOf('.');        if (index > 0) {            result = className.substring(0,index+1) + 		STUB_PREFIX +		className.substring(index+1) + 		IDL_STUB_SUFFIX;        } else {            result = STUB_PREFIX +		className +		IDL_STUB_SUFFIX;        }        return result;    }        public static void printStackTrace()     {	Throwable thr = new Throwable( "Printing stack trace:" ) ;	thr.fillInStackTrace() ;	thr.printStackTrace() ;    }    /**     * Read an object reference from the input stream and narrow     * it to the desired type.     * @param in the stream to read from.     * @throws ClassCastException if narrowFrom cannot be cast to narrowTo.     */    public static Object readObjectAndNarrow(InputStream in,                                             Class narrowTo)	throws ClassCastException     {        Object result = in.read_Object();	if (result != null)             return PortableRemoteObject.narrow(result, narrowTo);	else	    return null;    }    /**     * Read an abstract interface type from the input stream and narrow     * it to the desired type.     * @param in the stream to read from.     * @throws ClassCastException if narrowFrom cannot be cast to narrowTo.     */    public static Object readAbstractAndNarrow(	org.omg.CORBA_2_3.portable.InputStream in, Class narrowTo)	throws ClassCastException     {        Object result = in.read_abstract_interface();	if (result != null)             return PortableRemoteObject.narrow(result, narrowTo);	else	    return null;    }    /** Converts an Ascii Character into Hexadecimal digit     */    static int hexOf( char x )    {	int val;        val = x - '0';        if (val >=0 && val <= 9)            return val;        val = (x - 'a') + 10;        if (val >= 10 && val <= 15)            return val;        val = (x - 'A') + 10;        if (val >= 10 && val <= 15)            return val;	throw wrapper.badHexDigit() ;    }}class StubEntry {    org.omg.CORBA.Object stub;    boolean mostDerived;        StubEntry(org.omg.CORBA.Object stub, boolean mostDerived) {        this.stub = stub;        this.mostDerived = mostDerived;    }}

⌨️ 快捷键说明

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