org.eclipse.osgi.framework.adaptor
Interface ClassLoaderDelegate

All Known Implementing Classes:
BundleLoader, SystemBundleLoader

public interface ClassLoaderDelegate

A ClassLoaderDelegate is used by the BundleClassLoader in a similar fashion that a parent ClassLoader is used. A ClassLoaderDelegate must be queried for any resource or class before it is loaded by the BundleClassLoader. The Framework implements the ClassLoaderDelegate and supplies it to the BundleClassLoader. FrameworkAdaptor implementations are not responsible for suppling an implementation for ClassLoaderDelegate.

This interface is not intended to be implemented by clients.

Since:
3.1

Method Summary
 Class<?> findClass(String classname)
          Finds a class for a bundle that may be outside of the actual bundle (i.e.
 String findLibrary(String libraryname)
          Returns the absolute path name of a native library.
 URL findResource(String resource)
          Finds a resource for a bundle that may be outside of the actual bundle (i.e.
 Enumeration<URL> findResources(String resource)
          Finds an enumeration of resources for a bundle that may be outside of the actual bundle (i.e.
 boolean isLazyTriggerSet()
          Returns true if the lazy trigger has been set for this delegate.
 Collection<String> listResources(String path, String filePattern, int options)
          Returns the names of resources visible to this delegate.
 void setLazyTrigger()
          Sets the lazy trigger for this delegate.
 

Method Detail

findClass

Class<?> findClass(String classname)
                   throws ClassNotFoundException
Finds a class for a bundle that may be outside of the actual bundle (i.e. a class from an imported package or required bundle).

If the class does not belong to an imported package or is not found in a required bundle then the ClassloaderDelegate will call BundleClassLoader.findLocalClass().

If no class is found then a ClassNotFoundException is thrown.

Parameters:
classname - the class to find.
Returns:
the Class.
Throws:
ClassNotFoundException - if the class is not found.

findResource

URL findResource(String resource)
Finds a resource for a bundle that may be outside of the actual bundle (i.e. a resource from an imported package or required bundle).

If the resource does not belong to an imported package or is not found in a required bundle then the ClassloaderDelegate will call BundleClassLoader.findLocalResource().

If no resource is found then return null.

Parameters:
resource - the resource to load.
Returns:
the resource or null if resource is not found.

findResources

Enumeration<URL> findResources(String resource)
                               throws IOException
Finds an enumeration of resources for a bundle that may be outside of the actual bundle (i.e. a resource from an imported package or required bundle).

If the resource does not belong to an imported package or is not found in a required bundle then the ClassloaderDelegate will call BundleClassLoader.findLocalResource().

If no resource is found then return null.

Parameters:
resource - the resource to find.
Returns:
the enumeration of resources found or null if the resource does not exist.
Throws:
IOException

findLibrary

String findLibrary(String libraryname)
Returns the absolute path name of a native library. The following is a list of steps that a ClassLoaderDelegate must take when trying to find a library: If no library is found return null.

Parameters:
libraryname - the library to find the path to.
Returns:
the path to the library or null if not found.

isLazyTriggerSet

boolean isLazyTriggerSet()
Returns true if the lazy trigger has been set for this delegate. The lazy trigger is set when a bundle has been marked for lazy activation due to a successful class load.

Returns:
true if the lazy trigger has been set
Since:
3.6

setLazyTrigger

void setLazyTrigger()
                    throws BundleException
Sets the lazy trigger for this delegate. This will activate the bundle if the bundle has been started with the activation policy and the bundle's start level is met.

Throws:
BundleException - if an error occurred while activating the bundle
Since:
3.6
See Also:
isLazyTriggerSet()

listResources

Collection<String> listResources(String path,
                                 String filePattern,
                                 int options)
Returns the names of resources visible to this delegate. This is used to answer a call to the BundleWiring.listResources(String, String, int) method. First a search is done on the packages imported by the bundle associated with this delegate. Next a search is done on the the bundles required by the bundle associated with this delegate. Finally a local search of the bundle associated with this delegate is done by calling BundleClassLoader.listLocalResources(String, String, int). Note that for imported packages the search stops at the source for the import.

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)


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