org.eclipse.osgi.internal.composite
Class CompositeClassLoader

java.lang.Object
  extended by java.lang.ClassLoader
      extended by org.eclipse.osgi.internal.composite.CompositeClassLoader
All Implemented Interfaces:
BaseClassLoader, BundleClassLoader, BundleReference

public class CompositeClassLoader
extends ClassLoader
implements BaseClassLoader


Constructor Summary
CompositeClassLoader(ClassLoader parent, ClassLoaderDelegate delegate, ClassLoaderDelegate companionDelegate, BaseData data)
           
 
Method Summary
 void attachFragment(BundleData bundledata, ProtectionDomain domain, String[] classpath)
          Attaches the BundleData for a fragment to this BundleClassLoader.
 void close()
          Closes this class loader.
 ClasspathEntry createClassPathEntry(BundleFile bundlefile, ProtectionDomain cpDomain)
          Creates a classpath entry with the given bundle file and domain
 Class defineClass(String name, byte[] classbytes, ClasspathEntry classpathEntry, BundleEntry entry)
          Defines a Class.
 List<URL> findEntries(String path, String filePattern, int options)
          Returns resource entries for the bundle associated with this class loader.
 Class findLocalClass(String classname)
          Finds a local class in the BundleClassLoader without consulting the delegate.
 URL findLocalResource(String resource)
          Finds a local resource in the BundleClassLoader without consulting the delegate.
 Enumeration findLocalResources(String resource)
          Finds all local resources in the BundleClassLoader with the specified path without consulting the delegate.
 Bundle getBundle()
          Returns the Bundle object associated with this BundleReference.
 ClasspathManager getClasspathManager()
          Returns the ClasspathManager for this BaseClassLoader
 ClassLoaderDelegate getDelegate()
          Returns the ClassLoaderDelegate used by this BundleClassLoader
 ProtectionDomain getDomain()
          Returns the domain for the host bundle of this class loader
 URL getResource(String name)
          This method will first search the parent class loader for the resource; That failing, this method will invoke ClassLoaderDelegate.findResource(String) to find the resource.
 void initialize()
          Initializes the ClassLoader.
 Collection<String> listLocalResources(String path, String filePattern, int options)
          Returns the names of local resources visible to this bundle class loader.
 Collection<String> listResources(String path, String filePattern, int options)
          Returns the names of resources visible to this bundle class loader.
 Class loadClass(String name)
          This method will first search the parent class loader for the class; That failing, this method will invoke ClassLoaderDelegate.findClass(String) to find the resource.
 Object publicDefinePackage(String name, String specTitle, String specVersion, String specVendor, String implTitle, String implVersion, String implVendor, URL sealBase)
          A public version of the ClassLoader#definePackage(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.net.URL) method.
 Class publicFindLoaded(String classname)
          A public version of the ClassLoader.findLoadedClass(java.lang.String) method.
 Object publicGetPackage(String pkgname)
          A public version of the ClassLoader#getPackage(java.lang.String) method.
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findResources, findSystemClass, getPackage, getPackages, getParent, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.osgi.framework.adaptor.BundleClassLoader
getParent, getResources
 

Constructor Detail

CompositeClassLoader

public CompositeClassLoader(ClassLoader parent,
                            ClassLoaderDelegate delegate,
                            ClassLoaderDelegate companionDelegate,
                            BaseData data)
Method Detail

createClassPathEntry

public ClasspathEntry createClassPathEntry(BundleFile bundlefile,
                                           ProtectionDomain cpDomain)
Description copied from interface: BaseClassLoader
Creates a classpath entry with the given bundle file and domain

Specified by:
createClassPathEntry in interface BaseClassLoader
Parameters:
bundlefile - the source bundle file for a classpath entry
cpDomain - the source domain for a classpath entry
Returns:
a classpath entry with the given bundle file and domain

defineClass

public Class defineClass(String name,
                         byte[] classbytes,
                         ClasspathEntry classpathEntry,
                         BundleEntry entry)
Description copied from interface: BaseClassLoader
Defines a Class.

Specified by:
defineClass in interface BaseClassLoader
Parameters:
name - the name of the class to define
classbytes - the bytes of the class to define
classpathEntry - the classpath entry used to load the class bytes
entry - the bundle entry used to load the class bytes
Returns:
a defined Class

getClasspathManager

public ClasspathManager getClasspathManager()
Description copied from interface: BaseClassLoader
Returns the ClasspathManager for this BaseClassLoader

Specified by:
getClasspathManager in interface BaseClassLoader
Returns:
the ClasspathManager

getDomain

public ProtectionDomain getDomain()
Description copied from interface: BaseClassLoader
Returns the domain for the host bundle of this class loader

Specified by:
getDomain in interface BaseClassLoader
Returns:
the domain for the host bundle of this class loader

publicDefinePackage

public Object publicDefinePackage(String name,
                                  String specTitle,
                                  String specVersion,
                                  String specVendor,
                                  String implTitle,
                                  String implVersion,
                                  String implVendor,
                                  URL sealBase)
Description copied from interface: BaseClassLoader
A public version of the ClassLoader#definePackage(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.net.URL) method.

Specified by:
publicDefinePackage in interface BaseClassLoader
Returns:
a defined Package

publicFindLoaded

public Class publicFindLoaded(String classname)
Description copied from interface: BaseClassLoader
A public version of the ClassLoader.findLoadedClass(java.lang.String) method.

Specified by:
publicFindLoaded in interface BaseClassLoader
Parameters:
classname - the class name to find.
Returns:
a loaded class

publicGetPackage

public Object publicGetPackage(String pkgname)
Description copied from interface: BaseClassLoader
A public version of the ClassLoader#getPackage(java.lang.String) method.

Specified by:
publicGetPackage in interface BaseClassLoader
Parameters:
pkgname - the package name to get.
Returns:
the package or null if it does not exist

attachFragment

public void attachFragment(BundleData bundledata,
                           ProtectionDomain domain,
                           String[] classpath)
Description copied from interface: BundleClassLoader
Attaches the BundleData for a fragment to this BundleClassLoader. The Fragment BundleData resources must be appended to the end of this BundleClassLoader's classpath. Fragment BundleData resources must be searched ordered by Bundle ID's.

Specified by:
attachFragment in interface BundleClassLoader
Parameters:
bundledata - The BundleData of the fragment.
domain - The ProtectionDomain of the resources of the fragment. Any classes loaded from the fragment's BundleData must belong to this ProtectionDomain.
classpath - An array of Bundle-ClassPath entries to use for loading classes and resources. This is specified by the Bundle-ClassPath manifest entry of the fragment.

close

public void close()
Description copied from interface: BundleClassLoader
Closes this class loader. After this method is called loadClass will always throw ClassNotFoundException, getResource, getResourceAsStream, getResources and will return null.

Specified by:
close in interface BundleClassLoader

findLocalClass

public Class findLocalClass(String classname)
                     throws ClassNotFoundException
Description copied from interface: BundleClassLoader
Finds a local class in the BundleClassLoader without consulting the delegate.

Specified by:
findLocalClass in interface BundleClassLoader
Parameters:
classname - the classname to find.
Returns:
The class object found.
Throws:
ClassNotFoundException - if the classname does not exist locally.

findLocalResource

public URL findLocalResource(String resource)
Description copied from interface: BundleClassLoader
Finds a local resource in the BundleClassLoader without consulting the delegate.

Specified by:
findLocalResource in interface BundleClassLoader
Parameters:
resource - the resource path to find.
Returns:
a URL to the resource or null if the resource does not exist.

findLocalResources

public Enumeration findLocalResources(String resource)
Description copied from interface: BundleClassLoader
Finds all local resources in the BundleClassLoader with the specified path without consulting the delegate.

Specified by:
findLocalResources in interface BundleClassLoader
Parameters:
resource - the resource path to find.
Returns:
An Enumeration of all resources found or null if the resource. does not exist.

getDelegate

public ClassLoaderDelegate getDelegate()
Description copied from interface: BundleClassLoader
Returns the ClassLoaderDelegate used by this BundleClassLoader

Specified by:
getDelegate in interface BundleClassLoader
Returns:
the ClassLoaderDelegate used by this BundleClassLoader

getResource

public URL getResource(String name)
Description copied from interface: BundleClassLoader
This method will first search the parent class loader for the resource; That failing, this method will invoke ClassLoaderDelegate.findResource(String) to find the resource.

Specified by:
getResource in interface BundleClassLoader
Overrides:
getResource in class ClassLoader
Parameters:
name - the resource path to get.
Returns:
a URL for the resource or null if the resource is not found.

initialize

public void initialize()
Description copied from interface: BundleClassLoader
Initializes the ClassLoader. This is called after all currently resolved fragment bundles have been attached to the BundleClassLoader by the Framework.

Specified by:
initialize in interface BundleClassLoader

loadClass

public Class loadClass(String name)
                throws ClassNotFoundException
Description copied from interface: BundleClassLoader
This method will first search the parent class loader for the class; That failing, this method will invoke ClassLoaderDelegate.findClass(String) to find the resource.

Specified by:
loadClass in interface BundleClassLoader
Overrides:
loadClass in class ClassLoader
Parameters:
name - the class name to load.
Returns:
the Class.
Throws:
ClassNotFoundException

getBundle

public Bundle getBundle()
Description copied from interface: BundleReference
Returns the Bundle object associated with this BundleReference.

Specified by:
getBundle in interface BundleReference
Returns:
The Bundle object associated with this BundleReference.

findEntries

public List<URL> findEntries(String path,
                             String filePattern,
                             int options)
Description copied from interface: BundleClassLoader
Returns resource entries for the bundle associated with this class loader. This is used to answer a call to the BundleWiring.findEntries(String, String, int) method.

Specified by:
findEntries in interface BundleClassLoader
Parameters:
path - The path name in which to look.
filePattern - The file name pattern for selecting resource names in the specified path.
options - The options for listing resource names.
Returns:
a list of resource URLs. If no resources are found then the empty list is returned.
See Also:
BundleWiring#findEntries(String, String, int)}

listResources

public Collection<String> listResources(String path,
                                        String filePattern,
                                        int options)
Description copied from interface: BundleClassLoader
Returns the names of resources visible to this bundle class loader. This is used to answer a call to the BundleWiring.listResources(String, String, int) method. This method should simply return the result of calling ClassLoaderDelegate.listResources(String, String, int)

Specified by:
listResources in interface BundleClassLoader
Parameters:
path - The path name in which to look.
filePattern - The file name pattern for selecting resource names in the specified path.
options - The options for listing resource names.
Returns:
a collection of resource names. If no resources are found then the empty collection is returned.
See Also:
BundleWiring#listResources(String, String, int)}, ClassLoaderDelegate#listResources(String, String, int)}

listLocalResources

public Collection<String> listLocalResources(String path,
                                             String filePattern,
                                             int options)
Description copied from interface: BundleClassLoader
Returns the names of local resources visible to this bundle class loader. Only the resources available on the local class path of this bundle class loader are searched.

Specified by:
listLocalResources in interface BundleClassLoader
Parameters:
path - The path name in which to look.
filePattern - The file name pattern for selecting resource names in the specified path.
options - The options for listing resource names.
Returns:
a collection of resource names. If no resources are found then the empty collection is returned.
See Also:
ClassLoaderDelegate#listResources(String, String, int)}


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