org.knopflerfish.framework
Class BundleClassLoader

java.lang.Object
  extended by java.lang.ClassLoader
      extended by org.knopflerfish.framework.BundleClassLoader

public final class BundleClassLoader
extends java.lang.ClassLoader

Classloader for bundle JAR files.


Field Summary
protected static org.knopflerfish.framework.BundleClassLoader.SecurityManagerExposer smex
           
 
Method Summary
protected  java.lang.Class findClass(java.lang.String name)
          Find bundle class to load.
protected  java.lang.String findLibrary(java.lang.String name)
          Find native library code to load.
protected  java.net.URL findResource(java.lang.String name)
          Finds the resource with the given name.
protected  java.util.Enumeration findResources(java.lang.String name)
          Returns an Enumeration of all the resources with the given name.
 java.net.URL getResource(java.lang.String name)
          Finds the resource with the given name.
 java.io.InputStream getResourceAsStream(java.lang.String name)
          Finds the resource with the given name and returns the InputStream.
 java.util.Enumeration getResourcesOSGi(java.lang.String name)
          Finds all the resources with the given name.
 boolean isBootClassContext(java.lang.String msg)
          Check if the current call is made from a class loaded on the boot class path (or rather, on a class loaded from something else than a bundle class loader)
protected  java.lang.Class loadClass(java.lang.String name, boolean resolve)
          Find Class and load it.
 java.lang.String toString()
          Return a string representing this objet
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLoadedClass, findSystemClass, getPackage, getPackages, getParent, 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, wait, wait, wait
 

Field Detail

smex

protected static org.knopflerfish.framework.BundleClassLoader.SecurityManagerExposer smex
Method Detail

findClass

protected java.lang.Class findClass(java.lang.String name)
                             throws java.lang.ClassNotFoundException
Find bundle class to load. First check if this load comes from an imported package. Otherwise load class from our bundle.

Overrides:
findClass in class java.lang.ClassLoader
Throws:
java.lang.ClassNotFoundException
See Also:
ClassLoader.findClass(java.lang.String)

findLibrary

protected java.lang.String findLibrary(java.lang.String name)
Find native library code to load.

Overrides:
findLibrary in class java.lang.ClassLoader
See Also:
ClassLoader.findLibrary(java.lang.String)

findResources

protected java.util.Enumeration findResources(java.lang.String name)
Returns an Enumeration of all the resources with the given name.

Overrides:
findResources in class java.lang.ClassLoader
See Also:
ClassLoader.findResources(java.lang.String)

findResource

protected java.net.URL findResource(java.lang.String name)
Finds the resource with the given name.

Overrides:
findResource in class java.lang.ClassLoader
See Also:
ClassLoader.findResource(java.lang.String)

isBootClassContext

public boolean isBootClassContext(java.lang.String msg)
Check if the current call is made from a class loaded on the boot class path (or rather, on a class loaded from something else than a bundle class loader)


loadClass

protected java.lang.Class loadClass(java.lang.String name,
                                    boolean resolve)
                             throws java.lang.ClassNotFoundException
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.

Overrides:
loadClass in class java.lang.ClassLoader
Parameters:
name - the name of the class
resolve - if true then resolve the class
Returns:
the resulting Class object
Throws:
java.lang.ClassNotFoundException - if the class could not be found
See Also:
ClassLoader.loadClass(java.lang.String)

getResource

public java.net.URL getResource(java.lang.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.

Overrides:
getResource in class java.lang.ClassLoader
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:
ClassLoader.getResource(java.lang.String)

getResourcesOSGi

public java.util.Enumeration getResourcesOSGi(java.lang.String name)
                                       throws java.io.IOException
Finds all the resources with the given name. A resource is some data (images, audio, text, etc) that can be accessed by class code in a way that is independent of the location of the code.

The name of a resource is a /-separated path name that identifies the resource.

Parameters:
name - resource name
Returns:
An enumeration of URL objects for the resource. If no resources could be found, the enumeration will be empty. Resources that the class loader doesn't have access to will not be in the enumeration.
Throws:
java.io.IOException
See Also:
ClassLoader.getResources(java.lang.String), Bundle.getResources(String name)

getResourceAsStream

public java.io.InputStream getResourceAsStream(java.lang.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.

Overrides:
getResourceAsStream in class java.lang.ClassLoader
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:
ClassLoader.getResourceAsStream(java.lang.String)

toString

public java.lang.String toString()
Return a string representing this objet

Overrides:
toString in class java.lang.Object
Returns:
A message string.