01: /*
02: * Copyright (C) The MX4J Contributors.
03: * All rights reserved.
04: *
05: * This software is distributed under the terms of the MX4J License version 1.0.
06: * See the terms of the MX4J License in the documentation provided with this software.
07: */
08:
09: package javax.management.loading;
10:
11: import java.util.ArrayList;
12: import javax.management.MBeanServer;
13: import javax.management.MBeanServerFactory;
14:
15: /**
16: * @version $Revision: 1.7 $
17: * @deprecated No replacement. Just throw away all code that referenced this class, and use
18: * {@link javax.management.MBeanServer#getClassLoaderRepository} instead.
19: */
20: public class DefaultLoaderRepository {
21: public DefaultLoaderRepository() {
22: }
23:
24: public static Class loadClass(String className)
25: throws ClassNotFoundException {
26: return loadClassWithout(null, className);
27: }
28:
29: public static Class loadClassWithout(ClassLoader loader,
30: String className) throws ClassNotFoundException {
31: ArrayList servers = MBeanServerFactory.findMBeanServer(null);
32: for (int i = 0; i < servers.size(); ++i) {
33: MBeanServer server = (MBeanServer) servers.get(i);
34: ClassLoaderRepository repository = server
35: .getClassLoaderRepository();
36: try {
37: return repository.loadClassWithout(loader, className);
38: } catch (ClassNotFoundException ignored) {
39: }
40: }
41: throw new ClassNotFoundException(className);
42: }
43: }
|