org.jboss.classloader.spi.base
Class BaseClassLoaderDomain

java.lang.Object
  extended by org.jboss.classloader.spi.base.BaseClassLoaderDomain
All Implemented Interfaces:
Loader
Direct Known Subclasses:
ClassLoaderDomain

public abstract class BaseClassLoaderDomain
extends Object
implements Loader

BaseClassLoaderDomain.

This class hides some of the implementation details and allows package access to the protected methods.

Version:
$Revision: 1.1 $
Author:
Adrian Brock

Constructor Summary
BaseClassLoaderDomain()
           
 
Method Summary
protected abstract  URL afterGetResource(String name)
          Invoked after getResource is attempted to allow a postload attempt, e.g.
protected abstract  void afterGetResources(String name, Set<URL> urls)
          Invoked after getResources is attempted to allow a postload attempt, e.g.
protected  void afterRegisterClassLoader(ClassLoader classLoader, ClassLoaderPolicy policy)
          Invoked after adding a classloader policy
protected  void afterUnregisterClassLoader(ClassLoader classLoader, ClassLoaderPolicy policy)
          Invoked after adding a classloader policy
protected abstract  URL beforeGetResource(String name)
          Invoked before getResource is attempted to allow a preload attempt, e.g.
protected abstract  void beforeGetResources(String name, Set<URL> urls)
          Invoked before getResources is attempted to allow a preload attempt, e.g.
protected  void beforeRegisterClassLoader(ClassLoader classLoader, ClassLoaderPolicy policy)
          Invoked before adding a classloader policy
protected  void beforeUnregisterClassLoader(ClassLoader classLoader, ClassLoaderPolicy policy)
          Invoked before adding a classloader policy
protected  void clearBlackList(String name)
          Cleans the entry with the given name from the blackList
protected abstract  Loader findAfterLoader(String name)
          Invoked after classloading is attempted to allow a postload attempt, e.g.
protected abstract  Loader findBeforeLoader(String name)
          Invoked before classloading is attempted to allow a preload attempt, e.g.
protected  Loader findLoader(String name)
          Find a loader for a class
 void flushCaches()
          Flush the internal caches
protected  ClassLoader getParentClassLoader()
          Get the parent classloader
 URL getResource(String name)
          Get a resource
 void getResources(String name, Set<URL> urls)
          Get resources
 boolean hasClassLoaders()
          Whether the domain has classloaders
 Class<?> loadClass(String name)
          Load a class
protected  void shutdownDomain()
          Shutdown the domain
 String toLongString()
          A long version of toString()
protected  void toLongString(StringBuilder builder)
          For subclasses to add information for toLongString()
protected  byte[] transform(ClassLoader classLoader, String className, byte[] byteCode, ProtectionDomain protectionDomain)
          Transform the byte code
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BaseClassLoaderDomain

public BaseClassLoaderDomain()
Method Detail

flushCaches

public void flushCaches()
Flush the internal caches


shutdownDomain

protected void shutdownDomain()
Shutdown the domain

The default implementation just unregisters all classloaders


hasClassLoaders

public boolean hasClassLoaders()
Whether the domain has classloaders

Returns:
true when the domain has classloaders

transform

protected byte[] transform(ClassLoader classLoader,
                           String className,
                           byte[] byteCode,
                           ProtectionDomain protectionDomain)
                    throws Exception
Transform the byte code

By default, this delegates to the classloader system

Parameters:
classLoader - the classloader
className - the class name
byteCode - the byte code
protectionDomain - the protection domain
Returns:
the transformed byte code
Throws:
Exception - for any error

findLoader

protected Loader findLoader(String name)
Find a loader for a class

Parameters:
name - the class resource name
Returns:
the loader

findBeforeLoader

protected abstract Loader findBeforeLoader(String name)
Invoked before classloading is attempted to allow a preload attempt, e.g. from the parent

Parameters:
name - the class resource name
Returns:
the loader if found or null otherwise

findAfterLoader

protected abstract Loader findAfterLoader(String name)
Invoked after classloading is attempted to allow a postload attempt, e.g. from the parent

Parameters:
name - the class resource name
Returns:
the loader if found or null otherwise

beforeGetResources

protected abstract void beforeGetResources(String name,
                                           Set<URL> urls)
                                    throws IOException
Invoked before getResources is attempted to allow a preload attempt, e.g. from the parent

Parameters:
name - the resource name
urls - the urls to add to
Throws:
IOException - for any error

afterGetResources

protected abstract void afterGetResources(String name,
                                          Set<URL> urls)
                                   throws IOException
Invoked after getResources is attempted to allow a postload attempt, e.g. from the parent

Parameters:
name - the resource name
urls - the urls to add to
Throws:
IOException - for any error

beforeGetResource

protected abstract URL beforeGetResource(String name)
Invoked before getResource is attempted to allow a preload attempt, e.g. from the parent

Parameters:
name - the resource name
Returns:
the url if found or null otherwise

afterGetResource

protected abstract URL afterGetResource(String name)
Invoked after getResource is attempted to allow a postload attempt, e.g. from the parent

Parameters:
name - the class name
Returns:
the url if found or null otherwise

loadClass

public Class<?> loadClass(String name)
Description copied from interface: Loader
Load a class

Specified by:
loadClass in interface Loader
Parameters:
name - the class name
Returns:
the class or null if not found

getResource

public URL getResource(String name)
Description copied from interface: Loader
Get a resource

Specified by:
getResource in interface Loader
Parameters:
name - the resource name
Returns:
the url or null if not found

getResources

public void getResources(String name,
                         Set<URL> urls)
                  throws IOException
Description copied from interface: Loader
Get resources

Specified by:
getResources in interface Loader
Parameters:
name - the resource name
urls - the list of urls to add to
Throws:
IOException - for any error

toLongString

public String toLongString()
A long version of toString()

Returns:
the long string

toLongString

protected void toLongString(StringBuilder builder)
For subclasses to add information for toLongString()

Parameters:
builder - the builder

beforeRegisterClassLoader

protected void beforeRegisterClassLoader(ClassLoader classLoader,
                                         ClassLoaderPolicy policy)
Invoked before adding a classloader policy

Parameters:
classLoader - the classloader
policy - the classloader policy

afterRegisterClassLoader

protected void afterRegisterClassLoader(ClassLoader classLoader,
                                        ClassLoaderPolicy policy)
Invoked after adding a classloader policy

Parameters:
classLoader - the classloader
policy - the classloader policy

beforeUnregisterClassLoader

protected void beforeUnregisterClassLoader(ClassLoader classLoader,
                                           ClassLoaderPolicy policy)
Invoked before adding a classloader policy

Parameters:
classLoader - the classloader
policy - the classloader policy

afterUnregisterClassLoader

protected void afterUnregisterClassLoader(ClassLoader classLoader,
                                          ClassLoaderPolicy policy)
Invoked after adding a classloader policy

Parameters:
classLoader - the classloader
policy - the classloader policy

getParentClassLoader

protected ClassLoader getParentClassLoader()
Get the parent classloader

Returns:
the parent classloader

clearBlackList

protected void clearBlackList(String name)
Cleans the entry with the given name from the blackList

Parameters:
name - the name of the resource to clear from the blackList


Copyright ? 2007 JBoss Inc.. All Rights Reserved.