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

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


org.jboss.mx.loading
Class BasicLoaderRepository

java.lang.Object
  extended byorg.jboss.mx.loading.LoaderRepository
      extended byorg.jboss.mx.loading.BasicLoaderRepository
All Implemented Interfaces:
ClassLoaderRepository, ServerConstants

public class BasicLoaderRepository
extends LoaderRepository

Implements a simple classloader repository for the MBean server. The basic loader repository uses an unordered list of classloaders to try and load the required class. There is no attempt made to resolve conflicts between classes loaded by different classloaders.

A thread's context class loader is always searched first. Context class loader is not required to be registered to the repository.

Version:
$Revision: 1.15 $
Author:
Juha Lindfors.
See Also:
LoaderRepository

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_NAME, 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
BasicLoaderRepository()
           
 
Method Summary
 void addClassLoader(ClassLoader cl)
          Add a class loader to the repository
 boolean addClassLoaderURL(ClassLoader cl, URL url)
          Update the set of URLs known to be associated with a previously added class loader.
 URL getResource(String name, ClassLoader cl)
          Find a resource URL for the given name
 void getResources(String name, ClassLoader cl, List urls)
          Find all resource URLs for the given name.
 Class loadClass(String className)
          Loads a class from the repository.
 Class loadClass(String name, boolean resolve, ClassLoader cl)
          Load the given class from the repository
 Class loadClassBefore(ClassLoader stop, String className)
          Loads a class from the repository, using the classloaders that were registered before the given classloader.
 Class loadClassWithout(ClassLoader skipLoader, String className)
          Loads a class from the repository, excluding the given classloader.
 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
 void removeClassLoader(ClassLoader cl)
          Remove a cladd loader from the repository.
 
Methods inherited from class org.jboss.mx.loading.LoaderRepository
compare, getCachedClass, getLoaders, getNativeClassForName, getTranslator, getURLs, reverseCompare, setTranslator
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicLoaderRepository

public BasicLoaderRepository()
Method Detail

loadClass

public Class loadClass(String className)
                throws ClassNotFoundException
Loads a class from the repository. This method attempts to load the class using all the classloader registered to the repository.

Specified by:
loadClass in interface ClassLoaderRepository
Specified by:
loadClass in class LoaderRepository
Parameters:
className - the class to load
Returns:
the found class
Throws:
ClassNotFoundException - when there is no such class

loadClassWithout

public Class loadClassWithout(ClassLoader skipLoader,
                              String className)
                       throws ClassNotFoundException
Loads a class from the repository, excluding the given classloader.

Specified by:
loadClassWithout in interface ClassLoaderRepository
Specified by:
loadClassWithout in class LoaderRepository
Parameters:
skipLoader - the classloader to exclude
className - the class to load
Returns:
the found class
Throws:
ClassNotFoundException - when there is no such class

loadClassBefore

public Class loadClassBefore(ClassLoader stop,
                             String className)
                      throws ClassNotFoundException
Loads a class from the repository, using the classloaders that were registered before the given classloader.

Specified by:
loadClassBefore in interface ClassLoaderRepository
Specified by:
loadClassBefore in class LoaderRepository
Parameters:
stop - consult all the classloaders registered before this one in an attempt to load a class
className - name of the class to load
Returns:
loaded class instance
Throws:
ClassNotFoundException - if none of the consulted classloaders were able to load the requested class

addClassLoader

public void addClassLoader(ClassLoader cl)
Description copied from class: LoaderRepository
Add a class loader to the repository

Specified by:
addClassLoader in class LoaderRepository

addClassLoaderURL

public boolean addClassLoaderURL(ClassLoader cl,
                                 URL url)
Description copied from class: LoaderRepository
Update the set of URLs known to be associated with a previously added class loader.

Specified by:
addClassLoaderURL in class LoaderRepository
Parameters:
cl -
url -

removeClassLoader

public void removeClassLoader(ClassLoader cl)
Description copied from class: LoaderRepository
Remove a cladd loader from the repository.

Specified by:
removeClassLoader in class LoaderRepository
Parameters:
cl -

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 class LoaderRepository
Parameters:
url - the URL to use for class loading
addToRepository - a flag indicating if the CL should be added to the repository
Returns:
the UCL instance
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 class LoaderRepository
Parameters:
url - the URL to use for class loading
origURL - an orignal URL to use as the URL for the CL CodeSource. This is useful when the url is a local copy that is difficult to use for security policy writing.
addToRepository - a flag indicating if the CL should be added to the repository
Returns:
the CL instance
Throws:
Exception

loadClass

public Class loadClass(String name,
                       boolean resolve,
                       ClassLoader cl)
                throws ClassNotFoundException
Description copied from class: LoaderRepository
Load the given class from the repository

Specified by:
loadClass in class LoaderRepository
Parameters:
name -
resolve -
cl -
Returns:
Throws:
ClassNotFoundException

getResource

public URL getResource(String name,
                       ClassLoader cl)
Description copied from class: LoaderRepository
Find a resource URL for the given name

Specified by:
getResource in class LoaderRepository
Parameters:
name - the resource name
cl - the requesting class loader
Returns:
The resource URL if found, null otherwise

getResources

public void getResources(String name,
                         ClassLoader cl,
                         List urls)
Description copied from class: LoaderRepository
Find all resource URLs for the given name. Since this typically entails an exhuastive search of the repository it can be a relatively slow operation.

Specified by:
getResources in class LoaderRepository
Parameters:
name - the resource name
cl - the requesting class loader
urls - a list into which the located resource URLs will be placed


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