java.lang.Object
com.sun.corba.ee.impl.javax.rmi.CORBA.Util
All Implemented Interfaces:
UtilDelegate

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

  • Constructor Details

    • Util

      public Util()
  • Method Details

    • getInstance

      public static Util getInstance()
    • unregisterTargetsForORB

      public void unregisterTargetsForORB(ORB orb)
    • mapSystemException

      public RemoteException mapSystemException(SystemException ex)
      Maps a SystemException to a RemoteException.
      Specified by:
      mapSystemException in interface UtilDelegate
      Parameters:
      ex - the SystemException to map.
      Returns:
      the mapped exception.
    • writeAny

      public void writeAny(OutputStream out, Object obj)
      Writes any java.lang.Object as a CORBA any.
      Specified by:
      writeAny in interface UtilDelegate
      Parameters:
      out - the stream in which to write the any.
      obj - the object to write as an any.
    • createTypeCode

      private 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. 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

      private TypeCode createTypeCodeForNull(ORB orb)
      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

      public Object readAny(InputStream in)
      Reads a java.lang.Object as a CORBA any.
      Specified by:
      readAny in interface UtilDelegate
      Parameters:
      in - the stream from which to read the any.
      Returns:
      the object read from the stream.
    • writeRemoteObject

      public void writeRemoteObject(OutputStream out, 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).
      Specified by:
      writeRemoteObject in interface UtilDelegate
      Parameters:
      out - the stream in which to write the object.
      obj - the object to write.
    • writeAbstractObject

      public void writeAbstractObject(OutputStream out, 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).
      Specified by:
      writeAbstractObject in interface UtilDelegate
      Parameters:
      out - the stream in which to write the object.
      obj - the object to write.
    • registerTarget

      public void registerTarget(Tie tie, Remote target)
      Registers a target for a tie. Adds the tie to an internal table and calls Tie.setTarget(java.rmi.Remote) on the tie object.
      Specified by:
      registerTarget in interface UtilDelegate
      Parameters:
      tie - the tie to register.
      target - the target for the tie.
    • unexportObject

      public void unexportObject(Remote target) throws NoSuchObjectException
      Removes the associated tie from an internal table and calls Tie.deactivate() to deactivate the object.
      Specified by:
      unexportObject in interface UtilDelegate
      Parameters:
      target - the object to unexport.
      Throws:
      NoSuchObjectException - if the target object does not exist
    • cleanUpTie

      protected void cleanUpTie(Tie cachedTie) throws NoSuchObjectException
      Throws:
      NoSuchObjectException
    • getTie

      public Tie getTie(Remote target)
      Returns the tie (if any) for a given target object.
      Specified by:
      getTie in interface UtilDelegate
      Parameters:
      target - the object to get the tie for
      Returns:
      the tie or null if no tie is registered for the given target.
    • lookupTie

      private static Tie lookupTie(Remote target)
      An unsynchronized version of getTie() for internal use.
    • createValueHandler

      public ValueHandler createValueHandler()
      Returns a singleton instance of a class that implements the ValueHandler interface.
      Specified by:
      createValueHandler in interface UtilDelegate
      Returns:
      a class which implements the ValueHandler interface.
    • getCodebase

      public String getCodebase(Class clz)
      Returns the codebase, if any, for the given class.
      Specified by:
      getCodebase in interface UtilDelegate
      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 interface UtilDelegate
      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

      public boolean isLocal(Stub stub) throws RemoteException
      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 interface UtilDelegate
      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

      public RemoteException wrapException(Throwable orig)
      Wraps an exception thrown by an implementation method. It returns the corresponding client-side exception.
      Specified by:
      wrapException in interface UtilDelegate
      Parameters:
      orig - the exception to wrap.
      Returns:
      the wrapped exception.
    • copyObjects

      public Object[] copyObjects(Object[] obj, ORB orb) throws RemoteException
      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 interface UtilDelegate
      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

      public Object copyObject(Object obj, ORB orb) throws RemoteException
      Copies or connects an object. Used by local stubs to copy an actual parameter, result object, or exception.
      Specified by:
      copyObject in interface UtilDelegate
      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

      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 classpath
      Parameters:
      className - Base class name of the exception
      message - Message to add to the exception
      Returns: