org.jboss.mx.loading
Class BasicLoaderRepository

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

public class BasicLoaderRepository
extends LoaderRepository (src)

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.

See Also:
LoaderRepository (src)

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_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(java.lang.ClassLoader cl)
          Add a class loader to the repository
 boolean addClassLoaderURL(java.lang.ClassLoader cl, java.net.URL url)
          Update the set of URLs known to be associated with a previously added class loader.
 java.net.URL getResource(java.lang.String name, java.lang.ClassLoader cl)
          Find a resource URL for the given name
 void getResources(java.lang.String name, java.lang.ClassLoader cl, java.util.List urls)
          Find all resource URLs for the given name.
 java.lang.Class loadClass(java.lang.String className)
          Loads a class from the repository.
 java.lang.Class loadClass(java.lang.String name, boolean resolve, java.lang.ClassLoader cl)
          Load the given class from the repository
 java.lang.Class loadClassBefore(java.lang.ClassLoader stop, java.lang.String className)
          Loads a class from the repository, using the classloaders that were registered before the given classloader.
 java.lang.Class loadClassWithout(java.lang.ClassLoader skipLoader, java.lang.String className)
          Loads a class from the repository, excluding the given classloader.
 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
 void removeClassLoader(java.lang.ClassLoader cl)
          Remove a cladd loader from the repository.
 
Methods inherited from class org.jboss.mx.loading.LoaderRepository (src)
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 java.lang.Class loadClass(java.lang.String className)
                          throws java.lang.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 (src)
Specified by:
loadClass in class LoaderRepository (src)
Parameters:
className - the class to load
Returns:
the found class
Throws:
java.lang.ClassNotFoundException - when there is no such class

loadClassWithout

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

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

loadClassBefore

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

Specified by:
loadClassBefore in interface ClassLoaderRepository (src)
Specified by:
loadClassBefore in class LoaderRepository (src)
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:
java.lang.ClassNotFoundException - if none of the consulted classloaders were able to load the requested class

addClassLoader

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

Specified by:
addClassLoader in class LoaderRepository (src)

addClassLoaderURL

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

Specified by:
addClassLoaderURL in class LoaderRepository (src)
Parameters:
cl -
url -

removeClassLoader

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

Specified by:
removeClassLoader in class LoaderRepository (src)
Parameters:
cl -

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 class LoaderRepository (src)
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:
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 class LoaderRepository (src)
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:
java.lang.Exception

loadClass

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

Specified by:
loadClass in class LoaderRepository (src)
Parameters:
name -
resolve -
cl -
Returns:
Throws:
java.lang.ClassNotFoundException

getResource

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

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

getResources

public void getResources(java.lang.String name,
                         java.lang.ClassLoader cl,
                         java.util.List urls)
Description copied from class: LoaderRepository (src)
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 (src)
Parameters:
name - the resource name
cl - the requesting class loader
urls - a list into which the located resource URLs will be placed