org.eclipse.osgi.baseadaptor.hooks
Interface ClassLoadingHook


public interface ClassLoadingHook

A ClassLoadingHook hooks into the ClasspathManager class.

Since:
3.2
See Also:
ClasspathManager, HookRegistry.getClassLoadingHooks(), HookRegistry.addClassLoadingHook(ClassLoadingHook)

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.
 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.
 

Method Detail

processClass

byte[] processClass(java.lang.String name,
                    byte[] classbytes,
                    ClasspathEntry classpathEntry,
                    BundleEntry entry,
                    ClasspathManager manager)
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.

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

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. This method allows a classloading hook to add additional ClasspathEntry objects

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

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

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

java.lang.ClassLoader getBundleClassLoaderParent()
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.

Returns:
the parent classloader to be used by all bundle classloaders or null.

createClassLoader

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[]). 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.

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

void initializedClassLoader(BaseClassLoader baseClassLoader,
                            BaseData data)
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.

Parameters:
baseClassLoader - the newly created bundle classloader
data - the BundleData associated with the bundle classloader