01: /* JFox, the OpenSource J2EE Application Server
02: *
03: * Copyright (C) 2002 huihoo.com
04: * Distributable under GNU LGPL license
05: * See the GNU Lesser General Public License for more details.
06: */
07:
08: package org.huihoo.jfox.jmx.loading;
09:
10: import java.io.ObjectInputStream;
11: import java.io.IOException;
12: import java.io.ObjectStreamClass;
13: import java.io.InputStream;
14:
15: /**
16: *
17: * @author <a href="mailto:young_yy@hotmail.com">Young Yang</a>
18: */
19:
20: public class ObjectInputStreamLoader extends ObjectInputStream {
21:
22: private ClassLoader loader;
23:
24: public ObjectInputStreamLoader(InputStream in, ClassLoader loader)
25: throws IOException {
26: super (in);
27: this .loader = loader;
28: }
29:
30: protected Class resolveClass(ObjectStreamClass osc)
31: throws IOException, ClassNotFoundException {
32: if (loader == null) {
33: return super .resolveClass(osc);
34: } else {
35: String className = osc.getName();
36: Class cls = loader.loadClass(className);
37: return cls;
38: }
39: }
40:
41: }
|