Package javax.rmi.CORBA
Class Util
- java.lang.Object
-
- javax.rmi.CORBA.Util
-
public class Util extends java.lang.ObjectProvides utility methods that can be used by stubs and ties to perform common operations.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringdefaultUtilImplNameprivate static java.lang.StringUtilClassKeyprivate static UtilDelegateutilDelegate
-
Constructor Summary
Constructors Modifier Constructor Description privateUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.ObjectcopyObject(java.lang.Object obj, ORB orb)Copies or connects an object.static java.lang.Object[]copyObjects(java.lang.Object[] obj, ORB orb)Copies or connects an array of objects.private static java.lang.ObjectcreateDelegateIfSpecified(java.lang.String classKey, java.lang.String defaultClassName)static ValueHandlercreateValueHandler()Returns a singleton instance of a class that implements theValueHandlerinterface.static java.lang.StringgetCodebase(java.lang.Class clz)Returns the codebase, if any, for the given class.private static java.util.PropertiesgetORBPropertiesFile()Load the orb.properties file.static TiegetTie(java.rmi.Remote target)Returns the tie (if any) for a given target object.private static voidisCustomSerializationPermitted()static booleanisLocal(Stub stub)The isLocal method has the same semantics as the ObjectImpl._is_local method, except that it can throw a RemoteException.static java.lang.ClassloadClass(java.lang.String className, java.lang.String remoteCodebase, java.lang.ClassLoader loader)Returns a class instance for the specified class.private static java.lang.ClassloadDelegateClass(java.lang.String className)static java.rmi.RemoteExceptionmapSystemException(SystemException ex)Maps a SystemException to a RemoteException.static java.lang.ObjectreadAny(InputStream in)Reads a java.lang.Object as a CORBA any.static voidregisterTarget(Tie tie, java.rmi.Remote target)Registers a target for a tie.static voidunexportObject(java.rmi.Remote target)Removes the associated tie from an internal table and callsTie.deactivate()to deactivate the object.static java.rmi.RemoteExceptionwrapException(java.lang.Throwable orig)Wraps an exception thrown by an implementation method.static voidwriteAbstractObject(OutputStream out, java.lang.Object obj)Writes a java.lang.Object as either a value or a CORBA Object.static voidwriteAny(OutputStream out, java.lang.Object obj)Writes any java.lang.Object as a CORBA any.static voidwriteRemoteObject(OutputStream out, java.lang.Object obj)Writes a java.lang.Object as a CORBA Object.
-
-
-
Field Detail
-
utilDelegate
private static UtilDelegate utilDelegate
-
UtilClassKey
private static final java.lang.String UtilClassKey
- See Also:
- Constant Field Values
-
defaultUtilImplName
private static final java.lang.String defaultUtilImplName
- See Also:
- Constant Field Values
-
-
Method Detail
-
mapSystemException
public static java.rmi.RemoteException mapSystemException(SystemException ex)
Maps a SystemException to a RemoteException.- Parameters:
ex- the SystemException to map.- Returns:
- the mapped exception.
-
writeAny
public static void writeAny(OutputStream out, java.lang.Object obj)
Writes any java.lang.Object as a CORBA any.- Parameters:
out- the stream in which to write the any.obj- the object to write as an any.
-
readAny
public static java.lang.Object readAny(InputStream in)
Reads a java.lang.Object as a CORBA any.- Parameters:
in- the stream from which to read the any.- Returns:
- the object read from the stream.
-
writeRemoteObject
public static void writeRemoteObject(OutputStream out, java.lang.Object obj)
Writes a java.lang.Object as a CORBA Object. Ifobjis an exported RMI-IIOP server object, the tie is found and wired toobj, then written toout.write_Object(org.omg.CORBA.Object). Ifobjis a CORBA Object, it is written toout.write_Object(org.omg.CORBA.Object).- Parameters:
out- the stream in which to write the object.obj- the object to write.
-
writeAbstractObject
public static void writeAbstractObject(OutputStream out, java.lang.Object obj)
Writes a java.lang.Object as either a value or a CORBA Object. Ifobjis a value object or a stub object, it is written toout.write_abstract_interface(java.lang.Object). Ifobjis an exported RMI-IIOP server object, the tie is found and wired toobj, then written toout.write_abstract_interface(java.lang.Object).- Parameters:
out- the stream in which to write the object.obj- the object to write.
-
registerTarget
public static void registerTarget(Tie tie, java.rmi.Remote target)
Registers a target for a tie. Adds the tie to an internal table and callsTie.setTarget(java.rmi.Remote)on the tie object.- Parameters:
tie- the tie to register.target- the target for the tie.
-
unexportObject
public static void unexportObject(java.rmi.Remote target) throws java.rmi.NoSuchObjectExceptionRemoves the associated tie from an internal table and callsTie.deactivate()to deactivate the object.- Parameters:
target- the object to unexport.- Throws:
java.rmi.NoSuchObjectException- if the target object does not exist
-
getTie
public static Tie getTie(java.rmi.Remote target)
Returns the tie (if any) for a given target object.- Parameters:
target- the Remote to get the Tie for- Returns:
- the tie or null if no tie is registered for the given target.
-
createValueHandler
public static ValueHandler createValueHandler()
Returns a singleton instance of a class that implements theValueHandlerinterface.- Returns:
- a class which implements the ValueHandler interface.
-
getCodebase
public static java.lang.String getCodebase(java.lang.Class clz)
Returns the codebase, if any, for the given class.- Parameters:
clz- the class to get a codebase for.- Returns:
- a space-separated list of URLs, or null.
-
loadClass
public static java.lang.Class loadClass(java.lang.String className, java.lang.String remoteCodebase, java.lang.ClassLoader loader) throws java.lang.ClassNotFoundExceptionReturns 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 SE 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.
- Parameters:
className- the name of the class.remoteCodebase- a space-separated list of URLs at which the class might be found. May be null.loader- a ClassLoader that may be used to load the class if all other methods fail.- Returns:
- the
Classobject representing the loaded class. - Throws:
java.lang.ClassNotFoundException- if class cannot be loaded.
-
isLocal
public static boolean isLocal(Stub stub) throws java.rmi.RemoteException
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.- Parameters:
stub- the stub to test.- Returns:
- 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:
java.rmi.RemoteException- The Java to IDL specification does not specify the conditions that cause a RemoteException to be thrown.
-
wrapException
public static java.rmi.RemoteException wrapException(java.lang.Throwable orig)
Wraps an exception thrown by an implementation method. It returns the corresponding client-side exception.- Parameters:
orig- the exception to wrap.- Returns:
- the wrapped exception.
-
copyObjects
public static java.lang.Object[] copyObjects(java.lang.Object[] obj, ORB orb) throws java.rmi.RemoteExceptionCopies 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.- Parameters:
obj- the objects to copy or connect.orb- the ORB.- Returns:
- the copied or connected objects.
- Throws:
java.rmi.RemoteException- if any object could not be copied or connected.
-
copyObject
public static java.lang.Object copyObject(java.lang.Object obj, ORB orb) throws java.rmi.RemoteExceptionCopies or connects an object. Used by local stubs to copy an actual parameter, result object, or exception.- Parameters:
obj- the object to copy.orb- the ORB.- Returns:
- the copy or connected object.
- Throws:
java.rmi.RemoteException- if the object could not be copied or connected.
-
createDelegateIfSpecified
private static java.lang.Object createDelegateIfSpecified(java.lang.String classKey, java.lang.String defaultClassName)
-
loadDelegateClass
private static java.lang.Class loadDelegateClass(java.lang.String className) throws java.lang.ClassNotFoundException- Throws:
java.lang.ClassNotFoundException
-
getORBPropertiesFile
private static java.util.Properties getORBPropertiesFile()
Load the orb.properties file.
-
isCustomSerializationPermitted
private static void isCustomSerializationPermitted()
-
-