org.eclipse.osgi.internal.baseadaptor.weaving
Class WeavingHookConfigurator

java.lang.Object
  extended by org.eclipse.osgi.internal.baseadaptor.weaving.WeavingHookConfigurator
All Implemented Interfaces:
HookConfigurator, ClassLoadingHook, ClassLoadingStatsHook

public class WeavingHookConfigurator
extends Object
implements HookConfigurator, ClassLoadingHook, ClassLoadingStatsHook


Constructor Summary
WeavingHookConfigurator()
           
 
Method Summary
 boolean addClassPathEntry(ArrayList<ClasspathEntry> cpEntries, String cp, ClasspathManager hostmanager, BaseData sourcedata, ProtectionDomain sourcedomain)
          Gets called by a classpath manager when looking for ClasspathEntry objects.
 void addHooks(HookRegistry hookRegistry)
          Adds hooks to the specified hook registry.
 BaseClassLoader createClassLoader(ClassLoader parent, ClassLoaderDelegate delegate, BundleProtectionDomain domain, BaseData data, String[] bundleclasspath)
          Gets called by a base data during BundleData.createClassLoader(ClassLoaderDelegate, BundleProtectionDomain, String[]).
 String findLibrary(BaseData data, String libName)
          Gets called by a base data during BundleData.findLibrary(String).
 ClassLoader getBundleClassLoaderParent()
          Gets called by the adaptor during FrameworkAdaptor.getBundleClassLoaderParent().
 void initializedClassLoader(BaseClassLoader baseClassLoader, BaseData data)
          Gets called by a classpath manager at the end of ClasspathManager.initialize().
 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.
 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.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WeavingHookConfigurator

public WeavingHookConfigurator()
Method Detail

addHooks

public void addHooks(HookRegistry hookRegistry)
Description copied from interface: HookConfigurator
Adds hooks to the specified hook registry.

Specified by:
addHooks in interface HookConfigurator
Parameters:
hookRegistry - the hook registry used to add hooks

processClass

public byte[] processClass(String name,
                           byte[] classbytes,
                           ClasspathEntry classpathEntry,
                           BundleEntry entry,
                           ClasspathManager manager)
Description copied from interface: ClassLoadingHook
Gets called by a classpath manager before defining a class. This method allows a class loading hook to process the bytes of a class that is about to be defined.

Specified by:
processClass in interface ClassLoadingHook
Parameters:
name - the name of the class being defined
classbytes - the bytes of the class being defined
classpathEntry - the ClasspathEntry where the class bytes have been read from.
entry - the BundleEntry source of the class bytes
manager - the class path manager used to define the requested class
Returns:
a modified array of classbytes or null if the original bytes should be used.

addClassPathEntry

public boolean addClassPathEntry(ArrayList<ClasspathEntry> cpEntries,
                                 String cp,
                                 ClasspathManager hostmanager,
                                 BaseData sourcedata,
                                 ProtectionDomain sourcedomain)
Description copied from interface: ClassLoadingHook
Gets called by a classpath manager when looking for ClasspathEntry objects. This method allows a classloading hook to add additional ClasspathEntry objects

Specified by:
addClassPathEntry in interface ClassLoadingHook
Parameters:
cpEntries - the list of ClasspathEntry objects currently available for the requested classpath
cp - the name of the requested classpath
hostmanager - the classpath manager the requested ClasspathEntry is for
sourcedata - the source bundle data of the requested ClasspathEntry
sourcedomain - the source domain of the requested ClasspathEntry
Returns:
true if a ClasspathEntry has been added to cpEntries

findLibrary

public String findLibrary(BaseData data,
                          String libName)
Description copied from interface: ClassLoadingHook
Gets called by a base data during BundleData.findLibrary(String). A base data will call this method 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 base data will return null.

Specified by:
findLibrary in interface ClassLoadingHook
Parameters:
data - the base data to find a native library for.
libName - the name of the native library.
Returns:
The absolute path name of the native library or null.

getBundleClassLoaderParent

public ClassLoader getBundleClassLoaderParent()
Description copied from interface: ClassLoadingHook
Gets called by the adaptor during FrameworkAdaptor.getBundleClassLoaderParent(). The adaptor will call this method 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 adaptor will perform the default behavior.

Specified by:
getBundleClassLoaderParent in interface ClassLoadingHook
Returns:
the parent classloader to be used by all bundle classloaders or null.

createClassLoader

public BaseClassLoader createClassLoader(ClassLoader parent,
                                         ClassLoaderDelegate delegate,
                                         BundleProtectionDomain domain,
                                         BaseData data,
                                         String[] bundleclasspath)
Description copied from interface: ClassLoadingHook
Gets called by a base data during BundleData.createClassLoader(ClassLoaderDelegate, BundleProtectionDomain, String[]). The BaseData will call this method for each configured class loading hook until one data hook returns a non-null value. If no class loading hook returns a non-null value then a default implemenation of BundleClassLoader will be created.

Specified by:
createClassLoader in interface ClassLoadingHook
Parameters:
parent - the parent classloader for the BundleClassLoader
delegate - the delegate for the bundle classloader
domain - the domian for the bundle classloader
data - the BundleData for the BundleClassLoader
bundleclasspath - the classpath for the bundle classloader
Returns:
a newly created bundle classloader

initializedClassLoader

public void initializedClassLoader(BaseClassLoader baseClassLoader,
                                   BaseData data)
Description copied from interface: ClassLoadingHook
Gets called by a classpath manager at the end of ClasspathManager.initialize(). The classpath manager will call this method for each configured class loading hook after it has been initialized.

Specified by:
initializedClassLoader in interface ClassLoadingHook
Parameters:
baseClassLoader - the newly created bundle classloader
data - the BundleData associated with the bundle classloader

preFindLocalClass

public void preFindLocalClass(String name,
                              ClasspathManager manager)
Description copied from interface: ClassLoadingStatsHook
Gets called by a classpath manager during 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.

Specified by:
preFindLocalClass in interface ClassLoadingStatsHook
Parameters:
name - the name of the requested class
manager - the classpath manager used to find and load the requested class

postFindLocalClass

public void postFindLocalClass(String name,
                               Class<?> clazz,
                               ClasspathManager manager)
Description copied from interface: ClassLoadingStatsHook
Gets called by a classpath manager during 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.

Specified by:
postFindLocalClass in interface ClassLoadingStatsHook
Parameters:
name - the name of the requested class
clazz - the loaded class or null if not found
manager - the classpath manager used to find and load the requested class

preFindLocalResource

public void preFindLocalResource(String name,
                                 ClasspathManager manager)
Description copied from interface: ClassLoadingStatsHook
Gets called by a classpath manager during 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.

Specified by:
preFindLocalResource in interface ClassLoadingStatsHook
Parameters:
name - the name of the requested resource
manager - the classpath manager used to find the requested resource

postFindLocalResource

public void postFindLocalResource(String name,
                                  URL resource,
                                  ClasspathManager manager)
Description copied from interface: ClassLoadingStatsHook
Gets called by a classpath manager during 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.

Specified by:
postFindLocalResource in interface ClassLoadingStatsHook
Parameters:
name - the name of the requested resource
resource - the URL to the requested resource or null if not found
manager - the classpath manager used to find the requested resource

recordClassDefine

public void recordClassDefine(String name,
                              Class<?> clazz,
                              byte[] classbytes,
                              ClasspathEntry classpathEntry,
                              BundleEntry entry,
                              ClasspathManager manager)
Description copied from interface: ClassLoadingStatsHook
Gets called by a classpath manager after an attempt is made to define a class. This method allows a class loading stat hook to record data about a class definition.

Specified by:
recordClassDefine in interface ClassLoadingStatsHook
Parameters:
name - the name of the class that got defined
clazz - the class object that got defined or null if an error occurred while defining a class
classbytes - the class bytes used to define the class
classpathEntry - the ClasspathEntry where the class bytes got read from
entry - the BundleEntyr source of the class bytes
manager - the classpath manager used to define the class


Copyright © 2007–2014 The Apache Software Foundation. All rights reserved.