org.ops4j.pax.swissbox.core
Class BundleClassLoader

java.lang.Object
  extended by java.lang.ClassLoader
      extended by org.ops4j.pax.swissbox.core.BundleClassLoader

public class BundleClassLoader
extends java.lang.ClassLoader

Class loader that uses the a bundle in order to implement class loader functionality.

Since:
0.1.0, December 29, 2007
Author:
Alin Dreghiciu

Constructor Summary
BundleClassLoader(org.osgi.framework.Bundle bundle)
          Creates a bundle class loader with no parent.
BundleClassLoader(org.osgi.framework.Bundle bundle, java.lang.ClassLoader parent)
          Creates a bundle class loader.
 
Method Summary
 boolean equals(java.lang.Object o)
           
protected  java.lang.Class findClass(java.lang.String name)
          Use bundle to find find the class.
protected  java.net.URL findResource(java.lang.String name)
          Use bundle to find resource.
protected  java.util.Enumeration<java.net.URL> findResources(java.lang.String name)
          Use bundle to find resources.
 org.osgi.framework.Bundle getBundle()
          Getter.
 java.net.URL getResource(java.lang.String name)
          If there is a parent class loader use the super implementation that will first use the parent and as a fallback it will call findResource().
 java.util.Enumeration<java.net.URL> getResources(java.lang.String name)
          If there is a parent class loader use the super implementation that will first use the parent and as a fallback it will call findResources().
 int hashCode()
           
protected  java.lang.Class loadClass(java.lang.String name, boolean resolve)
          If there is a parent class loader use the super implementation that will first use the parent and as a fallback it will call findClass().
static BundleClassLoader newPriviledged(org.osgi.framework.Bundle bundle)
          Privileged factory method.
static BundleClassLoader newPriviledged(org.osgi.framework.Bundle bundle, java.lang.ClassLoader parent)
          Privileged factory method.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findSystemClass, getPackage, getPackages, getParent, getResourceAsStream, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BundleClassLoader

public BundleClassLoader(org.osgi.framework.Bundle bundle)
Creates a bundle class loader with no parent.

Parameters:
bundle - bundle to be used for class loading. Cannot be null.

BundleClassLoader

public BundleClassLoader(org.osgi.framework.Bundle bundle,
                         java.lang.ClassLoader parent)
Creates a bundle class loader.

Parameters:
bundle - bundle to be used for class loading. Cannot be null.
parent - parent class loader
Method Detail

newPriviledged

public static BundleClassLoader newPriviledged(org.osgi.framework.Bundle bundle)
Privileged factory method.

Parameters:
bundle - bundle to be used for class loading. Cannot be null.
Returns:
created bundle class loader
See Also:
BundleClassLoader(Bundle)

newPriviledged

public static BundleClassLoader newPriviledged(org.osgi.framework.Bundle bundle,
                                               java.lang.ClassLoader parent)
Privileged factory method.

Parameters:
bundle - bundle to be used for class loading. Cannot be null.
parent - parent class loader
Returns:
created bundle class loader
See Also:
BundleClassLoader(Bundle,ClassLoader)

getBundle

public org.osgi.framework.Bundle getBundle()
Getter.

Returns:
the bundle the class loader loads from

getResource

public java.net.URL getResource(java.lang.String name)
If there is a parent class loader use the super implementation that will first use the parent and as a fallback it will call findResource(). In case there is no parent directy use findResource() as if we call the super implementation it will use the VMClassLoader, fact that should be avoided.

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

getResources

public java.util.Enumeration<java.net.URL> getResources(java.lang.String name)
                                                 throws java.io.IOException
If there is a parent class loader use the super implementation that will first use the parent and as a fallback it will call findResources(). In case there is no parent directy use findResources() as if we call the super implementation it will use the VMClassLoader, fact that should be avoided.

Overrides:
getResources in class java.lang.ClassLoader
Throws:
java.io.IOException
See Also:
ClassLoader.getResources(String)

findClass

protected java.lang.Class findClass(java.lang.String name)
                             throws java.lang.ClassNotFoundException
Use bundle to find find the class.

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

loadClass

protected java.lang.Class loadClass(java.lang.String name,
                                    boolean resolve)
                             throws java.lang.ClassNotFoundException
If there is a parent class loader use the super implementation that will first use the parent and as a fallback it will call findClass(). In case there is no parent directy use findClass() as if we call the super implementation it will use the VMClassLoader, fact that should be avoided.

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

findResource

protected java.net.URL findResource(java.lang.String name)
Use bundle to find resource.

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

findResources

protected java.util.Enumeration<java.net.URL> findResources(java.lang.String name)
                                                     throws java.io.IOException
Use bundle to find resources.

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

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object


Copyright © 2006-2011 OPS4J - Open Participation Software for Java. All Rights Reserved.