KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > jmx > remote > util > ClassLoaderWithRepository


1 /*
2  * @(#)ClassLoaderWithRepository.java 1.7 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package com.sun.jmx.remote.util;
9
10 import javax.management.loading.ClassLoaderRepository JavaDoc;
11
12 public class ClassLoaderWithRepository extends ClassLoader JavaDoc {
13     public ClassLoaderWithRepository(ClassLoaderRepository JavaDoc clr,
14                      ClassLoader JavaDoc cl2) {
15
16     if (clr == null) throw new
17         IllegalArgumentException JavaDoc("Null ClassLoaderRepository object.");
18
19     repository = clr;
20     this.cl2 = cl2;
21    }
22
23     protected Class JavaDoc findClass(String JavaDoc name) throws ClassNotFoundException JavaDoc {
24     try {
25         return repository.loadClass(name);
26     } catch (ClassNotFoundException JavaDoc cne) {
27         if (cl2 != null) {
28         return cl2.loadClass(name);
29         } else {
30         throw cne;
31         }
32     }
33     }
34
35     private ClassLoaderRepository JavaDoc repository;
36     private ClassLoader JavaDoc cl2;
37 }
38
Popular Tags