01: // Copyright 2004, 2005 The Apache Software Foundation
02: //
03: // Licensed under the Apache License, Version 2.0 (the "License");
04: // you may not use this file except in compliance with the License.
05: // You may obtain a copy of the License at
06: //
07: // http://www.apache.org/licenses/LICENSE-2.0
08: //
09: // Unless required by applicable law or agreed to in writing, software
10: // distributed under the License is distributed on an "AS IS" BASIS,
11: // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: // See the License for the specific language governing permissions and
13: // limitations under the License.
14:
15: package org.apache.hivemind;
16:
17: import java.net.URL;
18:
19: /**
20: * An object which is used to resolve classes and class-path resources. This is needed because, in
21: * an application server, different class loaders may be involved in loading different HiveMind
22: * modules. For example, the HiveMind library may be on the system claasspath, and modules may
23: * include EJBs and WARs, each loaded by a different classloader.
24: * <p>
25: * The class loader for the framework needs to be able to see resources in the application, but the
26: * application's class loader is a descendent of the framework's class loader. To resolve this, we
27: * need a 'hook', an instance that provides access to the application's class loader.
28: *
29: * @author Howard Lewis Ship
30: */
31:
32: public interface ClassResolver {
33: /**
34: * Forwarded, unchanged, to the class loader. Returns null if the resource is not found.
35: */
36:
37: public URL getResource(String name);
38:
39: /**
40: * Forwarded, to the the method <code>Class.forName(String, boolean, ClassLoader)</code>,
41: * using the resolver's class loader.
42: * <p>
43: * Since 1.1, the type may include primitive types and arrays (of primitives or of objects).
44: *
45: * @throws ApplicationRuntimeException
46: * on any error.
47: */
48:
49: public Class findClass(String type);
50:
51: /**
52: * Like {@link #findClass(String)}, but simply returns null if the class does not exist (i.e.,
53: * if {@link ClassNotFoundException} is thrown). This is used in certain spots when (typically)
54: * the exact package for a class is not known.
55: */
56:
57: public Class checkForClass(String type);
58:
59: /**
60: * Returns a {@link java.lang.ClassLoader} that can see all the classes the resolver can access.
61: */
62:
63: public ClassLoader getClassLoader();
64: }
|