org.jboss.mx.loading
Class HeirarchicalLoaderRepository3

java.lang.Object
  extended byorg.jboss.mx.loading.LoaderRepository (src) 
      extended byorg.jboss.mx.loading.UnifiedLoaderRepository3 (src) 
          extended byorg.jboss.mx.loading.HeirarchicalLoaderRepository3
All Implemented Interfaces:
ClassLoaderRepository (src) , MBeanRegistration (src) , NotificationBroadcaster (src) , NotificationEmitter (src) , ServerConstants (src) , UnifiedLoaderRepository3MBean (src) , UnifiedLoaderRepositoryMBean (src)

public class HeirarchicalLoaderRepository3
extends UnifiedLoaderRepository3 (src)

A simple extension of UnifiedLoaderRepository3 that adds the notion of a parent UnifiedLoaderRepository. Classes and resources are loaded from child first and then the parent depending on the java2ParentDelegation flag.


Field Summary
 
Fields inherited from class org.jboss.mx.loading.LoaderRepository (src)
instance, loaders, translator
 
Fields inherited from interface org.jboss.mx.server.ServerConstants (src)
CLASS_REMOVED, CLASSLOADER, CLASSLOADER_ADDED, CLASSLOADER_REMOVED, DEFAULT_DOMAIN, DEFAULT_LOADER_REPOSITORY_CLASS, DEFAULT_MBEAN_REGISTRY_CLASS, DEFAULT_MBEAN_SERVER_BUILDER_CLASS, DEFAULT_REQUIRED_MODELMBEAN_CLASS, DEFAULT_SCOPED_REPOSITORY_CLASS, DEFAULT_SCOPED_REPOSITORY_PARSER_CLASS, IMPLEMENTATION_NAME, IMPLEMENTATION_VENDOR, IMPLEMENTATION_VERSION, JMI_DOMAIN, LOADER_REPOSITORY_CLASS_PROPERTY, MBEAN_REGISTRY, MBEAN_REGISTRY_CLASS_PROPERTY, MBEAN_SERVER_BUILDER_CLASS_PROPERTY, MBEAN_SERVER_CONFIGURATION, MBEAN_SERVER_DELEGATE, OPTIMIZE_REFLECTED_DISPATCHER, REQUIRED_MODELMBEAN_CLASS_PROPERTY, SPECIFICATION_NAME, SPECIFICATION_VENDOR, SPECIFICATION_VERSION, UNIFIED_LOADER_REPOSITORY_CLASS
 
Constructor Summary
HeirarchicalLoaderRepository3(MBeanServer (src)  server)
          Create a HeirarchicalLoaderRepository3 with a parent obtained by querying the server for the ServerConstants.DEFAULT_LOADER_NAME mbean.
HeirarchicalLoaderRepository3(MBeanServer (src)  server, ObjectName (src)  parentName)
          Create a HeirarchicalLoaderRepository3 with a parent obtained by querying the server for the parentName mbean.
HeirarchicalLoaderRepository3(UnifiedLoaderRepository3 (src)  parent)
          Create a HeirarchicalLoaderRepository3 with an explicit parent.
 
Method Summary
 int compare(LoaderRepository (src)  lr)
          Compare two loader repository, by default we do no special ordering
 java.lang.Class getCachedClass(java.lang.String classname)
          Override getCachedClass to return the parent repository cached class if java2ParentDelegation=true, followed by this repository's cached value.
 java.util.Set getPackageClassLoaders(java.lang.String name)
          Called by LoadMgr to obtain all class loaders.
 java.net.URL getResource(java.lang.String name, java.lang.ClassLoader scl)
          Find a resource from this repository.
 void getResources(java.lang.String name, java.lang.ClassLoader cl, java.util.List urls)
          Find all resource URLs for the given name.
 java.net.URL[] getURLs()
          Obtain a listing of the URLs for all UnifiedClassLoaders associated with the repository
 boolean getUseParentFirst()
          Get the use parent first flag.
 java.lang.Class loadClass(java.lang.String name, boolean resolve, java.lang.ClassLoader scl)
          Load a class using the repository class loaders.
 java.lang.Class loadClassFromCache(java.lang.String name)
          Called by LoadMgr to locate a previously loaded class.
 RepositoryClassLoader (src) newClassLoader(java.net.URL url, boolean addToRepository)
          Create RepositoryClassLoader and optionally add it to the repository
 RepositoryClassLoader (src) newClassLoader(java.net.URL url, java.net.URL origURL, boolean addToRepository)
          Create RepositoryClassLoader and optionally add it to the repository
protected  int reverseCompare(LoaderRepository (src)  lr)
          Allow subclasses to override the ordering
 void setUseParentFirst(boolean flag)
          Set the use parent first flag.
 
Methods inherited from class org.jboss.mx.loading.UnifiedLoaderRepository3 (src)
addClassLoader, addClassLoaderURL, addNotificationListener, cacheLoadedClass, displayClassInfo, flush, getCacheSize, getClassLoadersSize, getInstance, getNotificationInfo, getResourceFromGlobalCache, getResourceFromRepository, getWrappingClassLoader, loadClass, loadClassBefore, loadClassWithout, postDeregister, postRegister, preDeregister, preRegister, registerClassLoader, removeClassLoader, removeNotificationListener, removeNotificationListener
 
Methods inherited from class org.jboss.mx.loading.LoaderRepository (src)
getLoaders, getNativeClassForName, getTranslator, setTranslator
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jboss.mx.loading.UnifiedLoaderRepositoryMBean (src)
getTranslator, setTranslator
 

Constructor Detail

HeirarchicalLoaderRepository3

public HeirarchicalLoaderRepository3(UnifiedLoaderRepository3 (src)  parent)
                              throws AttributeNotFoundException (src) ,
                                     InstanceNotFoundException (src) ,
                                     MBeanException (src) ,
                                     ReflectionException (src) 
Create a HeirarchicalLoaderRepository3 with an explicit parent.

Parameters:
parent -
Throws:
AttributeNotFoundException (src)
InstanceNotFoundException (src)
MBeanException (src)
ReflectionException (src)

HeirarchicalLoaderRepository3

public HeirarchicalLoaderRepository3(MBeanServer (src)  server)
                              throws AttributeNotFoundException (src) ,
                                     InstanceNotFoundException (src) ,
                                     MBeanException (src) ,
                                     ReflectionException (src) 
Create a HeirarchicalLoaderRepository3 with a parent obtained by querying the server for the ServerConstants.DEFAULT_LOADER_NAME mbean.

Parameters:
server -
Throws:
AttributeNotFoundException (src)
InstanceNotFoundException (src)
MBeanException (src)
ReflectionException (src)

HeirarchicalLoaderRepository3

public HeirarchicalLoaderRepository3(MBeanServer (src)  server,
                                     ObjectName (src)  parentName)
                              throws AttributeNotFoundException (src) ,
                                     InstanceNotFoundException (src) ,
                                     MBeanException (src) ,
                                     ReflectionException (src) 
Create a HeirarchicalLoaderRepository3 with a parent obtained by querying the server for the parentName mbean.

Parameters:
server -
parentName -
Throws:
AttributeNotFoundException (src)
InstanceNotFoundException (src)
MBeanException (src)
ReflectionException (src)
Method Detail

newClassLoader

public RepositoryClassLoader (src)  newClassLoader(java.net.URL url,
                                            boolean addToRepository)
                                     throws java.lang.Exception
Description copied from class: LoaderRepository (src)
Create RepositoryClassLoader and optionally add it to the repository

Specified by:
newClassLoader in interface UnifiedLoaderRepositoryMBean (src)
Overrides:
newClassLoader in class UnifiedLoaderRepository3 (src)
Throws:
java.lang.Exception

newClassLoader

public RepositoryClassLoader (src)  newClassLoader(java.net.URL url,
                                            java.net.URL origURL,
                                            boolean addToRepository)
                                     throws java.lang.Exception
Description copied from class: LoaderRepository (src)
Create RepositoryClassLoader and optionally add it to the repository

Specified by:
newClassLoader in interface UnifiedLoaderRepositoryMBean (src)
Overrides:
newClassLoader in class UnifiedLoaderRepository3 (src)
Throws:
java.lang.Exception

getUseParentFirst

public boolean getUseParentFirst()
Get the use parent first flag. This indicates whether the parent repository is consulted first for resource and class loading or if the HeirchicalLoaderRepository is consulted first.

Returns:
true if the parent repository is consulted first, false if the HeirchicalLoaderRepository is consulted first.

setUseParentFirst

public void setUseParentFirst(boolean flag)
Set the use parent first flag. This indicates whether the parent repository is consulted first for resource and class loading or if the HeirchicalLoaderRepository is consulted first.

Parameters:
flag - true if the parent repository is consulted first, false if the HeirchicalLoaderRepository is consulted first.

loadClass

public java.lang.Class loadClass(java.lang.String name,
                                 boolean resolve,
                                 java.lang.ClassLoader scl)
                          throws java.lang.ClassNotFoundException
Load a class using the repository class loaders.

Overrides:
loadClass in class UnifiedLoaderRepository3 (src)
Parameters:
name - The name of the class
resolve - an obsolete unused parameter from ClassLoader.loadClass
scl - The asking class loader
Returns:
The loaded class
Throws:
java.lang.ClassNotFoundException - If the class could not be found.

getCachedClass

public java.lang.Class getCachedClass(java.lang.String classname)
Override getCachedClass to return the parent repository cached class if java2ParentDelegation=true, followed by this repository's cached value. Else, if java2ParentDelegation=false, only check this repository's cache to attempt to load the class from the child repository before going to the parent cache.

Overrides:
getCachedClass in class UnifiedLoaderRepository3 (src)
Parameters:
classname -
Returns:
the cached class if found, null otherwise

getResource

public java.net.URL getResource(java.lang.String name,
                                java.lang.ClassLoader scl)
Find a resource from this repository. This first looks to this repository and then the parent repository.

Overrides:
getResource in class UnifiedLoaderRepository3 (src)
Parameters:
name - The name of the resource
scl - The asking class loader
Returns:
An URL for reading the resource, or null if the resource could not be found.

getResources

public void getResources(java.lang.String name,
                         java.lang.ClassLoader cl,
                         java.util.List urls)
Find all resource URLs for the given name. This is entails an exhuastive search of this and the parent repository and is an expensive operation.

Overrides:
getResources in class UnifiedLoaderRepository3 (src)
Parameters:
name - the resource name
cl - the requesting class loader
urls - a list into which the located resource URLs will be placed

getURLs

public java.net.URL[] getURLs()
Obtain a listing of the URLs for all UnifiedClassLoaders associated with the repository

Specified by:
getURLs in interface UnifiedLoaderRepositoryMBean (src)
Overrides:
getURLs in class UnifiedLoaderRepository3 (src)

loadClassFromCache

public java.lang.Class loadClassFromCache(java.lang.String name)
Called by LoadMgr to locate a previously loaded class. This looks first to this repository and then the parent repository.

Overrides:
loadClassFromCache in class UnifiedLoaderRepository3 (src)
Parameters:
name - the fully qualified class name
Returns:
the cached class if found, null otherwise

getPackageClassLoaders

public java.util.Set getPackageClassLoaders(java.lang.String name)
Called by LoadMgr to obtain all class loaders. This returns a set of PkgClassLoader with the HeirarchicalLoaderRepository3 ordered ahead of the parent repository pkg class loaders

Specified by:
getPackageClassLoaders in interface UnifiedLoaderRepository3MBean (src)
Overrides:
getPackageClassLoaders in class UnifiedLoaderRepository3 (src)
Returns:
Set

compare

public int compare(LoaderRepository (src)  lr)
Description copied from class: LoaderRepository (src)
Compare two loader repository, by default we do no special ordering

Overrides:
compare in class LoaderRepository (src)
Parameters:
lr - the loader repository
Returns:
-1, 0, 1 depending upon the order

reverseCompare

protected int reverseCompare(LoaderRepository (src)  lr)
Description copied from class: LoaderRepository (src)
Allow subclasses to override the ordering

Overrides:
reverseCompare in class LoaderRepository (src)
Parameters:
lr - the loader repository
Returns:
-1, 0, 1 depending upon the order