org.jboss.mx.loading
Class BasicLoaderRepository

java.lang.Object
  extended by org.jboss.mx.loading.LoaderRepository
      extended by org.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: 81022 $
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)
           
 boolean addClassLoaderURL(ClassLoader cl, URL url)
           
 URL getResource(String name, ClassLoader cl)
           
 void getResources(String name, ClassLoader cl, List urls)
           
 Class loadClass(String className)
          Loads a class from the repository.
 Class loadClass(String name, boolean resolve, ClassLoader cl)
           
 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)
           
 RepositoryClassLoader newClassLoader(URL url, URL origURL, boolean addToRepository)
           
 void removeClassLoader(ClassLoader cl)
           
 
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)
Specified by:
addClassLoader in class LoaderRepository

addClassLoaderURL

public boolean addClassLoaderURL(ClassLoader cl,
                                 URL url)
Specified by:
addClassLoaderURL in class LoaderRepository

removeClassLoader

public void removeClassLoader(ClassLoader cl)
Specified by:
removeClassLoader in class LoaderRepository

newClassLoader

public RepositoryClassLoader newClassLoader(URL url,
                                            boolean addToRepository)
                                     throws Exception
Specified by:
newClassLoader in class LoaderRepository
Throws:
Exception

newClassLoader

public RepositoryClassLoader newClassLoader(URL url,
                                            URL origURL,
                                            boolean addToRepository)
                                     throws Exception
Specified by:
newClassLoader in class LoaderRepository
Throws:
Exception

loadClass

public Class loadClass(String name,
                       boolean resolve,
                       ClassLoader cl)
                throws ClassNotFoundException
Specified by:
loadClass in class LoaderRepository
Throws:
ClassNotFoundException

getResource

public URL getResource(String name,
                       ClassLoader cl)
Specified by:
getResource in class LoaderRepository

getResources

public void getResources(String name,
                         ClassLoader cl,
                         List urls)
Specified by:
getResources in class LoaderRepository


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