Class Util
java.lang.Object
com.sun.corba.ee.impl.javax.rmi.CORBA.Util
- All Implemented Interfaces:
UtilDelegate
Provides utility methods that can be used by stubs and ties to
perform common operations.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate WeakHashMap
<Class<?>, String> private static final Object
private static final IdentityHashMap
<Remote, Tie> private static Util
private static KeepAlive
private static final UtilSystemException
private static ValueHandler
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
cleanUpTie
(Tie cachedTie) copyObject
(Object obj, ORB orb) Copies or connects an object.Object[]
copyObjects
(Object[] obj, ORB orb) Copies or connects an array of objects.private RemoteException
createTransactionException
(String className, String message) Tries to find the correct remote exception to instantiate depending on whether javax.transaction or jakarta.transaction is on the classpathprivate TypeCode
createTypeCode
(Serializable obj, Any any, ORB orb) When using our own ORB and Any implementations, we need to get the ORB version and create the type code appropriately.private TypeCode
createTypeCodeForNull
(ORB orb) This is used to create the TypeCode for a null reference.Returns a singleton instance of a class that implements theValueHandler
interface.getCodebase
(Class clz) Returns the codebase, if any, for the given class.static Util
Returns the tie (if any) for a given target object.boolean
The isLocal method has the same semantics as the ObjectImpl._is_local method, except that it can throw a RemoteException.loadClass
(String className, String remoteCodebase, ClassLoader loader) Returns a class instance for the specified class.private static Tie
An unsynchronized version of getTie() for internal use.Maps a SystemException to a RemoteException.readAny
(InputStream in) Reads a java.lang.Object as a CORBA any.void
registerTarget
(Tie tie, Remote target) Registers a target for a tie.void
unexportObject
(Remote target) Removes the associated tie from an internal table and callsTie.deactivate()
to deactivate the object.void
wrapException
(Throwable orig) Wraps an exception thrown by an implementation method.void
writeAbstractObject
(OutputStream out, Object obj) Writes a java.lang.Object as either a value or a CORBA Object.void
writeAny
(OutputStream out, Object obj) Writes any java.lang.Object as a CORBA any.void
writeRemoteObject
(OutputStream out, Object obj) Writes a java.lang.Object as a CORBA Object.
-
Field Details
-
keepAlive
-
exportedServants
-
valueHandlerSingleton
-
utilWrapper
-
instance
-
annotationMap
-
annotObj
-
-
Constructor Details
-
Util
public Util()
-
-
Method Details
-
getInstance
-
unregisterTargetsForORB
-
mapSystemException
Maps a SystemException to a RemoteException.- Specified by:
mapSystemException
in interfaceUtilDelegate
- Parameters:
ex
- the SystemException to map.- Returns:
- the mapped exception.
-
writeAny
Writes any java.lang.Object as a CORBA any.- Specified by:
writeAny
in interfaceUtilDelegate
- Parameters:
out
- the stream in which to write the any.obj
- the object to write as an any.
-
createTypeCode
When using our own ORB and Any implementations, we need to get the ORB version and create the type code appropriately. This is to overcome a bug in which the JDK 1.3.x ORBs used a tk_char rather than a tk_wchar to describe a Java char field. This only works in RMI-IIOP with Util.writeAny since we actually know what ORB and stream we're writing with when we insert the value. Returns null if it wasn't possible to create the TypeCode (means it wasn't our ORB or Any implementation). This does not handle null objs. -
createTypeCodeForNull
This is used to create the TypeCode for a null reference. It also handles backwards compatibility with JDK 1.3.x. This method will not return null. -
readAny
Reads a java.lang.Object as a CORBA any.- Specified by:
readAny
in interfaceUtilDelegate
- Parameters:
in
- the stream from which to read the any.- Returns:
- the object read from the stream.
-
writeRemoteObject
Writes a java.lang.Object as a CORBA Object. Ifobj
is an exported RMI-IIOP server object, the tie is found and wired toobj
, then written toout.write_Object(org.omg.CORBA.Object)
. Ifobj
is a CORBA Object, it is written toout.write_Object(org.omg.CORBA.Object)
.- Specified by:
writeRemoteObject
in interfaceUtilDelegate
- Parameters:
out
- the stream in which to write the object.obj
- the object to write.
-
writeAbstractObject
Writes a java.lang.Object as either a value or a CORBA Object. Ifobj
is a value object or a stub object, it is written toout.write_abstract_interface(java.lang.Object)
. Ifobj
is an exported RMI-IIOP server object, the tie is found and wired toobj
, then written toout.write_abstract_interface(java.lang.Object)
.- Specified by:
writeAbstractObject
in interfaceUtilDelegate
- Parameters:
out
- the stream in which to write the object.obj
- the object to write.
-
registerTarget
Registers a target for a tie. Adds the tie to an internal table and callsTie.setTarget(java.rmi.Remote)
on the tie object.- Specified by:
registerTarget
in interfaceUtilDelegate
- Parameters:
tie
- the tie to register.target
- the target for the tie.
-
unexportObject
Removes the associated tie from an internal table and callsTie.deactivate()
to deactivate the object.- Specified by:
unexportObject
in interfaceUtilDelegate
- Parameters:
target
- the object to unexport.- Throws:
NoSuchObjectException
- if the target object does not exist
-
cleanUpTie
- Throws:
NoSuchObjectException
-
getTie
Returns the tie (if any) for a given target object.- Specified by:
getTie
in interfaceUtilDelegate
- Parameters:
target
- the object to get the tie for- Returns:
- the tie or null if no tie is registered for the given target.
-
lookupTie
An unsynchronized version of getTie() for internal use. -
createValueHandler
Returns a singleton instance of a class that implements theValueHandler
interface.- Specified by:
createValueHandler
in interfaceUtilDelegate
- Returns:
- a class which implements the ValueHandler interface.
-
getCodebase
Returns the codebase, if any, for the given class.- Specified by:
getCodebase
in interfaceUtilDelegate
- Parameters:
clz
- the class to get a codebase for.- Returns:
- a space-separated list of URLs, or null.
-
loadClass
public Class loadClass(String className, String remoteCodebase, ClassLoader loader) throws ClassNotFoundException Returns a class instance for the specified class.- Specified by:
loadClass
in interfaceUtilDelegate
- 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 who may be used to load the class if all other methods fail.- Returns:
- the
Class
object representing the loaded class. - Throws:
ClassNotFoundException
- if class cannot be loaded.
-
isLocal
The isLocal method has the same semantics as the ObjectImpl._is_local method, except that it can throw a RemoteException. (no it doesn't but the spec says it should.) 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.- Specified by:
isLocal
in interfaceUtilDelegate
- 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:
RemoteException
- The Java to IDL specification does to specify the conditions that cause a RemoteException to be thrown.
-
wrapException
Wraps an exception thrown by an implementation method. It returns the corresponding client-side exception.- Specified by:
wrapException
in interfaceUtilDelegate
- Parameters:
orig
- the exception to wrap.- Returns:
- the wrapped exception.
-
copyObjects
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.- Specified by:
copyObjects
in interfaceUtilDelegate
- Parameters:
obj
- the objects to copy or connect.orb
- the ORB.- Returns:
- the copied or connected objects.
- Throws:
RemoteException
- if any object could not be copied or connected.
-
copyObject
Copies or connects an object. Used by local stubs to copy an actual parameter, result object, or exception.- Specified by:
copyObject
in interfaceUtilDelegate
- Parameters:
obj
- the object to copy.orb
- the ORB.- Returns:
- the copy or connected object.
- Throws:
RemoteException
- if the object could not be copied or connected.
-
createTransactionException
Tries to find the correct remote exception to instantiate depending on whether javax.transaction or jakarta.transaction is on the classpath- Parameters:
className
- Base class name of the exceptionmessage
- Message to add to the exception- Returns:
-