org.eclipse.osgi.internal.baseadaptor
Class BaseClassLoadingHook

java.lang.Object
  extended by org.eclipse.osgi.internal.baseadaptor.BaseClassLoadingHook
All Implemented Interfaces:
ClassLoadingHook

public class BaseClassLoadingHook
extends Object
implements ClassLoadingHook


Constructor Summary
BaseClassLoadingHook()
           
 
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.
 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().
static String[] mapLibraryNames(String mappedLibName)
           
 byte[] processClass(String name, byte[] classbytes, ClasspathEntry classpathEntry, BundleEntry entry, ClasspathManager manager)
          Gets called by a classpath manager before defining a class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BaseClassLoadingHook

public BaseClassLoadingHook()
Method Detail

mapLibraryNames

public static String[] mapLibraryNames(String mappedLibName)

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.

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

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.

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.

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


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