Class Utility

java.lang.Object
com.sun.corba.ee.impl.util.Utility

public final class Utility extends Object
Handy class full of static functions.
  • Field Details

  • Constructor Details

    • Utility

      public Utility()
  • Method Details

    • autoConnect

      public static Object autoConnect(Object obj, ORB orb, boolean convertToStub)
      Ensure that stubs, ties, and implementation objects are 'connected' to the runtime. Converts implementation objects to a type suitable for sending on the wire.
      Parameters:
      obj - the object to connect.
      orb - the ORB to connect to if obj is exported to IIOP.
      convertToStub - true if implementation types should be converted to Stubs rather than just org.omg.CORBA.Object.
      Returns:
      the connected object.
      Throws:
      INV_OBJREF - if obj is an implementation which has not been exported.
    • loadTie

      public static Tie loadTie(Remote obj)
    • loadTie

      private static Tie loadTie(Class theClass)
    • clearCaches

      public static void clearCaches()
    • loadClassOfType

      static Class loadClassOfType(String className, String remoteCodebase, ClassLoader loader, Class expectedType, ClassLoader expectedTypeClassLoader) throws ClassNotFoundException
      Load a class and check that it is assignable to a given type.
      Parameters:
      className - the class name.
      remoteCodebase - the codebase to use. May be null.
      loader - the class loader of last resort. May be null.
      expectedType - the expected type. May be null.
      Returns:
      the loaded class.
      Throws:
      ClassNotFoundException
    • loadClassForClass

      public static Class loadClassForClass(String className, String remoteCodebase, ClassLoader loader, Class relatedType, ClassLoader relatedTypeClassLoader) throws ClassNotFoundException
      Load a class and check that it is compatible with a given type.
      Parameters:
      className - the class name.
      remoteCodebase - the codebase to use. May be null.
      loader - the loading context. May be null.
      relatedType - Type to check compatibility with
      relatedTypeClassLoader - the related type. May be null.
      Returns:
      the loaded class.
      Throws:
      ClassNotFoundException - If the className cannot be found
    • getHelper

      public static BoxedValueHelper getHelper(Class clazz, String codebase, String repId)
      Get the helper for an IDLValue Throws MARSHAL exception if no helper found.
      Parameters:
      clazz - Class to get helper for
      codebase - The codebase to use. May be null.
      repId - The repository ID
      Returns:
      The Helper
    • getFactory

      public static ValueFactory getFactory(Class clazz, String codebase, ORB orb, String repId)
      Get the factory for an IDLValue Throws MARSHAL exception if no factory found.
      Parameters:
      clazz - The Class
      codebase - The codebase to use. May be null.
      orb - the ORB
      repId - Repository ID
      Returns:
      The Factory
    • loadStub

      public static Remote loadStub(Tie tie, PresentationManager.StubFactory stubFactory, String remoteCodebase, boolean onlyMostDerived)
      Load an RMI-IIOP Stub given a Tie.
      Parameters:
      tie - the tie.
      stubFactory - the Stub factory.
      remoteCodebase - the codebase to use. May be null.
      onlyMostDerived - if true, will fail if cannot load a stub for the first repID in the tie. If false, will walk all repIDs.
      Returns:
      the stub or null if not found.
    • loadStubAndUpdateCache

      private static StubEntry loadStubAndUpdateCache(Tie tie, PresentationManager.StubFactory stubFactory, String remoteCodebase, boolean onlyMostDerived)
      Load an RMI-IIOP Stub given a Tie, but do not look in the cache. This method must be called with the lock held for tieToStubCache.
      Parameters:
      tie - the tie.
      stubFactory - the stub factory. May be null.
      remoteCodebase - the codebase to use. May be null.
      onlyMostDerived - if true, will fail if cannot load a stub for the first repID in the tie. If false, will walk all repIDs.
      Returns:
      the StubEntry or null if not found.
    • getAndForgetTie

      public static Tie getAndForgetTie(Object stub)
    • purgeStubForTie

      public static void purgeStubForTie(Tie tie)
    • purgeTieAndServant

      public static void purgeTieAndServant(Tie tie)
    • stubNameFromRepID

      public static String stubNameFromRepID(String repID)
    • loadStub

      public static Remote loadStub(Object narrowFrom, Class narrowTo)
    • loadStubClass

      public static Class loadStubClass(String repID, String remoteCodebase, Class expectedType) throws ClassNotFoundException
      Throws:
      ClassNotFoundException
    • stubName

      public static String stubName(String className)
      Create an RMI stub name.
      Parameters:
      className - Class to create stub of
      Returns:
      RMI stub name
    • dynamicStubName

      public static String dynamicStubName(String className)
    • stubName

      private static String stubName(String className, boolean isDynamic)
    • stubNameForCompiler

      public static String stubNameForCompiler(String className)
    • stubNameForCompiler

      private static String stubNameForCompiler(String className, boolean isDynamic)
    • tieName

      public static String tieName(String className)
      Create an RMI tie name.
      Parameters:
      className - Class used for RMI
      Returns:
      RMI Tie name
    • tieNameForCompiler

      public static String tieNameForCompiler(String className)
    • throwNotSerializableForCorba

      public static void throwNotSerializableForCorba(String className)
      Throws the CORBA equivalent of a java.io.NotSerializableException
      Parameters:
      className - Class that is non-serializable
    • idlStubName

      public static String idlStubName(String className)
      Create an IDL stub name.
      Parameters:
      className - Class to create stub name of
      Returns:
      Created stub name
    • printStackTrace

      public static void printStackTrace()
    • readObjectAndNarrow

      public static Object readObjectAndNarrow(InputStream in, Class narrowTo) throws ClassCastException
      Read an object reference from the input stream and narrow it to the desired type.
      Parameters:
      in - the stream to read from.
      narrowTo - Desired class
      Returns:
      Narrowed object
      Throws:
      ClassCastException - if narrowFrom cannot be cast to narrowTo.
    • readAbstractAndNarrow

      public static Object readAbstractAndNarrow(InputStream in, Class narrowTo) throws ClassCastException
      Read an abstract interface type from the input stream and narrow it to the desired type.
      Parameters:
      in - the stream to read from.
      narrowTo - Desired class
      Returns:
      Narrowed object
      Throws:
      ClassCastException - if narrowFrom cannot be cast to narrowTo.
    • hexOf

      static int hexOf(char x)
      Converts an Ascii Character into Hexadecimal digit