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

BasicLoaderRepository (JBoss/JMX API) - JBoss 3.2.7 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.6.4.4 $
Author:
Juha Lindfors.
See Also:
LoaderRepository

Field Summary
 
Fields inherited from class org.jboss.mx.loading.LoaderRepository
instance, loaders, nativeClassBySignature, 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)
          Attempts to load a class using the first found instance of a ClassLoader with a given class description.
 Class loadClass(String name, boolean resolve, ClassLoader cl)
          Load the given class from the repository
 Class loadClassWithout(ClassLoader skipLoader, String className)
          Attempts to load a class using the first found instance of a ClassLoader with a given class description.
 UnifiedClassLoader newClassLoader(URL url, boolean addToRepository)
          Create UnifiedClassLoader and optionally add it to the repository
 UnifiedClassLoader newClassLoader(URL url, URL origURL, boolean addToRepository)
          Create UnifiedClassLoader 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
getCachedClass, getDefaultLoaderRepository, getLoaders, getNativeClassForName, getTranslator, getURLs, loadClassBefore, 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
Attempts to load a class using the first found instance of a ClassLoader with a given class description.

Specified by:
loadClass in interface ClassLoaderRepository
Specified by:
loadClass in class LoaderRepository
Parameters:
className - fully qualified name of the class to load
Returns:
loaded class instance
Throws:
ClassNotFoundException - if the class was not found by any of the registered class loaders

loadClassWithout

public Class loadClassWithout(ClassLoader skipLoader,
                              String className)
                       throws ClassNotFoundException
Attempts to load a class using the first found instance of a ClassLoader with a given class description. If a non-null reference is passed as a skipLoader parameter then this class loader will not be used to load the requested class from the repository.

Specified by:
loadClassWithout in interface ClassLoaderRepository
Specified by:
loadClassWithout in class LoaderRepository
Parameters:
skipLoader - this class loader instance will be skipped when attempting to load the given class.
className - fully qualified name of the class to load
Returns:
loaded class instance
Throws:
ClassNotFoundException - if the class was not found by any of the registered class loaders

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 UnifiedClassLoader newClassLoader(URL url,
                                         boolean addToRepository)
                                  throws Exception
Description copied from class: LoaderRepository
Create UnifiedClassLoader 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 UCL should be added to the repository
Returns:
the UCL instance
Throws:
Exception

newClassLoader

public UnifiedClassLoader newClassLoader(URL url,
                                         URL origURL,
                                         boolean addToRepository)
                                  throws Exception
Description copied from class: LoaderRepository
Create UnifiedClassLoader 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 UCL 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 UCL should be added to the repository
Returns:
the UCL 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.