Fields Summary |
---|
public static final RepositoryIdCache_1_3 | cache |
public static final byte[] | IDL_IDENTIFIER_CHARS |
private static String | defaultServerURL |
private static boolean | useCodebaseOnly |
private static com.sun.corba.se.impl.util.IdentityHashtable | classToRepStr |
private static com.sun.corba.se.impl.util.IdentityHashtable | classIDLToRepStr |
private static com.sun.corba.se.impl.util.IdentityHashtable | classSeqToRepStr |
private static com.sun.corba.se.impl.util.IdentityHashtable | repStrToByteArray |
private static Hashtable | repStrToClass |
private String | repId |
private boolean | isSupportedFormat |
private String | typeString |
private String | versionString |
private boolean | isSequence |
private boolean | isRMIValueType |
private boolean | isIDLType |
private String | completeClassName |
private String | unqualifiedName |
private String | definedInId |
private Class | clazz |
private String | suid |
private String | actualSuid |
private long | suidLong |
private long | actualSuidLong |
private static final String | kValuePrefix |
private static final String | kIDLPrefix |
private static final String | kIDLNamePrefix |
private static final String | kIDLClassnamePrefix |
private static final String | kSequencePrefix |
private static final String | kCORBAPrefix |
private static final String | kArrayPrefix |
private static final int | kValuePrefixLength |
private static final int | kIDLPrefixLength |
private static final int | kSequencePrefixLength |
private static final String | kInterfaceHashCode |
private static final String | kInterfaceOnlyHashStr |
private static final String | kExternalizableHashStr |
public static final int | kInitialValueTag |
public static final int | kNoTypeInfo |
public static final int | kSingleRepTypeInfo |
public static final int | kPartialListTypeInfo |
public static final int | kChunkedMask |
public static final String | kWStringValueVersion |
public static final String | kWStringValueHash |
public static final String | kWStringStubValue |
public static final String | kWStringTypeStr |
public static final String | kWStringValueRepID |
public static final String | kAnyRepID |
public static final String | kClassDescValueHash |
public static final String | kClassDescStubValue |
public static final String | kClassDescTypeStr |
public static final String | kClassDescValueRepID |
public static final String | kObjectValueHash |
public static final String | kObjectStubValue |
public static final String | kSequenceValueHash |
public static final String | kPrimitiveSequenceValueHash |
public static final String | kSerializableValueHash |
public static final String | kSerializableStubValue |
public static final String | kExternalizableValueHash |
public static final String | kExternalizableStubValue |
public static final String | kRemoteValueHash |
public static final String | kRemoteStubValue |
public static final String | kRemoteTypeStr |
public static final String | kRemoteValueRepID |
public static final Hashtable | kSpecialArrayTypeStrings |
public static final Hashtable | kSpecialCasesRepIDs |
public static final Hashtable | kSpecialCasesStubValues |
public static final Hashtable | kSpecialCasesVersions |
public static final Hashtable | kSpecialCasesClasses |
public static final Hashtable | kSpecialCasesArrayPrefix |
public static final Hashtable | kSpecialPrimitives |
private static final byte[] | ASCII_HEXUsed to convert ascii to hex. |
public static final String | kjava_rmi_Remote |
public static final String | korg_omg_CORBA_Object |
public static final Class[] | kNoParamTypes |
public static final Object[] | kNoArgs |
Methods Summary |
---|
private static java.lang.String | convertFromISOLatin1(java.lang.String name)Convert strings with ISO Latin 1 escape sequences back to original strings.
Section 5.5.7 of OBV spec.
int index = -1;
StringBuffer buf = new StringBuffer(name);
while ((index = buf.toString().indexOf("\\U")) != -1){
String str = "0000" + buf.toString().substring(index+2, index+6);
// Convert Hexadecimal
byte[] buffer = new byte[(str.length() - 4) / 2];
for (int i=4, j=0; i < str.length(); i +=2, j++) {
buffer[j] = (byte)((ORBUtility.hexOf(str.charAt(i)) << 4) & 0xF0);
buffer[j] |= (byte)((ORBUtility.hexOf(str.charAt(i+1)) << 0) & 0x0F);
}
buf = new StringBuffer(delete(buf.toString(), index, index+6));
buf.insert(index, (char)buffer[1]);
}
return buf.toString();
|
private static java.lang.String | convertToISOLatin1(java.lang.String name)Convert strings with illegal IDL identifier characters.
Section 5.5.7 of OBV spec.
int length = name.length();
if (length == 0) {
return name;
}
StringBuffer buffer = null;
for (int i = 0; i < length; i++) {
char c = name.charAt(i);
if (c > 255 || IDL_IDENTIFIER_CHARS[c] == 0) {
// We gotta convert. Have we already started?
if (buffer == null) {
// No, so get set up...
buffer = new StringBuffer(name.substring(0,i));
}
// Convert the character into the IDL escape syntax...
buffer.append(
"\\U" +
(char)ASCII_HEX[(c & 0xF000) >>> 12] +
(char)ASCII_HEX[(c & 0x0F00) >>> 8] +
(char)ASCII_HEX[(c & 0x00F0) >>> 4] +
(char)ASCII_HEX[(c & 0x000F)]);
} else {
if (buffer != null) {
buffer.append(c);
}
}
}
if (buffer != null) {
name = buffer.toString();
}
return name;
|
public static java.lang.String | createForAnyType(java.lang.Class type)Createa a repository ID for the type if it is either a java type
or an IDL type.
try{
if (type.isArray())
return createSequenceRepID(type);
else if (IDLEntity.class.isAssignableFrom(type))
{
try{
return getIdFromHelper(type);
}
catch(Throwable t) {
return createForIDLType(type, 1, 0);
}
}
else return createForJavaType(type);
}
catch(com.sun.corba.se.impl.io.TypeMismatchException e){
return null;
}
|
public static java.lang.String | createForIDLType(java.lang.Class ser, int major, int minor)Creates a repository ID for an IDL Java Type.
synchronized (classIDLToRepStr){
String repid = (String)classIDLToRepStr.get(ser);
if (repid != null)
return repid;
repid = kIDLPrefix + convertToISOLatin1(ser.getName()).replace('.",'/") +
":" + major + "." + minor;
classIDLToRepStr.put(ser, repid);
return repid;
}
|
public static java.lang.String | createForJavaType(java.io.Serializable ser)Creates a repository ID for a normal Java Type.
synchronized (classToRepStr) {
String repid = createForSpecialCase(ser);
if (repid != null)
return repid;
Class clazz = ser.getClass();
repid = (String)classToRepStr.get(clazz);
if (repid != null)
return repid;
repid = kValuePrefix + convertToISOLatin1(clazz.getName()) +
createHashString(clazz);
classToRepStr.put(clazz, repid);
repStrToClass.put(repid, clazz);
return repid;
}
|
public static java.lang.String | createForJavaType(java.lang.Class clz)Creates a repository ID for a normal Java Type.
synchronized (classToRepStr){
String repid = createForSpecialCase(clz);
if (repid != null)
return repid;
repid = (String)classToRepStr.get(clz);
if (repid != null)
return repid;
repid = kValuePrefix + convertToISOLatin1(clz.getName()) +
createHashString(clz);
classToRepStr.put(clz, repid);
repStrToClass.put(repid, clz);
return repid;
}
|
public static java.lang.String | createForSpecialCase(java.lang.Class clazz)
if (clazz.isArray()){
return createSequenceRepID(clazz);
}
else {
return (String)kSpecialCasesRepIDs.get(clazz);
}
|
public static java.lang.String | createForSpecialCase(java.io.Serializable ser)
Class clazz = ser.getClass();
if (clazz.isArray()){
return createSequenceRepID(ser);
}
else
return createForSpecialCase(clazz);
|
private static java.lang.String | createHashString(java.io.Serializable ser)
return createHashString(ser.getClass());
|
private static java.lang.String | createHashString(java.lang.Class clazz)
if (clazz.isInterface() || !java.io.Serializable.class.isAssignableFrom(clazz))
return kInterfaceHashCode;
long actualLong = ObjectStreamClassUtil_1_3.computeStructuralUID(false, clazz);
String hash = null;
if (actualLong == 0)
hash = kInterfaceOnlyHashStr;
else if (actualLong == 1)
hash = kExternalizableHashStr;
else
hash = Long.toHexString(actualLong).toUpperCase();
while(hash.length() < 16){
hash = "0" + hash;
}
long declaredLong = ObjectStreamClassUtil_1_3.computeSerialVersionUID(clazz);
String declared = null;
if (declaredLong == 0)
declared = kInterfaceOnlyHashStr;
else if (declaredLong == 1)
declared = kExternalizableHashStr;
else
declared = Long.toHexString(declaredLong).toUpperCase();
while (declared.length() < 16){
declared = "0" + declared;
}
hash = hash + ":" + declared;
return ":" + hash;
|
public static java.lang.String | createSequenceRepID(java.lang.Object ser)Creates a repository ID for a sequence. This is for expert users only as
this method assumes the object passed is an array. If passed an object
that is not an array, it will produce a rep id for a sequence of zero
length. This would be an error.
return createSequenceRepID(ser.getClass());
|
public static java.lang.String | createSequenceRepID(java.lang.Class clazz)Creates a repository ID for a sequence. This is for expert users only as
this method assumes the object passed is an array. If passed an object
that is not an array, it will produce a malformed rep id.
synchronized (classSeqToRepStr){
String repid = (String)classSeqToRepStr.get(clazz);
if (repid != null)
return repid;
Class originalClazz = clazz;
Class type = null;
int numOfDims = 0;
while ((type = clazz.getComponentType()) != null) {
numOfDims++;
clazz = type;
}
if (clazz.isPrimitive())
repid = kValuePrefix + originalClazz.getName() + kPrimitiveSequenceValueHash;
else {
StringBuffer buf = new StringBuffer();
buf.append(kValuePrefix);
while(numOfDims-- > 0) {
buf.append("[");
}
buf.append("L");
buf.append(convertToISOLatin1(clazz.getName()));
buf.append(";");
buf.append(createHashString(clazz));
repid = buf.toString();
}
classSeqToRepStr.put(originalClazz,repid);
return repid;
}
|
private static java.lang.String | delete(java.lang.String str, int from, int to)
return str.substring(0, from) + str.substring(to, str.length());
|
public final java.lang.String | getActualSerialVersionUID()
return actualSuid;
|
public final long | getActualSerialVersionUIDAsLong()
return actualSuidLong;
|
public final java.lang.Class | getAnyClassFromType()
try {
return getClassFromType();
} catch (ClassNotFoundException cnfe) {
Class clz = (Class)repStrToClass.get(repId);
if (clz != null)
return clz;
else
throw cnfe;
}
|
public static byte[] | getByteArray(java.lang.String repStr)
synchronized (repStrToByteArray){
return (byte[]) repStrToByteArray.get(repStr);
}
|
public final java.lang.Class | getClassFromType()
if (clazz != null)
return clazz;
Class specialCase = (Class)kSpecialCasesClasses.get(getClassName());
if (specialCase != null){
clazz = specialCase;
return specialCase;
}
else
{
try{
return Util.loadClass(getClassName(), null, null);
}
catch(ClassNotFoundException cnfe){
if (defaultServerURL != null) {
try{
return getClassFromType(defaultServerURL);
}
catch(MalformedURLException mue){
throw cnfe;
}
}
else throw cnfe;
}
}
|
public final java.lang.Class | getClassFromType(java.lang.Class expectedType, java.lang.String codebase)
if (clazz != null)
return clazz;
Class specialCase = (Class)kSpecialCasesClasses.get(getClassName());
if (specialCase != null){
clazz = specialCase;
return specialCase;
} else {
ClassLoader expectedTypeClassLoader = (expectedType == null ? null : expectedType.getClassLoader());
return loadClassOfType(getClassName(),
codebase,
expectedTypeClassLoader,
expectedType,
expectedTypeClassLoader);
}
|
public final java.lang.Class | getClassFromType(java.lang.String url)
return Util.loadClass(getClassName(), url, null);
|
public final java.lang.String | getClassName()
if (isRMIValueType)
return typeString;
else if (isIDLType)
return completeClassName;
else return null;
|
public final java.lang.String | getDefinedInId()
if (definedInId == null){
getUnqualifiedName();
}
return definedInId;
|
private static java.lang.String | getIdFromHelper(java.lang.Class clazz)
try {
Class helperClazz = Utility.loadClassForClass(clazz.getName()+"Helper", null,
clazz.getClassLoader(), clazz, clazz.getClassLoader());
Method idMethod = helperClazz.getDeclaredMethod("id", kNoParamTypes);
return (String)idMethod.invoke(null, kNoArgs);
}
catch(java.lang.ClassNotFoundException cnfe)
{
throw new org.omg.CORBA.MARSHAL(cnfe.toString());
}
catch(java.lang.NoSuchMethodException nsme)
{
throw new org.omg.CORBA.MARSHAL(nsme.toString());
}
catch(java.lang.reflect.InvocationTargetException ite)
{
throw new org.omg.CORBA.MARSHAL(ite.toString());
}
catch(java.lang.IllegalAccessException iae)
{
throw new org.omg.CORBA.MARSHAL(iae.toString());
}
|
public final java.lang.String | getRepositoryId()
return repId;
|
public final java.lang.String | getSerialVersionUID()
return suid;
|
public final long | getSerialVersionUIDAsLong()
return suidLong;
|
public final java.lang.String | getTypeString()
return typeString;
|
public final java.lang.String | getUnqualifiedName()
if (unqualifiedName == null){
String className = getClassName();
int index = (className != null) ? className.lastIndexOf('.") : -1;
if (index == -1){
unqualifiedName = className;
definedInId = "IDL::1.0";
}
else {
unqualifiedName = className.substring(index);
definedInId = "IDL:" + className.substring(0, index).replace('.",'/") + ":1.0";
}
}
return unqualifiedName;
|
public final java.lang.String | getVersionString()
return versionString;
|
com.sun.corba.se.impl.orbutil.RepositoryId_1_3 | init(java.lang.String aRepId)
this.repId = aRepId;
// Special case for remote
if (aRepId.length() == 0) {
clazz = java.rmi.Remote.class;
typeString = "";
isRMIValueType = true;
suid = kInterfaceOnlyHashStr;
return this;
}
else if (aRepId.equals(kWStringValueRepID)) {
clazz = java.lang.String.class;
typeString = kWStringTypeStr;
isIDLType = true;
versionString = kWStringValueVersion;
return this;
}
else {
String repId = convertFromISOLatin1(aRepId);
versionString = repId.substring(repId.indexOf(':", repId.indexOf(':")+1));
if (repId.startsWith(kIDLPrefix)) {
typeString =
repId.substring(kIDLPrefixLength, repId.indexOf(':", kIDLPrefixLength));
isIDLType = true;
if (typeString.startsWith(kIDLNamePrefix))
completeClassName = kIDLClassnamePrefix +
typeString.substring(kIDLNamePrefix.length()).replace('/",'.");
else completeClassName = typeString.replace('/",'.");
}
else if (repId.startsWith(kValuePrefix)) {
typeString =
repId.substring(kValuePrefixLength, repId.indexOf(':", kValuePrefixLength));
isRMIValueType = true;
if (versionString.indexOf('.") == -1) {
actualSuid = versionString.substring(1);
suid = actualSuid; // default if not explicitly specified
if (actualSuid.indexOf(':") != -1){
// we have a declared hash also
int pos = actualSuid.indexOf(':")+1;
// actualSuid = suid.substring(pos);
// suid = suid.substring(0, pos-1);
suid = actualSuid.substring(pos);
actualSuid = actualSuid.substring(0, pos-1);
}
}
else {
// _REVISIT_ : Special case version failure ?
}
}
else isSupportedFormat = false;
if (typeString.startsWith(kSequencePrefix)) {
isSequence = true;
}
return this;
}
|
public static boolean | isAbstractBase(java.lang.Class clazz)
return (clazz.isInterface() &&
IDLEntity.class.isAssignableFrom(clazz) &&
(!ValueBase.class.isAssignableFrom(clazz)) &&
(!org.omg.CORBA.Object.class.isAssignableFrom(clazz)));
|
public final boolean | isIDLType()
return isIDLType;
|
public final boolean | isRMIValueType()
return isRMIValueType;
|
public final boolean | isSequence()
return isSequence;
|
public final boolean | isSupportedFormat()
return isSupportedFormat;
|
private java.lang.Class | loadClassOfType(java.lang.String className, java.lang.String remoteCodebase, java.lang.ClassLoader loader, java.lang.Class expectedType, java.lang.ClassLoader expectedTypeClassLoader)
Class loadedClass = null;
try {
//Sequence finding of the stubs according to spec
try{
//If-else is put here for speed up of J2EE.
//According to the OMG spec, the if clause is not dead code.
//It can occur if some compiler has allowed generation
//into org.omg.stub hierarchy for non-offending
//classes. This will encourage people to
//produce non-offending class stubs in their own hierarchy.
if(!PackagePrefixChecker
.hasOffendingPrefix(PackagePrefixChecker
.withoutPackagePrefix(className))){
loadedClass = Util.loadClass
(PackagePrefixChecker.withoutPackagePrefix(className),
remoteCodebase,
loader);
} else {
loadedClass = Util.loadClass
(className,
remoteCodebase,
loader);
}
} catch (ClassNotFoundException cnfe) {
loadedClass = Util.loadClass
(className,
remoteCodebase,
loader);
}
if (expectedType == null)
return loadedClass;
} catch (ClassNotFoundException cnfe) {
if (expectedType == null)
throw cnfe;
}
// If no class was not loaded, or if the loaded class is not of the
// correct type, make a further attempt to load the correct class
// using the classloader of the expected type.
// _REVISIT_ Is this step necessary, or should the Util,loadClass
// algorithm always produce a valid class if the setup is correct?
// Does the OMG standard algorithm need to be changed to include
// this step?
if (loadedClass == null || !expectedType.isAssignableFrom(loadedClass)) {
if (expectedType.getClassLoader() != expectedTypeClassLoader)
throw new IllegalArgumentException("expectedTypeClassLoader not class loader of expectedType.");
if (expectedTypeClassLoader != null)
loadedClass = expectedTypeClassLoader.loadClass(className);
else
loadedClass = ORBClassLoader.loadClass(className);
}
return loadedClass;
|
private static java.lang.String | replace(java.lang.String target, java.lang.String arg, java.lang.String source)
int i = 0;
i = target.indexOf(arg);
while(i != -1)
{
String left = target.substring(0, i);
String right = target.substring(i+arg.length());
target = new String(left+source+right);
i = target.indexOf(arg);
}
return target;
|
public static void | setByteArray(java.lang.String repStr, byte[] repStrBytes)
synchronized (repStrToByteArray){
repStrToByteArray.put(repStr, repStrBytes);
}
|
public final java.lang.String | toString()
return repId;
|
public static boolean | useFullValueDescription(java.lang.Class clazz, java.lang.String repositoryID)Checks to see if the FullValueDescription should be retrieved.
String clazzRepIDStr = createForAnyType(clazz);
if (clazzRepIDStr.equals(repositoryID))
return false;
RepositoryId_1_3 targetRepid;
RepositoryId_1_3 clazzRepid;
synchronized(cache) {
// to avoid race condition where multiple threads could be
// accessing this method, and their access to the cache may
// be interleaved giving unexpected results
targetRepid = cache.getId(repositoryID);
clazzRepid = cache.getId(clazzRepIDStr);
}
if ((targetRepid.isRMIValueType()) && (clazzRepid.isRMIValueType())){
if (!targetRepid.getSerialVersionUID().equals(clazzRepid.getSerialVersionUID())) {
String mssg = "Mismatched serialization UIDs : Source (Rep. ID" +
clazzRepid + ") = " +
clazzRepid.getSerialVersionUID() + " whereas Target (Rep. ID " + repositoryID +
") = " + targetRepid.getSerialVersionUID();
throw new IOException(mssg);
} else {
return true;
}
} else {
throw new IOException("The repository ID is not of an RMI value type (Expected ID = " + clazzRepIDStr + "; Received ID = " + repositoryID +")");
}
|