org.eclipse.core.runtime.internal.adaptor
Class EclipseClassLoadingHook

java.lang.Object
  extended by org.eclipse.core.runtime.internal.adaptor.EclipseClassLoadingHook
All Implemented Interfaces:
HookConfigurator, ClassLoadingHook

public class EclipseClassLoadingHook
extends java.lang.Object
implements ClassLoadingHook, HookConfigurator


Constructor Summary
EclipseClassLoadingHook()
           
 
Method Summary
 boolean addClassPathEntry(java.util.ArrayList cpEntries, java.lang.String cp, ClasspathManager hostmanager, BaseData sourcedata, java.security.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(java.lang.ClassLoader parent, ClassLoaderDelegate delegate, BundleProtectionDomain domain, BaseData data, java.lang.String[] bundleclasspath)
          Gets called by a base data during BundleData.createClassLoader(ClassLoaderDelegate, BundleProtectionDomain, String[]).
 java.lang.String findLibrary(BaseData data, java.lang.String libName)
          Gets called by a base data during BundleData.findLibrary(String).
 java.lang.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().
 byte[] processClass(java.lang.String name, byte[] classbytes, ClasspathEntry classpathEntry, BundleEntry entry, ClasspathManager manager)
          Gets called by a classpath manager before defining a class.
 void recordClassDefine(java.lang.String name, java.lang.Class clazz, byte[] classbytes, ClasspathEntry classpathEntry, BundleEntry entry, ClasspathManager manager)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EclipseClassLoadingHook

public EclipseClassLoadingHook()
Method Detail

processClass

public byte[] processClass(java.lang.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(java.util.ArrayList cpEntries,
                                 java.lang.String cp,
                                 ClasspathManager hostmanager,
                                 BaseData sourcedata,
                                 java.security.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

recordClassDefine

public void recordClassDefine(java.lang.String name,
                              java.lang.Class clazz,
                              byte[] classbytes,
                              ClasspathEntry classpathEntry,
                              BundleEntry entry,
                              ClasspathManager manager)

findLibrary

public java.lang.String findLibrary(BaseData data,
                                    java.lang.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 java.lang.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.

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

createClassLoader

public BaseClassLoader createClassLoader(java.lang.ClassLoader parent,
                                         ClassLoaderDelegate delegate,
                                         BundleProtectionDomain domain,
                                         BaseData data,
                                         java.lang.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