org.jboss.classloader.spi
Class ClassLoaderPolicy

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

public abstract class ClassLoaderPolicy
extends BaseClassLoaderPolicy

ClassLoader policy.

Version:
$Revision: 1.1 $
Author:
Adrian Brock

Constructor Summary
ClassLoaderPolicy()
           
 
Method Summary
 PackageInformation getClassPackageInformation(String className, String packageName)
          Get the package information for a class
protected  List<? extends DelegateLoader> getDelegates()
          Get the delegate loaders for imported stuff
 DelegateLoader getExported()
          Get the delegate loader for exported stuff
 ObjectName getObjectName()
          Get the object name the classloader is registered in the MBeanServer with
 PackageInformation getPackageInformation(String packageName)
          Get the package information
 String[] getPackageNames()
          Get the exported packages
protected  ProtectionDomain getProtectionDomain(String className, String path)
          Get the protection domain
abstract  URL getResource(String path)
          Get the resource
 InputStream getResourceAsStream(String path)
          Get the resource as a stream
abstract  void getResources(String name, Set<URL> urls)
          Get resources
protected  boolean isBlackListable()
          Whether to cache misses
protected  boolean isCacheable()
          Whether to cache
protected  boolean isImportAll()
          Whether to import all exports from other classloaders in the domain
protected  ClassLoader isJDKRequest(String name)
          Check whether this a request from the jdk if it is return the relevant classloader
protected  void toLongString(StringBuilder builder)
          For subclasses to add information for toLongString()
 
Methods inherited from class org.jboss.classloader.spi.base.BaseClassLoaderPolicy
addTranslator, clearBlackList, getAccessControlContext, getDomainName, getName, getTranslators, removeTranslator, setTranslators, shutdownPolicy, toLongString, toString, transform
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ClassLoaderPolicy

public ClassLoaderPolicy()
Method Detail

getExported

public DelegateLoader getExported()
Get the delegate loader for exported stuff

By default this uses getPackageNames() to create a FilteredDelegateLoader

Specified by:
getExported in class BaseClassLoaderPolicy
Returns:
the delegate loader

getPackageNames

public String[] getPackageNames()
Get the exported packages

Provides a hint for indexing

No packages are exported by default

The returned package names can be null to indicate nothing is exported, but if an array is returned it should not include a null package element.

Specified by:
getPackageNames in class BaseClassLoaderPolicy
Returns:
the package names

getDelegates

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

There are no imports by default

NOTE: Protected access for security reasons

Specified by:
getDelegates in class BaseClassLoaderPolicy
Returns:
the delegate loaders

isImportAll

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

False by default

Specified by:
isImportAll in class BaseClassLoaderPolicy
Returns:
true to import all

isCacheable

protected boolean isCacheable()
Whether to cache

True by default

Specified by:
isCacheable in class BaseClassLoaderPolicy
Returns:
true to cache

isBlackListable

protected boolean isBlackListable()
Whether to cache misses

True by default

Specified by:
isBlackListable in class BaseClassLoaderPolicy
Returns:
true to cache misses

getResource

public abstract URL getResource(String path)
Get the resource

Parameters:
path - the path
Returns:
the url or null if not found

getResourceAsStream

public InputStream getResourceAsStream(String path)
Get the resource as a stream

Uses getResource(String) by default

Parameters:
path - the path
Returns:
the stream or null if not found

getResources

public abstract void getResources(String name,
                                  Set<URL> urls)
                           throws IOException
Get resources

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

getProtectionDomain

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

By default there is no protection domain

NOTE: Protected access for security reasons

Specified by:
getProtectionDomain in class BaseClassLoaderPolicy
Parameters:
className - the class name
path - the path
Returns:
the protection domain

getPackageInformation

public PackageInformation getPackageInformation(String packageName)
Get the package information

There is no package information by default

Parameters:
packageName - the package information
Returns:
the information or null if there is none

getClassPackageInformation

public PackageInformation getClassPackageInformation(String className,
                                                     String packageName)
Get the package information for a class

The default is to invoke getPackageInformation for the class's package

Parameters:
className - name the class name
packageName - the package information
Returns:
the information or null if there is none

isJDKRequest

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

By default this uses the and returns the system classloader if true.

Specified by:
isJDKRequest in class BaseClassLoaderPolicy
Parameters:
name - the class name
Returns:
the classloader

getObjectName

public ObjectName getObjectName()
Description copied from class: BaseClassLoaderPolicy
Get the object name the classloader is registered in the MBeanServer with

Specified by:
getObjectName in class BaseClassLoaderPolicy
Returns:
the object name

toLongString

protected void toLongString(StringBuilder builder)
Description copied from class: BaseClassLoaderPolicy
For subclasses to add information for toLongString()

Overrides:
toLongString in class BaseClassLoaderPolicy
Parameters:
builder - the builder


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