public abstract class ClassLoaderHook extends Object
Constructor and Description |
---|
ClassLoaderHook() |
Modifier and Type | Method and Description |
---|---|
boolean |
addClassPathEntry(ArrayList<ClasspathEntry> cpEntries,
String cp,
ClasspathManager hostmanager,
BundleInfo.Generation sourceGeneration)
Gets called by a classpath manager when looking for ClasspathEntry objects.
|
void |
classLoaderCreated(ModuleClassLoader classLoader)
Gets called by a classpath manager at the end of
BundleLoader.getClassLoader() is called the first time and a class loader is created. |
ModuleClassLoader |
createClassLoader(ClassLoader parent,
EquinoxConfiguration configuration,
BundleLoader delegate,
BundleInfo.Generation generation)
Gets called by a bundle loader when
BundleLoader.getClassLoader()
is called the first time in order to allow a hook to create the class loader. |
String |
findLocalLibrary(BundleInfo.Generation generation,
String libName)
Gets called by a base data during
ModuleClassLoader.findLibrary(String) . |
ClassLoader |
getModuleClassLoaderParent(EquinoxConfiguration configuration)
Returns the parent class loader to be used by all ModuleClassLoaders.
|
Class<?> |
postFindClass(String name,
ModuleClassLoader classLoader)
Called by a
BundleLoader.findClass(String) method after delegating to the resolved constraints and
local bundle for a class load. |
String |
postFindLibrary(String name,
ModuleClassLoader classLoader)
Called by a
ClasspathManager after normal delegation. |
void |
postFindLocalClass(String name,
Class<?> clazz,
ClasspathManager manager)
Gets called by a classpath manager during
ClasspathManager.findLocalClass(String) after
searching the local classloader for a class. |
void |
postFindLocalResource(String name,
URL resource,
ClasspathManager manager)
Gets called by a classpath manager during
ClasspathManager.findLocalResource(String) after
searching the local classloader for a resource. |
URL |
postFindResource(String name,
ModuleClassLoader classLoader)
Called by a
BundleLoader.findResource(String) after delegating to the resolved constraints and
local bundle for a resource load. |
Enumeration<URL> |
postFindResources(String name,
ModuleClassLoader classLoader)
Called by a
BundleLoader.findResources(String) after delegating to the resolved constraints and
local bundle for a resource load. |
Class<?> |
preFindClass(String name,
ModuleClassLoader classLoader)
Called by a
BundleLoader.findClass(String) method before delegating to the resolved constraints and
local bundle for a class load. |
String |
preFindLibrary(String name,
ModuleClassLoader classLoader)
Called by a
ClasspathManager before normal delegation. |
void |
preFindLocalClass(String name,
ClasspathManager manager)
Gets called by a classpath manager during
ClasspathManager.findLocalClass(String) before
searching the local classloader for a class. |
void |
preFindLocalResource(String name,
ClasspathManager manager)
Gets called by a classpath manager during
ClasspathManager.findLocalResource(String) before
searching the local classloader for a resource. |
URL |
preFindResource(String name,
ModuleClassLoader classLoader)
Called by a
BundleLoader.findResource(String) before delegating to the resolved constraints and
local bundle for a resource load. |
Enumeration<URL> |
preFindResources(String name,
ModuleClassLoader classLoader)
Called by a
BundleLoader.findResources(String) before delegating to the resolved constraints and
local bundle for a resource load. |
byte[] |
processClass(String name,
byte[] classbytes,
ClasspathEntry classpathEntry,
BundleEntry entry,
ClasspathManager manager)
Gets called by a classpath manager before defining a class.
|
void |
recordClassDefine(String name,
Class<?> clazz,
byte[] classbytes,
ClasspathEntry classpathEntry,
BundleEntry entry,
ClasspathManager manager)
Gets called by a classpath manager after an attempt is made to define a class.
|
boolean |
rejectTransformation(String name,
byte[] transformedBytes,
ClasspathEntry classpathEntry,
BundleEntry entry,
ClasspathManager manager)
Gets called by a classpath manager before defining a class.
|
public byte[] processClass(String name, byte[] classbytes, ClasspathEntry classpathEntry, BundleEntry entry, ClasspathManager manager)
name
- the name of the class being definedclassbytes
- the bytes of the class being definedclasspathEntry
- the ClasspathEntry where the class bytes have been read from.entry
- the BundleEntry source of the class bytesmanager
- the class path manager used to define the requested classpublic boolean rejectTransformation(String name, byte[] transformedBytes, ClasspathEntry classpathEntry, BundleEntry entry, ClasspathManager manager)
processClass
method.name
- the name of the class being definedtransformedBytes
- the transformed bytes of the class being definedclasspathEntry
- the ClasspathEntry where the class bytes have been read fromentry
- the BundleEntry source of the class bytesmanager
- the class path manager used to define the requested classpublic boolean addClassPathEntry(ArrayList<ClasspathEntry> cpEntries, String cp, ClasspathManager hostmanager, BundleInfo.Generation sourceGeneration)
cpEntries
- the list of ClasspathEntry objects currently available for the requested classpathcp
- the name of the requested classpathhostmanager
- the classpath manager the requested ClasspathEntry is forsourceGeneration
- the source generation of the requested ClasspathEntrypublic String findLocalLibrary(BundleInfo.Generation generation, String libName)
ModuleClassLoader.findLibrary(String)
.
A this method is called for each configured class loading hook until one
class loading hook returns a non-null value. If no class loading hook returns
a non-null value then the default behavior will be used.generation
- the bundle generation to find a native library for.libName
- the name of the native library.public ModuleClassLoader createClassLoader(ClassLoader parent, EquinoxConfiguration configuration, BundleLoader delegate, BundleInfo.Generation generation)
BundleLoader.getClassLoader()
is called the first time in order to allow a hook to create the class loader.
This should rarely, if ever be overridden. The default implementation
returns null indicating the built-in implementation should be used.
Only one hook is able to provide the implementation of the module class loader
and the first one to return non-null wins.parent
- the parent classloaderconfiguration
- the equinox configurationdelegate
- the delegate for this classloadergeneration
- the generation for this class loadernull
if the built-in implemention is to be used.public void classLoaderCreated(ModuleClassLoader classLoader)
BundleLoader.getClassLoader()
is called the first time and a class loader is created.classLoader
- the newly created bundle classloaderpublic Class<?> preFindClass(String name, ModuleClassLoader classLoader) throws ClassNotFoundException
BundleLoader.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 ClassNotFoundException
then the calling
BundleLoader.findClass(String)
method re-throws the exception.name
- the name of the class to findclassLoader
- the module class loaderClassNotFoundException
- to terminate the delegation and throw an exceptionpublic Class<?> postFindClass(String name, ModuleClassLoader classLoader) throws ClassNotFoundException
BundleLoader.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.name
- the name of the class to findclassLoader
- the bundle class loaderClassNotFoundException
- to terminate the delegation and throw an exceptionpublic URL preFindResource(String name, ModuleClassLoader classLoader) throws FileNotFoundException
BundleLoader.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 FileNotFoundException
then the delegation is terminated.name
- the name of the resource to findclassLoader
- the bundle class loaderFileNotFoundException
- to terminate the delegationpublic URL postFindResource(String name, ModuleClassLoader classLoader) throws FileNotFoundException
BundleLoader.findResource(String)
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.name
- the name of the resource to findclassLoader
- the bundle class loaderFileNotFoundException
- to terminate the delegationpublic Enumeration<URL> preFindResources(String name, ModuleClassLoader classLoader) throws FileNotFoundException
BundleLoader.findResources(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 FileNotFoundException
then the delegation is terminatedname
- the name of the resource to findclassLoader
- the bundle class loaderFileNotFoundException
- to terminate the delegationpublic Enumeration<URL> postFindResources(String name, ModuleClassLoader classLoader) throws FileNotFoundException
BundleLoader.findResources(String)
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.name
- the name of the resource to findclassLoader
- the bundle class loaderFileNotFoundException
- to terminate the delegationpublic String preFindLibrary(String name, ModuleClassLoader classLoader) throws FileNotFoundException
ClasspathManager
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.name
- the name of the library to findclassLoader
- the bundle class loaderFileNotFoundException
- to terminate the delegationpublic String postFindLibrary(String name, ModuleClassLoader classLoader)
ClasspathManager
after normal delegation. This method will only be called
if no library was found from the normal delegation.name
- the name of the library to findclassLoader
- the bundle class loaderpublic void preFindLocalClass(String name, ClasspathManager manager) throws ClassNotFoundException
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.name
- the name of the requested classmanager
- the classpath manager used to find and load the requested classClassNotFoundException
- to prevent the requested class from loadingpublic void postFindLocalClass(String name, Class<?> clazz, ClasspathManager manager) throws ClassNotFoundException
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.name
- the name of the requested classclazz
- the loaded class or null if not foundmanager
- the classpath manager used to find and load the requested classClassNotFoundException
public void preFindLocalResource(String name, ClasspathManager manager)
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.name
- the name of the requested resourcemanager
- the classpath manager used to find the requested resourcepublic void postFindLocalResource(String name, URL resource, ClasspathManager manager)
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.name
- the name of the requested resourceresource
- the URL to the requested resource or null if not foundmanager
- the classpath manager used to find the requested resourcepublic void recordClassDefine(String name, Class<?> clazz, byte[] classbytes, ClasspathEntry classpathEntry, BundleEntry entry, ClasspathManager manager)
name
- the name of the class that got definedclazz
- the class object that got defined or null if an error occurred while defining a classclassbytes
- the class bytes used to define the classclasspathEntry
- the ClasspathEntry where the class bytes got read fromentry
- the BundleEntyr source of the class bytesmanager
- the classpath manager used to define the classpublic ClassLoader getModuleClassLoaderParent(EquinoxConfiguration configuration)
null
value may be returned if this hook does not supply the parent.
Only one hook is able to provide the implementation of the parent class loader
and the first one to return non-null wins.configuration
- the equinox configurationCopyright © 2012–2018. All rights reserved.