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 Objectprivate static final IdentityHashMap<Remote, Tie> private static Utilprivate static KeepAliveprivate static final UtilSystemExceptionprivate static ValueHandler -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcleanUpTie(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 RemoteExceptioncreateTransactionException(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 TypeCodecreateTypeCode(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 TypeCodecreateTypeCodeForNull(ORB orb) This is used to create the TypeCode for a null reference.Returns a singleton instance of a class that implements theValueHandlerinterface.getCodebase(Class clz) Returns the codebase, if any, for the given class.static UtilReturns the tie (if any) for a given target object.booleanThe 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 TieAn 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.voidregisterTarget(Tie tie, Remote target) Registers a target for a tie.voidunexportObject(Remote target) Removes the associated tie from an internal table and callsTie.deactivate()to deactivate the object.voidwrapException(Throwable orig) Wraps an exception thrown by an implementation method.voidwriteAbstractObject(OutputStream out, Object obj) Writes a java.lang.Object as either a value or a CORBA Object.voidwriteAny(OutputStream out, Object obj) Writes any java.lang.Object as a CORBA any.voidwriteRemoteObject(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:
mapSystemExceptionin interfaceUtilDelegate- Parameters:
ex- the SystemException to map.- Returns:
- the mapped exception.
-
writeAny
Writes any java.lang.Object as a CORBA any.- Specified by:
writeAnyin 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
-
readAny
Reads a java.lang.Object as a CORBA any.- Specified by:
readAnyin 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. 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).- Specified by:
writeRemoteObjectin 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. 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).- Specified by:
writeAbstractObjectin 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(Remote)on the tie object.- Specified by:
registerTargetin 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:
unexportObjectin 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:
getTiein 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
-
createValueHandler
Returns a singleton instance of a class that implements theValueHandlerinterface.- Specified by:
createValueHandlerin interfaceUtilDelegate- Returns:
- a class which implements the ValueHandler interface.
-
getCodebase
Returns the codebase, if any, for the given class.- Specified by:
getCodebasein 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:
loadClassin 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
Classobject 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:
isLocalin 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:
wrapExceptionin 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:
copyObjectsin 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:
copyObjectin 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:
-