org.jboss.classloader.spi
Class ClassLoaderDomain

java.lang.Object
  extended by org.jboss.classloader.spi.base.BaseClassLoaderDomain
      extended by org.jboss.classloader.spi.ClassLoaderDomain
All Implemented Interfaces:
MBeanRegistration, ClassLoaderDomainMBean, Loader

public class ClassLoaderDomain
extends BaseClassLoaderDomain
implements Loader, ClassLoaderDomainMBean, MBeanRegistration

ClassLoaderDomain.

Version:
$Revision: 1.1 $
Author:
Adrian Brock

Constructor Summary
ClassLoaderDomain(String name)
          Create a new ClassLoaderDomain with the ParentPolicy.BEFORE loading rules.
 
Method Summary
protected  Package afterGetPackage(String name)
          Invoked after getPackage is attempted to allow a postload attempt, e.g.
protected  void afterGetPackages(Set<Package> packages)
          Invoked after getPackages is attempted to allow a postload attempt, e.g.
protected  URL afterGetResource(String name)
          Invoked after getResource is attempted to allow a postload attempt, e.g.
protected  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  Package beforeGetPackage(String name)
          Invoked before getPackage is attempted to allow a preload attempt, e.g.
protected  void beforeGetPackages(Set<Package> packages)
          Invoked before getPackages is attempted to allow a preload attempt, e.g.
protected  URL beforeGetResource(String name)
          Invoked before getResource is attempted to allow a preload attempt, e.g.
protected  void beforeGetResources(String name, Set<URL> urls)
          Invoked before getResources is attempted to allow a preload attempt, e.g.
protected  void beforeUnregisterClassLoader(ClassLoader classLoader, ClassLoaderPolicy policy)
          Invoked before adding a classloader policy
protected  Loader findAfterLoader(String name)
          Invoked after classloading is attempted to allow a postload attempt, e.g.
protected  Loader findBeforeLoader(String name)
          Invoked before classloading is attempted to allow a preload attempt, e.g.
 ObjectName findClassLoaderForClass(String name)
          Find the classloader for a class
protected  Loader findLoaderFromParent(String name)
          Try to find a loader from the parent
 String getName()
          Get the name.
 ObjectName getObjectName()
          Get the object name
protected  Package getPackageFromParent(String name)
          Try to get a package from the parent
protected  void getPackagesFromParent(Set<Package> packages, ClassFilter filter)
          Try to get packages from the parent
 Loader getParent()
          Get the parent
 ObjectName getParentDomain()
          Get the parent
 String getParentDomainName()
          Get the parent
 ParentPolicy getParentPolicy()
          Get the parent policy
 String getParentPolicyName()
          Get the parent policy name
protected  URL getResourceFromParent(String name)
          Try to get a resource from the parent
protected  void getResourcesFromParent(String name, Set<URL> urls)
          Try to get resources from the parent
 ObjectName getSystem()
          Get the classloader system
 boolean isUseLoadClassForParent()
          Get the useLoadClassForParent.
 List<ObjectName> listClassLoaders()
          Get the classloaders
 Map<String,List<ObjectName>> listExportingClassLoaders()
          Get the exporting classloaders
 List<ObjectName> listExportingClassLoaders(String packageName)
          Get the classloaders export a package
protected  Class<?> loadClassAfter(String name)
          Invoked after classloading is attempted to allow a postload attempt, e.g.
protected  Class<?> loadClassBefore(String name)
          Invoked before classloading is attempted to allow a preload attempt, e.g.
protected  Class<?> loadClassFromParent(String name)
          Try to find a load a from the parent
 Set<URL> loadResources(String name)
          Get resources
 void postDeregister()
           
 void postRegister(Boolean registrationDone)
           
 void preDeregister()
           
 ObjectName preRegister(MBeanServer server, ObjectName name)
           
protected  void registerClassLoaderMBean(ClassLoader cl)
          Register a classloader with the MBeanServer
 void setParent(Loader parent)
          Set the parent.
 void setParentPolicy(ParentPolicy parentPolicy)
          Set the parentPolicy.
 void setUseLoadClassForParent(boolean useLoadClassForParent)
          Set the useLoadClassForParent.
protected  void toLongString(StringBuilder builder)
          For subclasses to add information for toLongString()
 String toString()
           
protected  void unregisterClassLoaderMBean(ClassLoader cl)
          Unregister a classloader from the MBeanServer
 
Methods inherited from class org.jboss.classloader.spi.base.BaseClassLoaderDomain
afterUnregisterClassLoader, beforeRegisterClassLoader, checkClassCacheAndBlackList, clearBlackList, findLoader, flushCaches, getAllClassLoaders, getClassBlackListSize, getClassCacheSize, getClassLoaders, getClassLoadersByPackage, getClassLoaderSystem, getPackage, getPackages, getParentClassLoader, getResource, getResourceBlackListSize, getResourceCacheSize, getResources, hasClassLoaders, listClassBlackList, listClassCache, listResourceBlackList, listResourceCache, loadClass, loadClass, shutdownDomain, toLongString, transform
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jboss.classloader.spi.Loader
getPackage, getPackages, getResource, getResources, loadClass
 
Methods inherited from interface org.jboss.classloader.spi.ClassLoaderDomainMBean
flushCaches, getClassBlackListSize, getClassCacheSize, getResourceBlackListSize, getResourceCacheSize, listClassBlackList, listClassCache, listResourceBlackList, listResourceCache, loadClass
 

Constructor Detail

ClassLoaderDomain

public ClassLoaderDomain(String name)
Create a new ClassLoaderDomain with the ParentPolicy.BEFORE loading rules.

Parameters:
name - the name of the domain
Throws:
IllegalArgumentException - for a null name
Method Detail

getName

public String getName()
Get the name.

Specified by:
getName in interface ClassLoaderDomainMBean
Returns:
the name.

getObjectName

public ObjectName getObjectName()
Get the object name

Returns:
the object name

getParentPolicy

public ParentPolicy getParentPolicy()
Get the parent policy

Returns:
the parent policy.

setParentPolicy

public void setParentPolicy(ParentPolicy parentPolicy)
Set the parentPolicy.

Parameters:
parentPolicy - the parentPolicy.
Throws:
IllegalArgumentException - for a null parent policy

getParentPolicyName

public String getParentPolicyName()
Description copied from interface: ClassLoaderDomainMBean
Get the parent policy name

Specified by:
getParentPolicyName in interface ClassLoaderDomainMBean
Returns:
the parent policy name.

getParent

public Loader getParent()
Get the parent

Returns:
the parent.

setParent

public void setParent(Loader parent)
Set the parent.

Parameters:
parent - the parent.

isUseLoadClassForParent

public boolean isUseLoadClassForParent()
Get the useLoadClassForParent.

Specified by:
isUseLoadClassForParent in class BaseClassLoaderDomain
Returns:
the useLoadClassForParent.

setUseLoadClassForParent

public void setUseLoadClassForParent(boolean useLoadClassForParent)
Set the useLoadClassForParent.

Parameters:
useLoadClassForParent - the useLoadClassForParent.

getParentDomain

public ObjectName getParentDomain()
Description copied from interface: ClassLoaderDomainMBean
Get the parent

Specified by:
getParentDomain in interface ClassLoaderDomainMBean
Returns:
the parent.

getParentDomainName

public String getParentDomainName()
Description copied from interface: ClassLoaderDomainMBean
Get the parent

Specified by:
getParentDomainName in interface ClassLoaderDomainMBean
Returns:
the parent.

getSystem

public ObjectName getSystem()
Description copied from interface: ClassLoaderDomainMBean
Get the classloader system

Specified by:
getSystem in interface ClassLoaderDomainMBean
Returns:
the system

listClassLoaders

public List<ObjectName> listClassLoaders()
Description copied from interface: ClassLoaderDomainMBean
Get the classloaders

Specified by:
listClassLoaders in interface ClassLoaderDomainMBean
Returns:
the classloaders

listExportingClassLoaders

public Map<String,List<ObjectName>> listExportingClassLoaders()
Description copied from interface: ClassLoaderDomainMBean
Get the exporting classloaders

Specified by:
listExportingClassLoaders in interface ClassLoaderDomainMBean
Returns:
a map of packages to classloaders

listExportingClassLoaders

public List<ObjectName> listExportingClassLoaders(String packageName)
Description copied from interface: ClassLoaderDomainMBean
Get the classloaders export a package

Specified by:
listExportingClassLoaders in interface ClassLoaderDomainMBean
Parameters:
packageName - the package name
Returns:
the classloaders

findClassLoaderForClass

public ObjectName findClassLoaderForClass(String name)
                                   throws ClassNotFoundException
Description copied from interface: ClassLoaderDomainMBean
Find the classloader for a class

Specified by:
findClassLoaderForClass in interface ClassLoaderDomainMBean
Parameters:
name - the class name
Returns:
the classloader or null if it is not loaded by a managed classloader
Throws:
ClassNotFoundException - when the class is not found

loadResources

public Set<URL> loadResources(String name)
                       throws IOException
Description copied from interface: ClassLoaderDomainMBean
Get resources

Specified by:
loadResources in interface ClassLoaderDomainMBean
Parameters:
name - the name of the resource
Returns:
the resource urls
Throws:
IOException - for any error

toLongString

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

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

toString

public String toString()
Overrides:
toString in class Object

loadClassBefore

protected Class<?> loadClassBefore(String name)
Description copied from class: BaseClassLoaderDomain
Invoked before classloading is attempted to allow a preload attempt, e.g. from the parent

Specified by:
loadClassBefore in class BaseClassLoaderDomain
Parameters:
name - the class name
Returns:
the loader if found or null otherwise

loadClassAfter

protected Class<?> loadClassAfter(String name)
Description copied from class: BaseClassLoaderDomain
Invoked after classloading is attempted to allow a postload attempt, e.g. from the parent

Specified by:
loadClassAfter in class BaseClassLoaderDomain
Parameters:
name - the class name
Returns:
the loader if found or null otherwise

loadClassFromParent

protected Class<?> loadClassFromParent(String name)
Try to find a load a from the parent

Parameters:
name - the name
Returns:
the class if found

findBeforeLoader

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

Specified by:
findBeforeLoader in class BaseClassLoaderDomain
Parameters:
name - the class resource name
Returns:
the loader if found or null otherwise

findAfterLoader

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

Specified by:
findAfterLoader in class BaseClassLoaderDomain
Parameters:
name - the class resource name
Returns:
the loader if found or null otherwise

findLoaderFromParent

protected Loader findLoaderFromParent(String name)
Try to find a loader from the parent

Parameters:
name - the name
Returns:
the loader if found

beforeGetResource

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

Specified by:
beforeGetResource in class BaseClassLoaderDomain
Parameters:
name - the resource name
Returns:
the url if found or null otherwise

afterGetResource

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

Specified by:
afterGetResource in class BaseClassLoaderDomain
Parameters:
name - the resource name
Returns:
the url if found or null otherwise

getResourceFromParent

protected URL getResourceFromParent(String name)
Try to get a resource from the parent

Parameters:
name - the name
Returns:
the url if found

beforeGetResources

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

Specified by:
beforeGetResources in class BaseClassLoaderDomain
Parameters:
name - the resource name
urls - the urls to add to
Throws:
IOException - for any error

afterGetResources

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

Specified by:
afterGetResources in class BaseClassLoaderDomain
Parameters:
name - the resource name
urls - the urls to add to
Throws:
IOException - for any error

getResourcesFromParent

protected void getResourcesFromParent(String name,
                                      Set<URL> urls)
                               throws IOException
Try to get resources from the parent

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

beforeGetPackage

protected Package beforeGetPackage(String name)
Description copied from class: BaseClassLoaderDomain
Invoked before getPackage is attempted to allow a preload attempt, e.g. from the parent

Specified by:
beforeGetPackage in class BaseClassLoaderDomain
Parameters:
name - the package name
Returns:
the package if found or null otherwise

afterGetPackage

protected Package afterGetPackage(String name)
Description copied from class: BaseClassLoaderDomain
Invoked after getPackage is attempted to allow a postload attempt, e.g. from the parent

Specified by:
afterGetPackage in class BaseClassLoaderDomain
Parameters:
name - the package name
Returns:
the url if found or null otherwise

getPackageFromParent

protected Package getPackageFromParent(String name)
Try to get a package from the parent

Parameters:
name - the name
Returns:
the package if found

beforeGetPackages

protected void beforeGetPackages(Set<Package> packages)
Description copied from class: BaseClassLoaderDomain
Invoked before getPackages is attempted to allow a preload attempt, e.g. from the parent

Specified by:
beforeGetPackages in class BaseClassLoaderDomain
Parameters:
packages - the packages to add to

afterGetPackages

protected void afterGetPackages(Set<Package> packages)
Description copied from class: BaseClassLoaderDomain
Invoked after getPackages is attempted to allow a postload attempt, e.g. from the parent

Specified by:
afterGetPackages in class BaseClassLoaderDomain
Parameters:
packages - the packages to add to

getPackagesFromParent

protected void getPackagesFromParent(Set<Package> packages,
                                     ClassFilter filter)
Try to get packages from the parent

Parameters:
packages - the packages to add to
filter - the filter

preRegister

public ObjectName preRegister(MBeanServer server,
                              ObjectName name)
                       throws Exception
Specified by:
preRegister in interface MBeanRegistration
Throws:
Exception

postRegister

public void postRegister(Boolean registrationDone)
Specified by:
postRegister in interface MBeanRegistration

preDeregister

public void preDeregister()
                   throws Exception
Specified by:
preDeregister in interface MBeanRegistration
Throws:
Exception

postDeregister

public void postDeregister()
Specified by:
postDeregister in interface MBeanRegistration

afterRegisterClassLoader

protected void afterRegisterClassLoader(ClassLoader classLoader,
                                        ClassLoaderPolicy policy)
Description copied from class: BaseClassLoaderDomain
Invoked after adding a classloader policy

Overrides:
afterRegisterClassLoader in class BaseClassLoaderDomain
Parameters:
classLoader - the classloader
policy - the classloader policy

beforeUnregisterClassLoader

protected void beforeUnregisterClassLoader(ClassLoader classLoader,
                                           ClassLoaderPolicy policy)
Description copied from class: BaseClassLoaderDomain
Invoked before adding a classloader policy

Overrides:
beforeUnregisterClassLoader in class BaseClassLoaderDomain
Parameters:
classLoader - the classloader
policy - the classloader policy

registerClassLoaderMBean

protected void registerClassLoaderMBean(ClassLoader cl)
Register a classloader with the MBeanServer

Parameters:
cl - the classloader

unregisterClassLoaderMBean

protected void unregisterClassLoaderMBean(ClassLoader cl)
Unregister a classloader from the MBeanServer

Parameters:
cl - the classloader


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