org.jboss.classloader.spi.base
Class BaseClassLoaderPolicy

java.lang.Object
  extended by org.jboss.classloader.spi.base.BaseClassLoaderPolicy
Direct Known Subclasses:
ClassLoaderPolicy

public abstract class BaseClassLoaderPolicy
extends Object

Base ClassLoader policy.

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

Version:
$Revision: 1.1 $
Author:
Adrian Brock, Ales Justin

Constructor Summary
BaseClassLoaderPolicy()
          Create a new BaseClassLoaderPolicy.
 
Method Summary
 void addTranslator(org.jboss.util.loading.Translator translator)
          Add the translator.
protected  void clearBlackList(String name)
          Cleans the entry with the given name from the blackList
protected  AccessControlContext getAccessControlContext()
          Get the access control context for this policy
protected abstract  List<? extends DelegateLoader> getDelegates()
          Get the delegate loaders for imported stuff
 String getDomainName()
          Get the classloader domain name
protected abstract  DelegateLoader getExported()
          Get the delegate loader for exported stuff
protected  String getName()
          Get a simple name for the classloader
abstract  ObjectName getObjectName()
          Get the object name the classloader is registered in the MBeanServer with
abstract  String[] getPackageNames()
          Get the exported packages
protected abstract  ProtectionDomain getProtectionDomain(String className, String path)
          Get the protection domain
 List<org.jboss.util.loading.Translator> getTranslators()
          Get the policy's translators.
protected abstract  boolean isBlackListable()
          Whether to cache misses
protected abstract  boolean isCacheable()
          Whether to cache
protected abstract  boolean isImportAll()
          Whether to import all exports from other classloaders in the domain
protected abstract  ClassLoader isJDKRequest(String name)
          Check whether this a request from the jdk if it is return the relevant classloader
 void removeTranslator(org.jboss.util.loading.Translator translator)
          Remove the translator.
 void setTranslators(List<org.jboss.util.loading.Translator> translators)
          Set the translators.
protected  void shutdownPolicy()
          Shutdown the policy
 String toLongString()
          A long version of toString()
protected  void toLongString(StringBuilder builder)
          For subclasses to add information for toLongString()
 String toString()
           
protected  byte[] transform(String className, byte[] byteCode, ProtectionDomain protectionDomain)
          Transform the byte code
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BaseClassLoaderPolicy

public BaseClassLoaderPolicy()
Create a new BaseClassLoaderPolicy.

Throws:
SecurityException - if the caller does not have permission to create a classloader
Method Detail

getAccessControlContext

protected AccessControlContext getAccessControlContext()
Get the access control context for this policy

Returns:
the access control context

getExported

protected abstract DelegateLoader getExported()
Get the delegate loader for exported stuff

NOTE: Protected access for security reasons

Returns:
the delegate loader

getName

protected String getName()
Get a simple name for the classloader

Returns:
the name

getPackageNames

public abstract String[] getPackageNames()
Get the exported packages

Provides a hint for indexing

Returns:
the package names

getDelegates

protected abstract List<? extends DelegateLoader> getDelegates()
Get the delegate loaders for imported stuff

NOTE: Protected access for security reasons

Returns:
the delegate loaders

isImportAll

protected abstract boolean isImportAll()
Whether to import all exports from other classloaders in the domain

Returns:
true to import all

getProtectionDomain

protected abstract ProtectionDomain getProtectionDomain(String className,
                                                        String path)
Get the protection domain

NOTE: Defined as protected here for security reasons

Parameters:
className - the class name
path - the path
Returns:
the protection domain

transform

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

By default, this delegates to the domain

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

isCacheable

protected abstract boolean isCacheable()
Whether to cache

Returns:
true to cache

isBlackListable

protected abstract boolean isBlackListable()
Whether to cache misses

Returns:
true to cache misses

getObjectName

public abstract ObjectName getObjectName()
Get the object name the classloader is registered in the MBeanServer with

Returns:
the object name

isJDKRequest

protected abstract ClassLoader isJDKRequest(String name)
Check whether this a request from the jdk if it is return the relevant classloader

Parameters:
name - the class name
Returns:
the classloader

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

toString

public String toString()
Overrides:
toString in class Object

getDomainName

public String getDomainName()
Get the classloader domain name

Returns:
the domain

shutdownPolicy

protected void shutdownPolicy()
Shutdown the policy

The default implementation removes and shutdowns the 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

getTranslators

public List<org.jboss.util.loading.Translator> getTranslators()
Get the policy's translators.

Returns:
the translators

setTranslators

public void setTranslators(List<org.jboss.util.loading.Translator> translators)
Set the translators.

Parameters:
translators - the translators

addTranslator

public void addTranslator(org.jboss.util.loading.Translator translator)
Add the translator.

Parameters:
translator - the translator to add
Throws:
IllegalArgumentException - for null translator

removeTranslator

public void removeTranslator(org.jboss.util.loading.Translator translator)
Remove the translator.

Parameters:
translator - the translator to remove
Throws:
IllegalArgumentException - for null translator


Copyright © 2009 JBoss, a division of Red Hat, Inc.. All Rights Reserved.