Package com.sun.corba.ee.impl.util
Class Utility
java.lang.Object
com.sun.corba.ee.impl.util.Utility
Handy class full of static functions.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Object
static final String
static final String
private static final OMGSystemException
static final String
static final String
private static final IdentityHashMap
static final String
private static final IdentityHashMap
private static final IdentityHashMap
private static final UtilSystemException
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Object
autoConnect
(Object obj, ORB orb, boolean convertToStub) Ensure that stubs, ties, and implementation objects are 'connected' to the runtime.static void
static String
dynamicStubName
(String className) static Tie
getAndForgetTie
(Object stub) static ValueFactory
getFactory
(Class clazz, String codebase, ORB orb, String repId) Get the factory for an IDLValue Throws MARSHAL exception if no factory found.static BoxedValueHelper
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 String
idlStubName
(String className) Create an IDL stub name.static Class
loadClassForClass
(String className, String remoteCodebase, ClassLoader loader, Class relatedType, ClassLoader relatedTypeClassLoader) Load a class and check that it is compatible with a given type.(package private) static Class
loadClassOfType
(String className, String remoteCodebase, ClassLoader loader, Class expectedType, ClassLoader expectedTypeClassLoader) Load a class and check that it is assignable to a given type.static Remote
loadStub
(Tie tie, PresentationManager.StubFactory stubFactory, String remoteCodebase, boolean onlyMostDerived) Load an RMI-IIOP Stub given a Tie.static Remote
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.static Class
loadStubClass
(String repID, String remoteCodebase, Class expectedType) private static Tie
static Tie
static void
static void
purgeStubForTie
(Tie tie) static void
purgeTieAndServant
(Tie tie) static Object
readAbstractAndNarrow
(InputStream in, Class narrowTo) Read an abstract interface type from the input stream and narrow it to the desired type.static Object
readObjectAndNarrow
(InputStream in, Class narrowTo) Read an object reference from the input stream and narrow it to the desired type.static String
Create an RMI stub name.private static String
static String
stubNameForCompiler
(String className) private static String
stubNameForCompiler
(String className, boolean isDynamic) static String
stubNameFromRepID
(String repID) static void
throwNotSerializableForCorba
(String className) Throws the CORBA equivalent of a java.io.NotSerializableExceptionstatic String
Create an RMI tie name.static String
tieNameForCompiler
(String className)
-
Field Details
-
STUB_PREFIX
- See Also:
-
RMI_STUB_SUFFIX
- See Also:
-
DYNAMIC_STUB_SUFFIX
- See Also:
-
IDL_STUB_SUFFIX
- See Also:
-
TIE_SUFIX
- See Also:
-
tieCache
-
tieToStubCache
-
stubToTieCache
-
CACHE_MISS
-
wrapper
-
omgWrapper
-
-
Constructor Details
-
Utility
public Utility()
-
-
Method Details
-
autoConnect
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
-
loadTie
-
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 withrelatedTypeClassLoader
- the related type. May be null.- Returns:
- the loaded class.
- Throws:
ClassNotFoundException
- If the className cannot be found
-
getHelper
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
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 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
-
purgeStubForTie
-
purgeTieAndServant
-
stubNameFromRepID
-
loadStub
-
loadStubClass
public static Class loadStubClass(String repID, String remoteCodebase, Class expectedType) throws ClassNotFoundException - Throws:
ClassNotFoundException
-
stubName
Create an RMI stub name.- Parameters:
className
- Class to create stub of- Returns:
- RMI stub name
-
dynamicStubName
-
stubName
-
stubNameForCompiler
-
stubNameForCompiler
-
tieName
Create an RMI tie name.- Parameters:
className
- Class used for RMI- Returns:
- RMI Tie name
-
tieNameForCompiler
-
throwNotSerializableForCorba
Throws the CORBA equivalent of a java.io.NotSerializableException- Parameters:
className
- Class that is non-serializable
-
idlStubName
Create an IDL stub name.- Parameters:
className
- Class to create stub name of- Returns:
- Created stub name
-
printStackTrace
public static void printStackTrace() -
readObjectAndNarrow
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
-