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

Util

public class Util extends Object
Provides utility methods that can be used by stubs and ties to perform common operations.

Fields Summary
private static javax.rmi.CORBA.UtilDelegate
utilDelegate
private static final String
UtilClassKey
private static final String
defaultUtilImplName
Constructors Summary
private Util()


     
	utilDelegate = (javax.rmi.CORBA.UtilDelegate)
	    createDelegateIfSpecified(UtilClassKey, defaultUtilImplName);
    
Methods Summary
public static java.lang.ObjectcopyObject(java.lang.Object obj, org.omg.CORBA.ORB orb)
Copies or connects an object. Used by local stubs to copy an actual parameter, result object, or exception.

param
obj the object to copy.
param
orb the ORB.
return
the copy or connected object.
exception
RemoteException if the object could not be copied or connected.


	if (utilDelegate != null) {
	    return utilDelegate.copyObject(obj, orb);
	}
	return null;
    
public static java.lang.Object[]copyObjects(java.lang.Object[] obj, org.omg.CORBA.ORB orb)
Copies or connects an array of objects. Used by local stubs to copy any number of actual parameters, preserving sharing across parameters as necessary to support RMI semantics.

param
obj the objects to copy or connect.
param
orb the ORB.
return
the copied or connected objects.
exception
RemoteException if any object could not be copied or connected.

    
	if (utilDelegate != null) {
	    return utilDelegate.copyObjects(obj, orb);
	}
	
        return null;
    
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 static ValueHandlercreateValueHandler()
Returns a singleton instance of a class that implements the {@link ValueHandler} interface.

return
a class which implements the ValueHandler interface.


	if (utilDelegate != null) {
	    return utilDelegate.createValueHandler();
	}
	return null;
    
public static java.lang.StringgetCodebase(java.lang.Class clz)
Returns the codebase, if any, for the given class.

param
clz the class to get a codebase for.
return
a space-separated list of URLs, or null.

	if (utilDelegate != null) {
	    return utilDelegate.getCodebase(clz);
	}
	return null;
    
private static java.util.PropertiesgetORBPropertiesFile()
Load the orb.properties file.

        return (Properties) AccessController.doPrivileged(
	    new GetORBPropertiesFileAction());
    
public static javax.rmi.CORBA.TiegetTie(java.rmi.Remote target)
Returns the tie (if any) for a given target object.

return
the tie or null if no tie is registered for the given target.


	if (utilDelegate != null) {
	    return utilDelegate.getTie(target);
	}
	return null;
    
public static booleanisLocal(Stub stub)
The isLocal method has the same semantics as the ObjectImpl._is_local method, except that it can throw a RemoteException. The _is_local() method is provided so that stubs may determine if a particular object is implemented by a local servant and hence local invocation APIs may be used.

param
stub the stub to test.
return
The _is_local() method returns true if the servant incarnating the object is located in the same process as the stub and they both share the same ORB instance. The _is_local() method returns false otherwise. The default behavior of _is_local() is to return false.
throws
RemoteException The Java to IDL specification does not specify the conditions that cause a RemoteException to be thrown.


	if (utilDelegate != null) {
	    return utilDelegate.isLocal(stub);
	}

	return false;
    
public static java.lang.ClassloadClass(java.lang.String className, java.lang.String remoteCodebase, java.lang.ClassLoader loader)
Returns a class instance for the specified class.

The spec for this method is the "Java to IDL language mapping", ptc/00-01-06.

In Java 2 Platform, this method works as follows:

  • Find the first non-null ClassLoader on the call stack and attempt to load the class using this ClassLoader.
  • If the first step fails, and if remoteCodebase is non-null and useCodebaseOnly is false, then call java.rmi.server.RMIClassLoader.loadClass(remoteCodebase, className).
  • If remoteCodebase is null or useCodebaseOnly is true, then call java.rmi.server.RMIClassLoader.loadClass(className).
  • If a class was not successfully loaded by step 1, 2, or 3, and loader is non-null, then call loader.loadClass(className).
  • If a class was successfully loaded by step 1, 2, 3, or 4, then return the loaded class, else throw ClassNotFoundException.

    param
    className the name of the class.
    param
    remoteCodebase a space-separated list of URLs at which the class might be found. May be null.
    param
    loader a ClassLoader that may be used to load the class if all other methods fail.
    return
    the Class object representing the loaded class.
    exception
    ClassNotFoundException if class cannot be loaded.

    	if (utilDelegate != null) {
    	    return utilDelegate.loadClass(className,remoteCodebase,loader);
    	}  
    	return null ;
        
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 ;
	}
    
public static java.rmi.RemoteExceptionmapSystemException(org.omg.CORBA.SystemException ex)
Maps a SystemException to a RemoteException.

param
ex the SystemException to map.
return
the mapped exception.

	
	if (utilDelegate != null) {
	    return utilDelegate.mapSystemException(ex);
	}
	return null;
    
public static java.lang.ObjectreadAny(org.omg.CORBA.portable.InputStream in)
Reads a java.lang.Object as a CORBA any.

param
in the stream from which to read the any.
return
the object read from the stream.


	if (utilDelegate != null) {
	    return utilDelegate.readAny(in);
	}
	return null;
    
public static voidregisterTarget(javax.rmi.CORBA.Tie tie, java.rmi.Remote target)
Registers a target for a tie. Adds the tie to an internal table and calls {@link Tie#setTarget} on the tie object.

param
tie the tie to register.
param
target the target for the tie.

        
	if (utilDelegate != null) {
	    utilDelegate.registerTarget(tie, target);
	}

    
public static voidunexportObject(java.rmi.Remote target)
Removes the associated tie from an internal table and calls {@link Tie#deactivate} to deactivate the object.

param
target the object to unexport.


	if (utilDelegate != null) {
	    utilDelegate.unexportObject(target);
	}

    
public static java.rmi.RemoteExceptionwrapException(java.lang.Throwable orig)
Wraps an exception thrown by an implementation method. It returns the corresponding client-side exception.

param
orig the exception to wrap.
return
the wrapped exception.


	if (utilDelegate != null) {
	    return utilDelegate.wrapException(orig);
	}

        return null;
    
public static voidwriteAbstractObject(org.omg.CORBA.portable.OutputStream out, java.lang.Object obj)
Writes a java.lang.Object as either a value or a CORBA Object. If obj is a value object or a stub object, it is written to out.write_abstract_interface(java.lang.Object). If obj is an exported RMI-IIOP server object, the tie is found and wired to obj, then written to out.write_abstract_interface(java.lang.Object).

param
out the stream in which to write the object.
param
obj the object to write.

                                                
	if (utilDelegate != null) {
	    utilDelegate.writeAbstractObject(out, obj);
	}
    
public static voidwriteAny(org.omg.CORBA.portable.OutputStream out, java.lang.Object obj)
Writes any java.lang.Object as a CORBA any.

param
out the stream in which to write the any.
param
obj the object to write as an any.


	if (utilDelegate != null) {
	    utilDelegate.writeAny(out, obj);
	}
    
public static voidwriteRemoteObject(org.omg.CORBA.portable.OutputStream out, java.lang.Object obj)
Writes a java.lang.Object as a CORBA Object. If obj is an exported RMI-IIOP server object, the tie is found and wired to obj, then written to out.write_Object(org.omg.CORBA.Object). If obj is a CORBA Object, it is written to out.write_Object(org.omg.CORBA.Object).

param
out the stream in which to write the object.
param
obj the object to write.

                                                
	if (utilDelegate != null) {
	    utilDelegate.writeRemoteObject(out, obj);
	}