Package com.sun.corba.ee.impl.util
Class Utility
- java.lang.Object
-
- com.sun.corba.ee.impl.util.Utility
-
public final class Utility extends java.lang.Object
Handy class full of static functions.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.Object
CACHE_MISS
static java.lang.String
DYNAMIC_STUB_SUFFIX
static java.lang.String
IDL_STUB_SUFFIX
private static OMGSystemException
omgWrapper
static java.lang.String
RMI_STUB_SUFFIX
static java.lang.String
STUB_PREFIX
private static java.util.IdentityHashMap
stubToTieCache
static java.lang.String
TIE_SUFIX
private static java.util.IdentityHashMap
tieCache
private static java.util.IdentityHashMap
tieToStubCache
private static UtilSystemException
wrapper
-
Constructor Summary
Constructors Constructor Description Utility()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.Object
autoConnect(java.lang.Object obj, ORB orb, boolean convertToStub)
Ensure that stubs, ties, and implementation objects are 'connected' to the runtime.static void
clearCaches()
static java.lang.String
dynamicStubName(java.lang.String className)
static Tie
getAndForgetTie(Object stub)
static ValueFactory
getFactory(java.lang.Class clazz, java.lang.String codebase, ORB orb, java.lang.String repId)
Get the factory for an IDLValue Throws MARSHAL exception if no factory found.static BoxedValueHelper
getHelper(java.lang.Class clazz, java.lang.String codebase, java.lang.String repId)
Get the helper for an IDLValue Throws MARSHAL exception if no helper found.(package private) static int
hexOf(char x)
Converts an Ascii Character into Hexadecimal digitstatic java.lang.String
idlStubName(java.lang.String className)
Create an IDL stub name.static java.lang.Class
loadClassForClass(java.lang.String className, java.lang.String remoteCodebase, java.lang.ClassLoader loader, java.lang.Class relatedType, java.lang.ClassLoader relatedTypeClassLoader)
Load a class and check that it is compatible with a given type.(package private) static java.lang.Class
loadClassOfType(java.lang.String className, java.lang.String remoteCodebase, java.lang.ClassLoader loader, java.lang.Class expectedType, java.lang.ClassLoader expectedTypeClassLoader)
Load a class and check that it is assignable to a given type.static java.rmi.Remote
loadStub(Tie tie, PresentationManager.StubFactory stubFactory, java.lang.String remoteCodebase, boolean onlyMostDerived)
Load an RMI-IIOP Stub given a Tie.static java.rmi.Remote
loadStub(Object narrowFrom, java.lang.Class narrowTo)
private static StubEntry
loadStubAndUpdateCache(Tie tie, PresentationManager.StubFactory stubFactory, java.lang.String remoteCodebase, boolean onlyMostDerived)
Load an RMI-IIOP Stub given a Tie, but do not look in the cache.static java.lang.Class
loadStubClass(java.lang.String repID, java.lang.String remoteCodebase, java.lang.Class expectedType)
private static Tie
loadTie(java.lang.Class theClass)
static Tie
loadTie(java.rmi.Remote obj)
static void
printStackTrace()
static void
purgeStubForTie(Tie tie)
static void
purgeTieAndServant(Tie tie)
static java.lang.Object
readAbstractAndNarrow(InputStream in, java.lang.Class narrowTo)
Read an abstract interface type from the input stream and narrow it to the desired type.static java.lang.Object
readObjectAndNarrow(InputStream in, java.lang.Class narrowTo)
Read an object reference from the input stream and narrow it to the desired type.static java.lang.String
stubName(java.lang.String className)
Create an RMI stub name.private static java.lang.String
stubName(java.lang.String className, boolean isDynamic)
static java.lang.String
stubNameForCompiler(java.lang.String className)
private static java.lang.String
stubNameForCompiler(java.lang.String className, boolean isDynamic)
static java.lang.String
stubNameFromRepID(java.lang.String repID)
static void
throwNotSerializableForCorba(java.lang.String className)
Throws the CORBA equivalent of a java.io.NotSerializableExceptionstatic java.lang.String
tieName(java.lang.String className)
Create an RMI tie name.static java.lang.String
tieNameForCompiler(java.lang.String className)
-
-
-
Field Detail
-
STUB_PREFIX
public static final java.lang.String STUB_PREFIX
- See Also:
- Constant Field Values
-
RMI_STUB_SUFFIX
public static final java.lang.String RMI_STUB_SUFFIX
- See Also:
- Constant Field Values
-
DYNAMIC_STUB_SUFFIX
public static final java.lang.String DYNAMIC_STUB_SUFFIX
- See Also:
- Constant Field Values
-
IDL_STUB_SUFFIX
public static final java.lang.String IDL_STUB_SUFFIX
- See Also:
- Constant Field Values
-
TIE_SUFIX
public static final java.lang.String TIE_SUFIX
- See Also:
- Constant Field Values
-
tieCache
private static final java.util.IdentityHashMap tieCache
-
tieToStubCache
private static final java.util.IdentityHashMap tieToStubCache
-
stubToTieCache
private static final java.util.IdentityHashMap stubToTieCache
-
CACHE_MISS
private static final java.lang.Object CACHE_MISS
-
wrapper
private static final UtilSystemException wrapper
-
omgWrapper
private static final OMGSystemException omgWrapper
-
-
Method Detail
-
autoConnect
public static java.lang.Object autoConnect(java.lang.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(java.rmi.Remote obj)
-
loadTie
private static Tie loadTie(java.lang.Class theClass)
-
clearCaches
public static void clearCaches()
-
loadClassOfType
static java.lang.Class loadClassOfType(java.lang.String className, java.lang.String remoteCodebase, java.lang.ClassLoader loader, java.lang.Class expectedType, java.lang.ClassLoader expectedTypeClassLoader) throws java.lang.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:
java.lang.ClassNotFoundException
-
loadClassForClass
public static java.lang.Class loadClassForClass(java.lang.String className, java.lang.String remoteCodebase, java.lang.ClassLoader loader, java.lang.Class relatedType, java.lang.ClassLoader relatedTypeClassLoader) throws java.lang.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 withrelatedTypeClassLoader
- the related type. May be null.- Returns:
- the loaded class.
- Throws:
java.lang.ClassNotFoundException
- If the className cannot be found
-
getHelper
public static BoxedValueHelper getHelper(java.lang.Class clazz, java.lang.String codebase, java.lang.String repId)
Get the helper for an IDLValue Throws MARSHAL exception if no helper found.- Parameters:
clazz
- Class to get helper forcodebase
- The codebase to use. May be null.repId
- The repository ID- Returns:
- The Helper
-
getFactory
public static ValueFactory getFactory(java.lang.Class clazz, java.lang.String codebase, ORB orb, java.lang.String repId)
Get the factory for an IDLValue Throws MARSHAL exception if no factory found.- Parameters:
clazz
- The Classcodebase
- The codebase to use. May be null.orb
- the ORBrepId
- Repository ID- Returns:
- The Factory
-
loadStub
public static java.rmi.Remote loadStub(Tie tie, PresentationManager.StubFactory stubFactory, java.lang.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, java.lang.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.
-
purgeStubForTie
public static void purgeStubForTie(Tie tie)
-
purgeTieAndServant
public static void purgeTieAndServant(Tie tie)
-
stubNameFromRepID
public static java.lang.String stubNameFromRepID(java.lang.String repID)
-
loadStub
public static java.rmi.Remote loadStub(Object narrowFrom, java.lang.Class narrowTo)
-
loadStubClass
public static java.lang.Class loadStubClass(java.lang.String repID, java.lang.String remoteCodebase, java.lang.Class expectedType) throws java.lang.ClassNotFoundException
- Throws:
java.lang.ClassNotFoundException
-
stubName
public static java.lang.String stubName(java.lang.String className)
Create an RMI stub name.- Parameters:
className
- Class to create stub of- Returns:
- RMI stub name
-
dynamicStubName
public static java.lang.String dynamicStubName(java.lang.String className)
-
stubName
private static java.lang.String stubName(java.lang.String className, boolean isDynamic)
-
stubNameForCompiler
public static java.lang.String stubNameForCompiler(java.lang.String className)
-
stubNameForCompiler
private static java.lang.String stubNameForCompiler(java.lang.String className, boolean isDynamic)
-
tieName
public static java.lang.String tieName(java.lang.String className)
Create an RMI tie name.- Parameters:
className
- Class used for RMI- Returns:
- RMI Tie name
-
tieNameForCompiler
public static java.lang.String tieNameForCompiler(java.lang.String className)
-
throwNotSerializableForCorba
public static void throwNotSerializableForCorba(java.lang.String className)
Throws the CORBA equivalent of a java.io.NotSerializableException- Parameters:
className
- Class that is non-serializable
-
idlStubName
public static java.lang.String idlStubName(java.lang.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 java.lang.Object readObjectAndNarrow(InputStream in, java.lang.Class narrowTo) throws java.lang.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:
java.lang.ClassCastException
- if narrowFrom cannot be cast to narrowTo.
-
readAbstractAndNarrow
public static java.lang.Object readAbstractAndNarrow(InputStream in, java.lang.Class narrowTo) throws java.lang.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:
java.lang.ClassCastException
- if narrowFrom cannot be cast to narrowTo.
-
hexOf
static int hexOf(char x)
Converts an Ascii Character into Hexadecimal digit
-
-