1:
38:
39:
40: package ;
41:
42: import ;
43: import ;
44: import ;
45: import ;
46: import ;
47: import ;
48: import ;
49:
50: public class RMIObjectInputStream
51: extends ObjectInputStream {
52:
53: public RMIObjectInputStream(InputStream strm) throws IOException {
54: super(strm);
55: enableResolveObject(true);
56: }
57:
58: protected Class resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException {
59: String annotation = (String)getAnnotation();
60:
61: try {
62: if(annotation == null)
63: return (RMIClassLoader.loadClass(desc.getName()));
64: else
65: return (RMIClassLoader.loadClass(annotation, desc.getName()));
66: }
67: catch (MalformedURLException _) {
68: throw new ClassNotFoundException(desc.getName());
69: }
70: }
71:
72:
73: protected Object getAnnotation()
74: throws IOException, ClassNotFoundException
75: {
76: return readObject();
77: }
78:
79: protected Class resolveProxyClass(String intfs[])
80: throws IOException, ClassNotFoundException
81: {
82: String annotation = (String)getAnnotation();
83:
84: Class clss[] = new Class[intfs.length];
85: if(annotation == null)
86: clss[0] = RMIClassLoader.loadClass(intfs[0]);
87: else
88: clss[0] = RMIClassLoader.loadClass(annotation, intfs[0]);
89:
90:
91: ClassLoader loader = clss[0].getClassLoader();
92: for (int i = 0; i < intfs.length; i++)
93: clss[i] = Class.forName(intfs[i], false, loader);
94:
95: try {
96: return Proxy.getProxyClass(loader, clss);
97: } catch (IllegalArgumentException e) {
98: throw new ClassNotFoundException(null, e);
99: }
100: }
101:
102: protected Object readValue(Class valueClass) throws IOException, ClassNotFoundException {
103: if(valueClass.isPrimitive()){
104: if(valueClass == Boolean.TYPE)
105: return Boolean.valueOf(readBoolean());
106: if(valueClass == Byte.TYPE)
107: return new Byte(readByte());
108: if(valueClass == Character.TYPE)
109: return new Character(readChar());
110: if(valueClass == Short.TYPE)
111: return new Short(readShort());
112: if(valueClass == Integer.TYPE)
113: return new Integer(readInt());
114: if(valueClass == Long.TYPE)
115: return new Long(readLong());
116: if(valueClass == Float.TYPE)
117: return new Float(readFloat());
118: if(valueClass == Double.TYPE)
119: return new Double(readDouble());
120: else
121: throw new Error("Unsupported primitive class: " + valueClass);
122: } else
123: return readObject();
124: }
125:
126: }