org.eclipse.osgi.framework.internal.core
Class BundleLoader

java.lang.Object
  extended by org.eclipse.osgi.framework.internal.core.BundleLoader
All Implemented Interfaces:
ClassLoaderDelegate
Direct Known Subclasses:
SystemBundleLoader

public class BundleLoader
extends java.lang.Object
implements ClassLoaderDelegate

This object is responsible for all classloader delegation for a bundle. It represents the loaded state of the bundle. BundleLoader objects are created lazily; care should be taken not to force the creation of a BundleLoader unless it is necessary.

See Also:
BundleLoaderProxy

Field Summary
static org.eclipse.osgi.framework.internal.core.BundleLoader.ClassContext CLASS_CONTEXT
           
static java.lang.String DEFAULT_PACKAGE
           
static byte FLAG_CLOSED
           
static byte FLAG_HASDYNAMICEIMPORTALL
           
static byte FLAG_HASDYNAMICIMPORTS
           
static byte FLAG_IMPORTSINIT
           
static java.lang.ClassLoader FW_CLASSLOADER
           
static java.lang.String JAVA_PACKAGE
           
 
Constructor Summary
protected BundleLoader(BundleHost bundle, BundleLoaderProxy proxy)
          BundleLoader runtime constructor.
 
Method Summary
 void addDynamicImportPackage(org.eclipse.osgi.util.ManifestElement[] packages)
          Adds a list of DynamicImport-Package manifest elements to the dynamic import tables of this BundleLoader.
 java.lang.Class findClass(java.lang.String name)
          Finds the class for a bundle.
 java.lang.String findLibrary(java.lang.String name)
          Returns the absolute path name of a native library.
 java.net.URL findResource(java.lang.String name)
          Finds the resource for a bundle.
 java.util.Enumeration findResources(java.lang.String name)
          Finds the resources for a bundle.
static java.lang.String getPackageName(java.lang.String name)
          Returns the package name from the specified class name.
static java.lang.String getResourcePackageName(java.lang.String name)
          Returns the package name from the specified resource name.
 java.lang.String toString()
          Return a string representation of this loader.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_PACKAGE

public static final java.lang.String DEFAULT_PACKAGE
See Also:
Constant Field Values

JAVA_PACKAGE

public static final java.lang.String JAVA_PACKAGE
See Also:
Constant Field Values

FLAG_IMPORTSINIT

public static final byte FLAG_IMPORTSINIT
See Also:
Constant Field Values

FLAG_HASDYNAMICIMPORTS

public static final byte FLAG_HASDYNAMICIMPORTS
See Also:
Constant Field Values

FLAG_HASDYNAMICEIMPORTALL

public static final byte FLAG_HASDYNAMICEIMPORTALL
See Also:
Constant Field Values

FLAG_CLOSED

public static final byte FLAG_CLOSED
See Also:
Constant Field Values

CLASS_CONTEXT

public static final org.eclipse.osgi.framework.internal.core.BundleLoader.ClassContext CLASS_CONTEXT

FW_CLASSLOADER

public static final java.lang.ClassLoader FW_CLASSLOADER
Constructor Detail

BundleLoader

protected BundleLoader(BundleHost bundle,
                       BundleLoaderProxy proxy)
                throws BundleException
BundleLoader runtime constructor. This object is created lazily when the first request for a resource is made to this bundle.

Parameters:
bundle - Bundle object for this loader.
proxy - the BundleLoaderProxy for this loader.
Throws:
BundleException
Method Detail

getPackageName

public static final java.lang.String getPackageName(java.lang.String name)
Returns the package name from the specified class name. The returned package is dot seperated.

Parameters:
name - Name of a class.
Returns:
Dot separated package name or null if the class has no package name.

getResourcePackageName

public static final java.lang.String getResourcePackageName(java.lang.String name)
Returns the package name from the specified resource name. The returned package is dot seperated.

Parameters:
name - Name of a resource.
Returns:
Dot separated package name or null if the resource has no package name.

findClass

public java.lang.Class findClass(java.lang.String name)
                          throws java.lang.ClassNotFoundException
Finds the class for a bundle. This method is used for delegation by the bundle's classloader.

Specified by:
findClass in interface ClassLoaderDelegate
Parameters:
name - the class to find.
Returns:
the Class.
Throws:
java.lang.ClassNotFoundException - if the class is not found.

findResource

public java.net.URL findResource(java.lang.String name)
Finds the resource for a bundle. This method is used for delegation by the bundle's classloader.

Specified by:
findResource in interface ClassLoaderDelegate
Parameters:
name - the resource to load.
Returns:
the resource or null if resource is not found.

findResources

public java.util.Enumeration findResources(java.lang.String name)
                                    throws java.io.IOException
Finds the resources for a bundle. This method is used for delegation by the bundle's classloader.

Specified by:
findResources in interface ClassLoaderDelegate
Parameters:
name - the resource to find.
Returns:
the enumeration of resources found or null if the resource does not exist.
Throws:
java.io.IOException

findLibrary

public java.lang.String findLibrary(java.lang.String name)
Returns the absolute path name of a native library.

Specified by:
findLibrary in interface ClassLoaderDelegate
Parameters:
name - the library name
Returns:
the absolute path of the native library or null if not found

toString

public final java.lang.String toString()
Return a string representation of this loader.

Overrides:
toString in class java.lang.Object
Returns:
String

addDynamicImportPackage

public final void addDynamicImportPackage(org.eclipse.osgi.util.ManifestElement[] packages)
Adds a list of DynamicImport-Package manifest elements to the dynamic import tables of this BundleLoader. Duplicate packages are checked and not added again.

Parameters:
packages - the DynamicImport-Package elements to add.