Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 424feb98a00d23031d4fef989e8d82cf4048afa0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/*******************************************************************************
 * Copyright (c) 2008, 2010 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/

package org.eclipse.osgi.framework.adaptor;

import java.io.FileNotFoundException;
import java.net.URL;
import java.util.Enumeration;
import org.eclipse.osgi.baseadaptor.HookRegistry;

/**
 * A ClassLoaderDelegateHook hooks into the <code>ClassLoaderDelegate</code>.
 * @see ClassLoaderDelegate
 * @see HookRegistry#getClassLoaderDelegateHooks()
 * @see HookRegistry#addClassLoaderDelegateHook(ClassLoaderDelegateHook)
 * @since 3.4
 */
public interface ClassLoaderDelegateHook {
	/**
	 * Called by a {@link ClassLoaderDelegate#findClass(String)} method before delegating to the resolved constraints and 
	 * local bundle for a class load.  If this method returns null then normal delegation is done.  If this method 
	 * returns a non-null value then the rest of the delegation process is skipped and the returned value is used.
	 * If this method throws a <code>ClassNotFoundException</code> then the calling 
	 * {@link ClassLoaderDelegate#findClass(String)} method re-throws the exception.
	 * @param name the name of the class to find
	 * @param classLoader the bundle class loader
	 * @param data the bundle data
	 * @return the class found by this hook or null if normal delegation should continue
	 * @throws ClassNotFoundException to terminate the delegation and throw an exception
	 */
	public Class<?> preFindClass(String name, BundleClassLoader classLoader, BundleData data) throws ClassNotFoundException;

	/**
	 * Called by a {@link ClassLoaderDelegate#findClass(String)} method after delegating to the resolved constraints and 
	 * local bundle for a class load.  This method will only be called if no class was found
	 * from the normal delegation.
	 * @param name the name of the class to find
	 * @param classLoader the bundle class loader
	 * @param data the bundle data
	 * @return the class found by this hook or null if normal delegation should continue
	 * @throws ClassNotFoundException to terminate the delegation and throw an exception
	 */
	public Class<?> postFindClass(String name, BundleClassLoader classLoader, BundleData data) throws ClassNotFoundException;

	/**
	 * Called by a {@link ClassLoaderDelegate #findResource(String)} before delegating to the resolved constraints and 
	 * local bundle for a resource load.  If this method returns null then normal delegation is done.  
	 * If this method returns a non-null value then the rest of the delegation process is skipped and the returned value is used.
	 * If this method throws an <code>FileNotFoundException</code> then the delegation is terminated.
	 * @param name the name of the resource to find
	 * @param classLoader the bundle class loader
	 * @param data the bundle data
	 * @return the resource found by this hook or null if normal delegation should continue
	 * @throws FileNotFoundException to terminate the delegation
	 */
	public URL preFindResource(String name, BundleClassLoader classLoader, BundleData data) throws FileNotFoundException;

	/**
	 * Called by a {@link ClassLoaderDelegate} after delegating to the resolved constraints and 
	 * local bundle for a resource load.  This method will only be called if no resource was found
	 * from the normal delegation.
	 * @param name the name of the resource to find
	 * @param classLoader the bundle class loader
	 * @param data the bundle data
	 * @return the resource found by this hook or null if normal delegation should continue
	 * @throws FileNotFoundException to terminate the delegation
	 */
	public URL postFindResource(String name, BundleClassLoader classLoader, BundleData data) throws FileNotFoundException;

	/**
	 * Called by a {@link ClassLoaderDelegate} before delegating to the resolved constraints and 
	 * local bundle for a resource load.  If this method returns null then normal delegation is done.  
	 * If this method returns  a non-null value then the rest of the delegation process is skipped and the returned value is used.
	 * If this method throws an <code>FileNotFoundException</code> then the delegation is terminated
	 * @param name the name of the resource to find
	 * @param classLoader the bundle class loader
	 * @param data the bundle data
	 * @return the resources found by this hook or null if normal delegation should continue
	 * @throws FileNotFoundException to terminate the delegation
	 */
	public Enumeration<URL> preFindResources(String name, BundleClassLoader classLoader, BundleData data) throws FileNotFoundException;

	/**
	 * Called by a {@link ClassLoaderDelegate} after delegating to the resolved constraints and 
	 * local bundle for a resource load.  This method will only be called if no resources were found
	 * from the normal delegation.
	 * @param name the name of the resource to find
	 * @param classLoader the bundle class loader
	 * @param data the bundle data
	 * @return the resources found by this hook or null if normal delegation should continue
	 * @throws FileNotFoundException to terminate the delegation
	 */
	public Enumeration<URL> postFindResources(String name, BundleClassLoader classLoader, BundleData data) throws FileNotFoundException;

	/**
	 * Called by a {@link ClassLoaderDelegate} before normal delegation.  If this method returns 
	 * a non-null value then the rest of the delegation process is skipped and the returned value
	 * is used.
	 * @param name the name of the library to find
	 * @param classLoader the bundle class loader
	 * @param data the bundle data
	 * @return the library found by this hook or null if normal delegation should continue
	 * @throws FileNotFoundException to terminate the delegation
	 */
	public String preFindLibrary(String name, BundleClassLoader classLoader, BundleData data) throws FileNotFoundException;

	/**
	 * Called by a {@link ClassLoaderDelegate} after normal delegation.  This method will only be called
	 * if no library was found from the normal delegation.
	 * @param name the name of the library to find
	 * @param classLoader the bundle class loader
	 * @param data the bundle data
	 * @return the library found by this hook or null if normal delegation should continue
	 */
	public String postFindLibrary(String name, BundleClassLoader classLoader, BundleData data);
}

Back to the top