Package com.sun.corba.ee.impl.misc
Class ORBUtility
- java.lang.Object
-
- com.sun.corba.ee.impl.misc.ORBUtility
-
public final class ORBUtility extends java.lang.Object
Handy class full of static functions that don't belong in util.Utility for pure ORB reasons.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.ThreadLocal<java.util.LinkedList<java.lang.Byte>>
encVersionThreadLocal
private static java.util.Hashtable<java.lang.String,java.lang.String>
exceptionClassNames
private static java.util.Hashtable
exceptionRepositoryIds
private static StructMember[]
members
private static OMGSystemException
omgWrapper
private static ValueHandler
vhandler
private static ORBUtilSystemException
wrapper
-
Constructor Summary
Constructors Modifier Constructor Description private
ORBUtility()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static int
bytesToInt(byte[] array, int offset)
Unmarshal a byte array to an integer.static byte
chooseEncodingVersion(ORB orb, IOR ior, GIOPVersion gv)
static java.lang.String
classNameOf(java.lang.String repositoryId)
Get the class name corresponding to a particular repository Id.static int
compareVersion(int[] v1, int[] v2)
Compare two version arrays.static int
compareVersion(java.lang.String v1, java.lang.String v2)
Compare two version strings.private static java.lang.String
compressClassName(java.lang.String name)
static java.lang.String[]
concatenateStringArrays(java.lang.String[] arr1, java.lang.String[] arr2)
static ValueHandler
createValueHandler()
Gets the ValueHandler from Util.createValueHandler.static ValueHandler
createValueHandler(ORB orb)
Creates the correct ValueHandler.static void
dprint(java.lang.Object obj, java.lang.String msg)
static void
dprint(java.lang.Object caller, java.lang.String msg, java.lang.Throwable t)
void
dprint(java.lang.String msg)
static void
dprint(java.lang.String className, java.lang.String msg)
static void
dprintTrace(java.lang.Object obj, java.lang.String msg)
static java.lang.String
dumpBinary(byte[] data)
private static void
dumpBinary(java.lang.StringBuffer sbuf, java.nio.ByteBuffer buffer)
static SystemException
extractSystemException(Any any)
private static java.lang.String
formatStackTraceElement(java.lang.StackTraceElement ste)
static java.lang.String
formatStringArray(java.lang.String[] a)
static byte[]
getBuffer(java.lang.String[] data)
Given some hex data, extract it and put it into a byte buffer.static byte[]
getByteBufferArray(java.nio.ByteBuffer byteBuffer)
static java.lang.String
getClassSecurityInfo(java.lang.Class cl)
static byte
getEncodingVersion()
static byte
getMaxStreamFormatVersion()
Returns the maximum stream format version supported by our ValueHandler.private static TypeCode
getSystemExceptionTypeCode(ORB orb, java.lang.String repID, java.lang.String name)
static java.lang.String
getThreadName(java.lang.Thread thr)
static int
hexOf(char x)
Converts an Ascii Character into Hexadecimal digitstatic void
insertSystemException(SystemException ex, Any any)
Static method for writing a CORBA standard exception to an Any.static void
intToBytes(int value, byte[] array, int offset)
Marshal an integer to a byte array.static boolean
isForeignORB(ORB orb)
Returns true if it was accurately determined that the remote ORB is a foreign (non-JavaSoft) ORB.static boolean
isPrintable(char c)
static boolean
isSystemException(java.lang.String repositoryId)
Return true if this repositoryId is a SystemException.private static boolean
isSystemExceptionTypeCode(TypeCode type, ORB orb)
static ClientDelegate
makeClientDelegate(IOR ior)
static Object
makeObjectReference(IOR ior)
This method is used to create untyped object references.static java.nio.channels.SocketChannel
openSocketChannel(java.net.SocketAddress sa)
Utility method for working around leak in SocketChannel.open( SocketAddress ) method.static java.lang.String
operationNameAndRequestId(MessageMediator m)
static int[]
parseVersion(java.lang.String version)
Parse a version string such as "1.1.6" or "jdk1.2fcs" into a version array of integers {1, 1, 6} or {1, 2}.static void
popEncVersionFromThreadLocalState()
static void
printBuffer(java.lang.String msg, java.nio.ByteBuffer buffer, java.io.PrintStream ps)
Print the contents of the buffer out to the PrintStream in hex and ASCII.private static void
printStackTrace(java.lang.StackTraceElement[] trace)
static void
pushEncVersionToThreadLocalState(byte value)
static SystemException
readSystemException(InputStream strm)
Static method for reading a CORBA standard exception from a stream.static java.lang.String
repositoryIdOf(java.lang.String name)
Get the repository id corresponding to a particular class.static void
setDaemon(java.lang.Thread thread)
private static StructMember[]
systemExceptionMembers(ORB orb)
static void
throwNotSerializableForCorba(java.lang.String className)
Throws the CORBA equivalent of a java.io.NotSerializableException Duplicated from util/Utility for Pure ORB reasons.static void
writeSystemException(SystemException ex, OutputStream strm)
Static method for writing a CORBA standard exception to a stream.
-
-
-
Field Detail
-
encVersionThreadLocal
private static final java.lang.ThreadLocal<java.util.LinkedList<java.lang.Byte>> encVersionThreadLocal
-
wrapper
private static ORBUtilSystemException wrapper
-
omgWrapper
private static OMGSystemException omgWrapper
-
members
private static StructMember[] members
-
vhandler
private static ValueHandler vhandler
-
exceptionClassNames
private static final java.util.Hashtable<java.lang.String,java.lang.String> exceptionClassNames
-
exceptionRepositoryIds
private static final java.util.Hashtable exceptionRepositoryIds
-
-
Method Detail
-
openSocketChannel
public static java.nio.channels.SocketChannel openSocketChannel(java.net.SocketAddress sa) throws java.io.IOException
Utility method for working around leak in SocketChannel.open( SocketAddress ) method.- Parameters:
sa
- address to connect to- Returns:
- The opened channel
- Throws:
java.io.IOException
- If an I/O error occurs- See Also:
SocketChannel.connect(java.net.SocketAddress)
-
pushEncVersionToThreadLocalState
public static void pushEncVersionToThreadLocalState(byte value)
-
popEncVersionFromThreadLocalState
public static void popEncVersionFromThreadLocalState()
-
getEncodingVersion
public static byte getEncodingVersion()
-
getByteBufferArray
public static byte[] getByteBufferArray(java.nio.ByteBuffer byteBuffer)
-
chooseEncodingVersion
public static byte chooseEncodingVersion(ORB orb, IOR ior, GIOPVersion gv)
- Parameters:
orb
- The ORBior
- Interoperable object referencegv
- The maximum GIOP version supported- Returns:
- the Java serialization encoding version.
-
systemExceptionMembers
private static StructMember[] systemExceptionMembers(ORB orb)
-
getSystemExceptionTypeCode
private static TypeCode getSystemExceptionTypeCode(ORB orb, java.lang.String repID, java.lang.String name)
-
insertSystemException
public static void insertSystemException(SystemException ex, Any any)
Static method for writing a CORBA standard exception to an Any.- Parameters:
ex
- Exception to writeany
- The Any to write the SystemException into.
-
extractSystemException
public static SystemException extractSystemException(Any any)
-
createValueHandler
public static ValueHandler createValueHandler()
Gets the ValueHandler from Util.createValueHandler.- Returns:
- gets the ValueHandler
-
createValueHandler
public static ValueHandler createValueHandler(ORB orb)
Creates the correct ValueHandler. The parameter is ignored- Parameters:
orb
- ignored- Returns:
- The correct ValueHandler
- See Also:
createValueHandler()
-
isForeignORB
public static boolean isForeignORB(ORB orb)
Returns true if it was accurately determined that the remote ORB is a foreign (non-JavaSoft) ORB. Note: If passed the ORBSingleton, this will return false.- Parameters:
orb
- ORB to test- Returns:
- If the ORB is foreign
-
bytesToInt
public static int bytesToInt(byte[] array, int offset)
Unmarshal a byte array to an integer. Assume the bytes are in BIGENDIAN order. i.e. array[offset] is the most-significant-byte and array[offset+3] is the least-significant-byte.- Parameters:
array
- The array of bytes.offset
- The offset from which to start unmarshalling.- Returns:
- Unmarshalled integer
-
intToBytes
public static void intToBytes(int value, byte[] array, int offset)
Marshal an integer to a byte array. The bytes are in BIGENDIAN order. i.e. array[offset] is the most-significant-byte and array[offset+3] is the least-significant-byte.- Parameters:
value
- Integer to marshalarray
- The array of bytes.offset
- The offset from which to start marshalling.
-
hexOf
public static int hexOf(char x)
Converts an Ascii Character into Hexadecimal digit- Parameters:
x
- ASCII character to convert- Returns:
- Hexadecimal digit
-
writeSystemException
public static void writeSystemException(SystemException ex, OutputStream strm)
Static method for writing a CORBA standard exception to a stream.- Parameters:
ex
- Exception to write to streamstrm
- The OutputStream to use for marshaling.
-
readSystemException
public static SystemException readSystemException(InputStream strm)
Static method for reading a CORBA standard exception from a stream.- Parameters:
strm
- The InputStream to use for unmarshalling.- Returns:
- Exception in stream
-
classNameOf
public static java.lang.String classNameOf(java.lang.String repositoryId)
Get the class name corresponding to a particular repository Id. This is used by the system to unmarshal (instantiate) the appropriate exception class for an marshaled as the value of its repository Id.- Parameters:
repositoryId
- The repository Id for which we want a class name.- Returns:
- Corresponding class name
-
isSystemException
public static boolean isSystemException(java.lang.String repositoryId)
Return true if this repositoryId is a SystemException.- Parameters:
repositoryId
- The repository Id to check.- Returns:
- if ID is a SystemException
-
repositoryIdOf
public static java.lang.String repositoryIdOf(java.lang.String name)
Get the repository id corresponding to a particular class. This is used by the system to write the appropriate repository id for a system exception.- Parameters:
name
- The class name of the system exception.- Returns:
- Repository ID
-
parseVersion
public static int[] parseVersion(java.lang.String version)
Parse a version string such as "1.1.6" or "jdk1.2fcs" into a version array of integers {1, 1, 6} or {1, 2}. A string of "n." or "n..m" is equivalent to "n.0" or "n.0.m" respectively.- Parameters:
version
- Java version- Returns:
- Array of version parts
-
compareVersion
public static int compareVersion(int[] v1, int[] v2)
Compare two version arrays. Return 1, 0 or -1 if v1 is greater than, equal to, or less than v2.- Parameters:
v1
- first versionv2
- second version- Returns:
- 1, 0 or -1 if v1 is greater than, equal to, or less than v2.
-
compareVersion
public static int compareVersion(java.lang.String v1, java.lang.String v2)
Compare two version strings. Return 1, 0 or -1 if v1 is greater than, equal to, or less than v2.- Parameters:
v1
- first version stringv2
- second version string- Returns:
- 1, 0 or -1 if v1 is greater than, equal to, or less than v2.
- See Also:
compareVersion(int[], int[])
-
compressClassName
private static java.lang.String compressClassName(java.lang.String name)
-
getThreadName
public static java.lang.String getThreadName(java.lang.Thread thr)
-
formatStackTraceElement
private static java.lang.String formatStackTraceElement(java.lang.StackTraceElement ste)
-
printStackTrace
private static void printStackTrace(java.lang.StackTraceElement[] trace)
-
dprint
public static void dprint(java.lang.Object obj, java.lang.String msg)
-
dprint
public static void dprint(java.lang.String className, java.lang.String msg)
-
dprint
public void dprint(java.lang.String msg)
-
dprintTrace
public static void dprintTrace(java.lang.Object obj, java.lang.String msg)
-
dprint
public static void dprint(java.lang.Object caller, java.lang.String msg, java.lang.Throwable t)
-
concatenateStringArrays
public static java.lang.String[] concatenateStringArrays(java.lang.String[] arr1, java.lang.String[] arr2)
-
throwNotSerializableForCorba
public static void throwNotSerializableForCorba(java.lang.String className)
Throws the CORBA equivalent of a java.io.NotSerializableException Duplicated from util/Utility for Pure ORB reasons. There are two reasons for this: 1) We can't introduce dependencies on the util version from outside of the io/util packages since it will not exist in the pure ORB build running on JDK 1.3.x. 2) We need to pick up the correct minor code from OMGSystemException.- Parameters:
className
- Class that is notSerializable
-
getMaxStreamFormatVersion
public static byte getMaxStreamFormatVersion()
Returns the maximum stream format version supported by our ValueHandler.- Returns:
- he maximum stream format version
-
makeClientDelegate
public static ClientDelegate makeClientDelegate(IOR ior)
-
makeObjectReference
public static Object makeObjectReference(IOR ior)
This method is used to create untyped object references.- Parameters:
ior
- object to make reference of- Returns:
- Object pointing to the IOR
-
setDaemon
public static void setDaemon(java.lang.Thread thread)
-
operationNameAndRequestId
public static java.lang.String operationNameAndRequestId(MessageMediator m)
-
isPrintable
public static boolean isPrintable(char c)
-
getBuffer
public static byte[] getBuffer(java.lang.String[] data)
Given some hex data, extract it and put it into a byte buffer. The data must follow the following structure:- All characters in a line after a "#" are ignored.
- All non-whitespace characters before a "#" are treated as hex data.
- All whitespace is ignored.
- Only whitespace and 0-9a-fA-F may occur before a "#" in any line.
- Each data line must contain an even number of non-whitespace characters.
- Parameters:
data
- data to extract- Returns:
- byte array containing the data
-
dumpBinary
public static java.lang.String dumpBinary(byte[] data)
-
dumpBinary
private static void dumpBinary(java.lang.StringBuffer sbuf, java.nio.ByteBuffer buffer)
-
printBuffer
public static void printBuffer(java.lang.String msg, java.nio.ByteBuffer buffer, java.io.PrintStream ps)
Print the contents of the buffer out to the PrintStream in hex and ASCII.- Parameters:
msg
- The message to use as the header for this displaybuffer
- The ByteBuffer containing the data. The contents from 0 to buffer.position() are printed out. Remember to set position!ps
- The PrintStream to use for the display.
-
getClassSecurityInfo
public static java.lang.String getClassSecurityInfo(java.lang.Class cl)
-
formatStringArray
public static java.lang.String formatStringArray(java.lang.String[] a)
-
-