KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > osgi > framework > adaptor > ClassLoaderDelegate


1 /*******************************************************************************
2  * Copyright (c) 2004, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.osgi.framework.adaptor;
13
14 import java.io.IOException JavaDoc;
15 import java.net.URL JavaDoc;
16 import java.util.Enumeration JavaDoc;
17
18 /**
19  * A ClassLoaderDelegate is used by the BundleClassLoader in a similar
20  * fashion that a parent ClassLoader is used. A ClassLoaderDelegate must
21  * be queried for any resource or class before it is loaded by the
22  * BundleClassLoader. The Framework implements the ClassLoaderDelegate
23  * and supplies it to the BundleClassLoader. FrameworkAdaptor implementations
24  * are not responsible for suppling an implementation for ClassLoaderDelegate.
25  * <p>
26  * This interface is not intended to be implemented by clients.
27  * </p>
28  * @since 3.1
29  */

30 public interface ClassLoaderDelegate {
31     /**
32      * Finds a class for a bundle that may be outside of the actual bundle
33      * (i.e. a class from an imported package or required bundle).<p>
34      *
35      * If the class does not belong to an imported package or is not
36      * found in a required bundle then the ClassloaderDelegate will call
37      * BundleClassLoader.findLocalClass(). <p>
38      *
39      * If no class is found then a ClassNotFoundException is thrown.
40      * @param classname the class to find.
41      * @return the Class.
42      * @throws ClassNotFoundException if the class is not found.
43      */

44     public Class JavaDoc findClass(String JavaDoc classname) throws ClassNotFoundException JavaDoc;
45
46     /**
47      * Finds a resource for a bundle that may be outside of the actual bundle
48      * (i.e. a resource from an imported package or required bundle).<p>
49      *
50      * If the resource does not belong to an imported package or is not
51      * found in a required bundle then the ClassloaderDelegate will call
52      * BundleClassLoader.findLocalResource(). <p>
53      *
54      * If no resource is found then return null.
55      * @param resource the resource to load.
56      * @return the resource or null if resource is not found.
57      */

58     public URL JavaDoc findResource(String JavaDoc resource);
59
60     /**
61      * Finds an enumeration of resources for a bundle that may be outside of
62      * the actual bundle (i.e. a resource from an imported package or required
63      * bundle).<p>
64      *
65      * If the resource does not belong to an imported package or is not
66      * found in a required bundle then the ClassloaderDelegate will call
67      * BundleClassLoader.findLocalResource(). <p>
68      * If no resource is found then return null.
69      * @param resource the resource to find.
70      * @return the enumeration of resources found or null if the resource
71      * does not exist.
72      */

73     public Enumeration JavaDoc findResources(String JavaDoc resource) throws IOException JavaDoc;
74
75     /**
76      * Returns the absolute path name of a native library. The following is
77      * a list of steps that a ClassLoaderDelegate must take when trying to
78      * find a library:
79      * <ul>
80      * <li>If the bundle is a fragment then try to find the library in the
81      * host bundle.
82      * <li>if the bundle is a host then try to find the library in the
83      * host bundle and then try to find the library in the fragment
84      * bundles.
85      * </ul>
86      * If no library is found return null.
87      * @param libraryname the library to find the path to.
88      * @return the path to the library or null if not found.
89      */

90     public String JavaDoc findLibrary(String JavaDoc libraryname);
91
92 }
93
Popular Tags