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
|
/*******************************************************************************
* Copyright (c) 2006, 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.baseadaptor.hooks;
import java.net.URL;
import org.eclipse.osgi.baseadaptor.HookRegistry;
import org.eclipse.osgi.baseadaptor.bundlefile.BundleEntry;
import org.eclipse.osgi.baseadaptor.loader.ClasspathEntry;
import org.eclipse.osgi.baseadaptor.loader.ClasspathManager;
/**
* A ClassLoadingStatsHook hooks into the <code>ClasspathManager</code> class. This class allows
* a hook to record statistics about classloading.
* @see ClasspathManager
* @see HookRegistry#getClassLoadingStatsHooks()
* @see HookRegistry#addClassLoadingStatsHook(ClassLoadingStatsHook)
* @since 3.2
*/
public interface ClassLoadingStatsHook {
/**
* Gets called by a classpath manager during {@link ClasspathManager#findLocalClass(String)} before
* searching the local classloader for a class. A classpath manager will call this method for
* each configured class loading stat hook.
* @param name the name of the requested class
* @param manager the classpath manager used to find and load the requested class
* @throws ClassNotFoundException to prevent the requested class from loading
*/
void preFindLocalClass(String name, ClasspathManager manager) throws ClassNotFoundException;
/**
* Gets called by a classpath manager during {@link ClasspathManager#findLocalClass(String)} after
* searching the local classloader for a class. A classpath manager will call this method for
* each configured class loading stat hook.
* @param name the name of the requested class
* @param clazz the loaded class or null if not found
* @param manager the classpath manager used to find and load the requested class
*/
void postFindLocalClass(String name, Class<?> clazz, ClasspathManager manager) throws ClassNotFoundException;
/**
* Gets called by a classpath manager during {@link ClasspathManager#findLocalResource(String)} before
* searching the local classloader for a resource. A classpath manager will call this method for
* each configured class loading stat hook.
* @param name the name of the requested resource
* @param manager the classpath manager used to find the requested resource
*/
void preFindLocalResource(String name, ClasspathManager manager);
/**
* Gets called by a classpath manager during {@link ClasspathManager#findLocalResource(String)} after
* searching the local classloader for a resource. A classpath manager will call this method for
* each configured class loading stat hook.
* @param name the name of the requested resource
* @param resource the URL to the requested resource or null if not found
* @param manager the classpath manager used to find the requested resource
*/
void postFindLocalResource(String name, URL resource, ClasspathManager manager);
/**
* Gets called by a classpath manager after a successfully defining a class. This method allows
* a class loading stat hook to record data about a class definition.
* @param name the name of the class that got defined
* @param clazz the class object that got defined
* @param classbytes the class bytes used to define the class
* @param classpathEntry the ClasspathEntry where the class bytes got read from
* @param entry the BundleEntyr source of the class bytes
* @param manager the classpath manager used to define the class
*/
void recordClassDefine(String name, Class<?> clazz, byte[] classbytes, ClasspathEntry classpathEntry, BundleEntry entry, ClasspathManager manager);
}
|