22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package com.sun.jmx.remote.util;
27
28 import javax.management.loading.ClassLoaderRepository;
29
30 public class ClassLoaderWithRepository extends ClassLoader {
31 public ClassLoaderWithRepository(ClassLoaderRepository clr,
32 ClassLoader cl2) {
33
34 if (clr == null) throw new
35 IllegalArgumentException("Null ClassLoaderRepository object.");
36
37 repository = clr;
38 this.cl2 = cl2;
39 }
40
41 protected Class findClass(String name) throws ClassNotFoundException {
42 try {
43 return repository.loadClass(name);
44 } catch (ClassNotFoundException cne) {
45 if (cl2 != null) {
46 return cl2.loadClass(name);
47 } else {
48 throw cne;
49 }
50 }
51 }
52
53 private ClassLoaderRepository repository;
54 private ClassLoader cl2;
55 }
|
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package com.sun.jmx.remote.util;
27
28 import javax.management.loading.ClassLoaderRepository;
29
30 public class ClassLoaderWithRepository extends ClassLoader {
31 public ClassLoaderWithRepository(ClassLoaderRepository clr,
32 ClassLoader cl2) {
33
34 if (clr == null) throw new
35 IllegalArgumentException("Null ClassLoaderRepository object.");
36
37 repository = clr;
38 this.cl2 = cl2;
39 }
40
41 protected Class findClass(String name) throws ClassNotFoundException {
42 Class<?> cls;
43 try {
44 cls = repository.loadClass(name);
45 } catch (ClassNotFoundException cne) {
46 if (cl2 != null) {
47 return cl2.loadClass(name);
48 } else {
49 throw cne;
50 }
51 }
52
53 if(!cls.getName().equals(name)){
54 if (cl2 != null) {
55 return cl2.loadClass(name);
56 } else {
57 throw new ClassNotFoundException(name);
58 }
59 }
60 return cls;
61 }
62
63 private ClassLoaderRepository repository;
64 private ClassLoader cl2;
65 }
|