org.knopflerfish.framework.BundleClassLoader Class Reference

List of all members.


Detailed Description

Classloader for bundle JAR files.

Author:
Jan Stein

Philippe Laporte

Mats-Ola Persson

Definition at line 57 of file BundleClassLoader.java.


Public Member Functions

URL getResource (String name)
 Finds the resource with the given name.
InputStream getResourceAsStream (String name)
 Finds the resource with the given name and returns the InputStream.
String toString ()
 Return a string representing this objet.

Protected Member Functions

Class findClass (String name) throws ClassNotFoundException
 Find bundle class to load.
String findLibrary (String name)
 Find native library code to load.
Enumeration findResources (String name)
 Returns an Enumeration of all the resources with the given name.
URL findResource (String name)
 Finds the resource with the given name.
Class loadClass (String name, boolean resolve) throws ClassNotFoundException
 Find Class and load it.

Package Functions

 BundleClassLoader (BundlePackages bpkgs, BundleArchive ba, ArrayList frags, ProtectionDomain pd, PermissionOps secure)
 Create class loader for specified bundle.
BundleImpl getBundle ()
 Get bundle owning this class loader.
BundleArchive getBundleArchive (long frag)
 Get bundle archive belonging to this class loader.
void close ()
 Close down this classloader.
void purge ()
 Close down this classloader and all its archives.
Enumeration getBundleResources (String name, boolean onlyFirst)
 Get all the resources with the given name in this bundle.
Hashtable getLocalizationEntries (String name)
 Find localization files and load.
BundlePackages getBpkgs ()
 Get bundle package handler.
Object searchFor (String name, String pkg, String path, SearchAction action, boolean onlyFirst, BundleClassLoader requestor, HashSet visited)
 Search for classloader to use according to OSGi search order.

Package Attributes

final PermissionOps secure
 Handle to secure operations.
final ProtectionDomain protectionDomain
 Bundle classloader protect domain.

Static Package Attributes

static final SearchAction classSearch
 Search action for class searching.
static final SearchAction resourceSearch
 Search action for resource searching.

Classes

interface  SearchAction
 Search action. More...

Member Function Documentation

Class org.knopflerfish.framework.BundleClassLoader.findClass ( String  name  )  throws ClassNotFoundException [protected]

Find bundle class to load.

First check if this load comes from an imported package. Otherwise load class from our bundle.

See also:
java.lang.ClassLoader.findClass

Definition at line 205 of file BundleClassLoader.java.

References org.knopflerfish.framework.BundlePackages.bundle, org.knopflerfish.framework.PermissionOps.callSearchFor(), org.knopflerfish.framework.BundleClassLoader.classSearch, org.knopflerfish.framework.PermissionOps.okClassAdminPerm(), and org.knopflerfish.framework.BundleClassLoader.secure.

Referenced by org.knopflerfish.framework.BundleClassLoader.loadClass().

String org.knopflerfish.framework.BundleClassLoader.findLibrary ( String  name  )  [protected]

Find native library code to load.

See also:
java.lang.ClassLoader.findLibrary

Definition at line 240 of file BundleClassLoader.java.

References org.knopflerfish.framework.BundleArchive.getNativeLibrary().

Enumeration org.knopflerfish.framework.BundleClassLoader.findResources ( String  name  )  [protected]

Returns an Enumeration of all the resources with the given name.

See also:
java.lang.ClassLoader.findResources

Definition at line 262 of file BundleClassLoader.java.

References org.knopflerfish.framework.BundleClassLoader.getBundleResources().

URL org.knopflerfish.framework.BundleClassLoader.findResource ( String  name  )  [protected]

Finds the resource with the given name.

See also:
java.lang.ClassLoader.findResource

Definition at line 273 of file BundleClassLoader.java.

References org.knopflerfish.framework.BundleClassLoader.getBundleResources().

Referenced by org.knopflerfish.framework.BundleClassLoader.getResource().

Class org.knopflerfish.framework.BundleClassLoader.loadClass ( String  name,
boolean  resolve 
) throws ClassNotFoundException [protected]

Find Class and load it.

This function is abstract in PJava 1.2 so we define it here to work as closely as it can to Java 2. Should work okey if we don't use the Java 2 stuff.

Parameters:
name the name of the class
resolve if true then resolve the class
Returns:
the resulting Class object
Exceptions:
ClassNotFoundException if the class could not be found
See also:
java.lang.ClassLoader.loadClass

Definition at line 294 of file BundleClassLoader.java.

References org.knopflerfish.framework.BundleClassLoader.findClass().

Referenced by org.knopflerfish.framework.ServiceReferenceImpl.getService().

URL org.knopflerfish.framework.BundleClassLoader.getResource ( String  name  ) 

Finds the resource with the given name.

This is defined a little different in PJava 1.2 versus Java 2. So we first try to use the super() version and if it fails we try to find it in the local bundle.

Parameters:
name resource name
Returns:
an URL to resource, or null if the resource could not be found or the caller doesn't have adequate privileges to get the resource.
See also:
java.lang.ClassLoader.getResource

Definition at line 320 of file BundleClassLoader.java.

References org.knopflerfish.framework.BundleClassLoader.findResource().

Referenced by org.knopflerfish.framework.BundleClassLoader.getResourceAsStream().

InputStream org.knopflerfish.framework.BundleClassLoader.getResourceAsStream ( String  name  ) 

Finds the resource with the given name and returns the InputStream.

The method is overridden to make sure it does the right thing.

Parameters:
name resource name
Returns:
an InputStream to resource, or null if the resource could not be found or the caller doesn't have adequate privileges to get the resource.
See also:
java.lang.ClassLoader.getResourceAsStream

Definition at line 342 of file BundleClassLoader.java.

References org.knopflerfish.framework.BundleClassLoader.getResource().

String org.knopflerfish.framework.BundleClassLoader.toString (  ) 

Return a string representing this objet.

Returns:
A message string.

Definition at line 358 of file BundleClassLoader.java.

References org.knopflerfish.framework.BundlePackages.bundle, org.knopflerfish.framework.BundlePackages.generation, and org.knopflerfish.framework.BundleImpl.id.

void org.knopflerfish.framework.BundleClassLoader.close (  )  [package]

Close down this classloader.

We don't give out any new classes. Perhaps we should block all classloads.

Definition at line 400 of file BundleClassLoader.java.

References org.knopflerfish.framework.BundlePackages.invalidateClassLoader().

Referenced by org.knopflerfish.framework.BundleClassLoader.purge().

void org.knopflerfish.framework.BundleClassLoader.purge (  )  [package]

Close down this classloader and all its archives.

Purge all archives.

Definition at line 414 of file BundleClassLoader.java.

References org.knopflerfish.framework.BundleImpl.archive, org.knopflerfish.framework.BundlePackages.bundle, org.knopflerfish.framework.Framework.bundles, org.knopflerfish.framework.BundleClassLoader.close(), org.knopflerfish.framework.BundleImpl.framework, org.knopflerfish.framework.Bundles.getBundle(), org.knopflerfish.framework.BundleArchive.getBundleLocation(), org.knopflerfish.framework.Framework.perm, org.knopflerfish.framework.BundleClassLoader.protectionDomain, org.knopflerfish.framework.BundleArchive.purge(), org.knopflerfish.framework.PermissionOps.purge(), and org.knopflerfish.framework.BundlePackages.unregisterPackages().

Object org.knopflerfish.framework.BundleClassLoader.searchFor ( String  name,
String  pkg,
String  path,
SearchAction  action,
boolean  onlyFirst,
BundleClassLoader  requestor,
HashSet  visited 
) [package]

Search for classloader to use according to OSGi search order.

3 If the class or resource is in a package that is imported using Import-Package or was imported dynamically in a previous load, then the request is delegated to the exporting bundles class loader; otherwise the search continues with the next step. If the request is delegated to an exporting class loader and the class or resource is not found, then the search terminates and the request fails.

4 If the class or resource is in a package that is imported from one or more other bundles using Require-Bundle, the request is delegated to the class loaders of the other bundles, in the order in which they are specified in this bundles manifest. If the class or resource is not found, then the search continues with the next step.

5 The bundles own internal bundle class path is searched. If the class or resource is not found, then the search continues with the next step.

6 Each attached fragment's internal bundle class path is searched. The fragments are searched in ascending bundle ID order. If the class or resource is not found, then the search continues with the next step.

7 If the class or resource is in a package that is exported by the bundle or the package is imported by the bundle (using Import-Package or Require-Bundle), then the search ends and the class or resource is not found.

8 Otherwise, if the class or resource is in a package that is imported using DynamicImport-Package, then a dynamic import of the package is now attempted. An exporter must conform to any implied package constraints. If an appropriate exporter is found, a wire is established so that future loads of the package are handled in Step 3. If a dynamic wire is not established, then the request fails.

9 If the dynamic import of the package is established, the request is delegated to the exporting bundle's class loader. If the request is delegated to an exporting class loader and the class or resource is not found, then the search terminates and the request fails.

Parameters:
name Name of class or null if we look for a resource
pkg Package name for item
path File path to item searched ("/" seperated)
action Action to be taken when item is found
onlyFirst Stop search when first matching item is found.
Returns:
Object returned from action class.

Definition at line 558 of file BundleClassLoader.java.

References org.knopflerfish.framework.BundlePackages.bundle, org.knopflerfish.framework.PermissionOps.callSearchFor(), org.knopflerfish.framework.ExportPkg.checkFilter(), org.knopflerfish.framework.BundleClassLoader.classSearch, org.knopflerfish.framework.BundleArchive.componentExists(), org.knopflerfish.framework.BundleImpl.framework, org.knopflerfish.framework.Listeners.frameworkError(), org.knopflerfish.framework.BundleClassLoader.SearchAction.get(), org.knopflerfish.framework.BundleArchive.getBundleId(), org.knopflerfish.framework.BundlePackages.getClassLoader(), org.knopflerfish.framework.SystemBundle.getClassLoader(), org.knopflerfish.framework.BundlePackages.getDynamicProviderBundlePackages(), org.knopflerfish.framework.BundlePackages.getExport(), org.knopflerfish.framework.BundlePackages.getProviderBundlePackages(), org.knopflerfish.framework.BundlePackages.getRequiredBundlePackages(), org.knopflerfish.framework.BundleImpl.id, org.knopflerfish.framework.Framework.listeners, org.knopflerfish.framework.BundleClassLoader.secure, and org.knopflerfish.framework.Framework.systemBundle.


The documentation for this class was generated from the following file:
Generated on Mon Jan 11 21:19:19 2010 for OpenMobileIS by  doxygen 1.5.4