FileDocCategorySizeDatePackage
Stub.javaAPI DocJava SE 5 API7438Fri Aug 26 14:57:46 BST 2005javax.rmi.CORBA

Stub

public abstract class Stub extends org.omg.CORBA_2_3.portable.ObjectImpl implements Serializable
Base class from which all RMI-IIOP stubs must inherit.

Fields Summary
private static final long
serialVersionUID
private transient StubDelegate
stubDelegate
private static Class
stubDelegateClass
private static final String
StubClassKey
private static final String
defaultStubImplName
Constructors Summary
Methods Summary
public voidconnect(org.omg.CORBA.ORB orb)
Connects this stub to an ORB. Required after the stub is deserialized but not after it is demarshalled by an ORB stream. If an unconnected stub is passed to an ORB stream for marshalling, it is implicitly connected to that ORB. Application code should not call this method directly, but should call the portable wrapper method {@link javax.rmi.PortableRemoteObject#connect}.

param
orb the ORB to connect to.
exception
RemoteException if the stub is already connected to a different ORB, or if the stub does not represent an exported remote or local object.

        
	if (stubDelegate == null) {
	    setDefaultDelegate();
	}

	if (stubDelegate != null) {
	    stubDelegate.connect(this, orb);
	}

    
private static java.lang.ObjectcreateDelegateIfSpecified(java.lang.String classKey, java.lang.String defaultClassName)

        String className = (String)
            AccessController.doPrivileged(new GetPropertyAction(classKey));
        if (className == null) {
            Properties props = getORBPropertiesFile();
            if (props != null) {
                className = props.getProperty(classKey);
            }
        }

	if (className == null) {
	    className = defaultClassName;
	}

        try {
            return loadDelegateClass(className).newInstance();
        } catch (ClassNotFoundException ex) {
	    INITIALIZE exc = new INITIALIZE( "Cannot instantiate " + className);
	    exc.initCause( ex ) ;
	    throw exc ;
        } catch (Exception ex) {
	    INITIALIZE exc = new INITIALIZE( "Error while instantiating" + className);
	    exc.initCause( ex ) ;
	    throw exc ;
        }

    
public booleanequals(java.lang.Object obj)
Compares two stubs for equality. Returns true when used to compare stubs that represent the same remote object, and false otherwise.

param
obj the reference object with which to compare.
return
true if this object is the same as the obj argument; false otherwise.


	if (stubDelegate == null) {
	    setDefaultDelegate();
	}

	if (stubDelegate != null) {
	    return stubDelegate.equals(this, obj);
	}

        return false;
    
private static java.util.PropertiesgetORBPropertiesFile()
Load the orb.properties file.

        return (Properties) AccessController.doPrivileged(new GetORBPropertiesFileAction());
    
public inthashCode()
Returns a hash code value for the object which is the same for all stubs that represent the same remote object.

return
the hash code value.


     
        Object stubDelegateInstance = (Object) createDelegateIfSpecified(StubClassKey, defaultStubImplName);
	if (stubDelegateInstance != null)
	    stubDelegateClass = stubDelegateInstance.getClass();
	
    

	if (stubDelegate == null) {
	    setDefaultDelegate();
	}

	if (stubDelegate != null) {
	    return stubDelegate.hashCode(this);
	}

	return 0;
    
private static java.lang.ClassloadDelegateClass(java.lang.String className)

	try {
	    ClassLoader loader = Thread.currentThread().getContextClassLoader();
	    return Class.forName(className, false, loader);
	} catch (ClassNotFoundException e) {
	    // ignore, then try RMIClassLoader
	}

	try {
	    return RMIClassLoader.loadClass(className);
	} catch (MalformedURLException e) {
	    String msg = "Could not load " + className + ": " + e.toString();
	    ClassNotFoundException exc = new ClassNotFoundException( msg ) ; 
	    throw exc ;
	}
    
private voidreadObject(java.io.ObjectInputStream stream)
Serialization method to restore the IOR state.


	if (stubDelegate == null) {
	    setDefaultDelegate();
	}

	if (stubDelegate != null) {
	    stubDelegate.readObject(this, stream);
	} 

    
private voidsetDefaultDelegate()

        if (stubDelegateClass != null) {
            try {
                 stubDelegate = (javax.rmi.CORBA.StubDelegate) stubDelegateClass.newInstance();
	    } catch (Exception ex) {
	    // what kind of exception to throw
	    // delegate not set therefore it is null and will return default
            // values
            }
 	}
    
public java.lang.StringtoString()
Returns a string representation of this stub. Returns the same string for all stubs that represent the same remote object.

return
a string representation of this stub.



	if (stubDelegate == null) {
	    setDefaultDelegate();
	}

	String ior;
	if (stubDelegate != null) {
	    ior = stubDelegate.toString(this);
	    if (ior == null) {
	        return super.toString();
	    } else {
	        return ior;
	    }
	}
        return super.toString();
    
private voidwriteObject(java.io.ObjectOutputStream stream)
Serialization method to save the IOR state.

serialData
The length of the IOR type ID (int), followed by the IOR type ID (byte array encoded using ISO8859-1), followed by the number of IOR profiles (int), followed by the IOR profiles. Each IOR profile is written as a profile tag (int), followed by the length of the profile data (int), followed by the profile data (byte array).


	if (stubDelegate == null) {
	    setDefaultDelegate();
	}

	if (stubDelegate != null) {
	    stubDelegate.writeObject(this, stream);
	}