站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > JBoss 4.0.1 sp1 jmx API Documentation 英文版文档

HeirarchicalLoaderRepository3 (JBoss/JMX API) - JBoss 4.0.1 sp1 jmx API Documentation 英文版文档


org.jboss.mx.loading
Class HeirarchicalLoaderRepository3

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

public class HeirarchicalLoaderRepository3
extends UnifiedLoaderRepository3

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.

Version:
$Revision: 1.11 $
Author:
Scott.Stark@jboss.org

Field Summary
 
Fields inherited from class org.jboss.mx.loading.LoaderRepository
instance, loaders, translator
 
Fields inherited from interface org.jboss.mx.server.ServerConstants
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 server)
          Create a HeirarchicalLoaderRepository3 with a parent obtained by querying the server for the ServerConstants.DEFAULT_LOADER_NAME mbean.
HeirarchicalLoaderRepository3(MBeanServer server, ObjectName parentName)
          Create a HeirarchicalLoaderRepository3 with a parent obtained by querying the server for the parentName mbean.
HeirarchicalLoaderRepository3(UnifiedLoaderRepository3 parent)
          Create a HeirarchicalLoaderRepository3 with an explicit parent.
 
Method Summary
 int compare(LoaderRepository lr)
          Compare two loader repository, by default we do no special ordering
 Class getCachedClass(String classname)
          Override getCachedClass to return the parent repository cached class if java2ParentDelegation=true, followed by this repository's cached value.
 Set getPackageClassLoaders(String name)
          Called by LoadMgr to obtain all class loaders.
 URL getResource(String name, ClassLoader scl)
          Find a resource from this repository.
 void getResources(String name, ClassLoader cl, List urls)
          Find all resource URLs for the given name.
 URL[] getURLs()
          Obtain a listing of the URLs for all UnifiedClassLoaders associated with the repository
 boolean getUseParentFirst()
          Get the use parent first flag.
 Class loadClass(String name, boolean resolve, ClassLoader scl)
          Load a class using the repository class loaders.
 Class loadClassFromCache(String name)
          Called by LoadMgr to locate a previously loaded class.
 RepositoryClassLoader newClassLoader(URL url, boolean addToRepository)
          Create RepositoryClassLoader and optionally add it to the repository
 RepositoryClassLoader newClassLoader(URL url, URL origURL, boolean addToRepository)
          Create RepositoryClassLoader and optionally add it to the repository
protected  int reverseCompare(LoaderRepository 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
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
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
getTranslator, setTranslator
 

Constructor Detail

HeirarchicalLoaderRepository3

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

Parameters:
parent -
Throws:
AttributeNotFoundException
InstanceNotFoundException
MBeanException
ReflectionException

HeirarchicalLoaderRepository3

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

Parameters:
server -
Throws:
AttributeNotFoundException
InstanceNotFoundException
MBeanException
ReflectionException

HeirarchicalLoaderRepository3

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

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

newClassLoader

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

Specified by:
newClassLoader in interface UnifiedLoaderRepositoryMBean
Overrides:
newClassLoader in class UnifiedLoaderRepository3
Throws:
Exception

newClassLoader

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

Specified by:
newClassLoader in interface UnifiedLoaderRepositoryMBean
Overrides:
newClassLoader in class UnifiedLoaderRepository3
Throws:
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 Class loadClass(String name,
                       boolean resolve,
                       ClassLoader scl)
                throws ClassNotFoundException
Load a class using the repository class loaders.

Overrides:
loadClass in class UnifiedLoaderRepository3
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:
ClassNotFoundException - If the class could not be found.

getCachedClass

public Class getCachedClass(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
Parameters:
classname -
Returns:
the cached class if found, null otherwise

getResource

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

Overrides:
getResource in class UnifiedLoaderRepository3
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(String name,
                         ClassLoader cl,
                         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
Parameters:
name - the resource name
cl - the requesting class loader
urls - a list into which the located resource URLs will be placed

getURLs

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

Specified by:
getURLs in interface UnifiedLoaderRepositoryMBean
Overrides:
getURLs in class UnifiedLoaderRepository3

loadClassFromCache

public Class loadClassFromCache(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
Parameters:
name - the fully qualified class name
Returns:
the cached class if found, null otherwise

getPackageClassLoaders

public Set getPackageClassLoaders(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
Overrides:
getPackageClassLoaders in class UnifiedLoaderRepository3
Returns:
Set

compare

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

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

reverseCompare

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

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


Copyright © 2002 JBoss Group, LLC. All Rights Reserved.