OPS4J Pax Swissbox :: OSGi Core 1.3.1

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 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, ClassLoader parent)
          Creates a bundle class loader.
 
Method Summary
 boolean equals(Object o)
           
protected  Class findClass(String name)
          Use bundle to find find the class.
protected  URL findResource(String name)
          Use bundle to find resource.
protected  Enumeration<URL> findResources(String name)
          Use bundle to find resources.
 org.osgi.framework.Bundle getBundle()
          Getter.
 URL getResource(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().
 Enumeration<URL> getResources(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  Class loadClass(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, ClassLoader parent)
          Privileged factory method.
 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,
                         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,
                                               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 URL getResource(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 ClassLoader
See Also:
ClassLoader.getResource(String)

getResources

public Enumeration<URL> getResources(String name)
                              throws 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 ClassLoader
Throws:
IOException
See Also:
ClassLoader.getResources(String)

findClass

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

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

loadClass

protected Class loadClass(String name,
                          boolean resolve)
                   throws 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 ClassLoader
Throws:
ClassNotFoundException
See Also:
ClassLoader.getResource(String)

findResource

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

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

findResources

protected Enumeration<URL> findResources(String name)
                                  throws IOException
Use bundle to find resources.

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

toString

public String toString()
Overrides:
toString in class Object

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

OPS4J Pax Swissbox :: OSGi Core 1.3.1

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