org.jboss.mx.loading
Class LoaderRepository

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

public abstract class LoaderRepository
extends java.lang.Object
implements ServerConstants (src) , ClassLoaderRepository (src)

Abstract base class of all loader repository implementations

See Also:
BasicLoaderRepository (src)

Field Summary
protected static LoaderRepository (src) instance
           
protected static java.util.Vector loaders
           
protected  Translator (src) 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
LoaderRepository()
           
 
Method Summary
abstract  void addClassLoader(java.lang.ClassLoader cl)
          Add a class loader to the repository
abstract  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.
 int compare(LoaderRepository (src)  lr)
          Compare two loader repository, by default we do no special ordering
 java.lang.Class getCachedClass(java.lang.String classname)
           
 java.util.Vector getLoaders()
           
static java.lang.Class getNativeClassForName(java.lang.String className)
          Return the class of a java native type
abstract  java.net.URL getResource(java.lang.String name, java.lang.ClassLoader cl)
          Find a resource URL for the given name
abstract  void getResources(java.lang.String name, java.lang.ClassLoader cl, java.util.List urls)
          Find all resource URLs for the given name.
 Translator (src) getTranslator()
           
 java.net.URL[] getURLs()
           
abstract  java.lang.Class loadClass(java.lang.String className)
          Loads a class from the repository.
abstract  java.lang.Class loadClass(java.lang.String name, boolean resolve, java.lang.ClassLoader cl)
          Load the given class from the repository
abstract  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.
abstract  java.lang.Class loadClassWithout(java.lang.ClassLoader loader, java.lang.String className)
          Loads a class from the repository, excluding the given classloader.
abstract  RepositoryClassLoader (src) newClassLoader(java.net.URL url, boolean addToRepository)
          Create RepositoryClassLoader and optionally add it to the repository
abstract  RepositoryClassLoader (src) newClassLoader(java.net.URL url, java.net.URL origURL, boolean addToRepository)
          Create RepositoryClassLoader and optionally add it to the repository
abstract  void removeClassLoader(java.lang.ClassLoader cl)
          Remove a cladd loader from the repository.
protected  int reverseCompare(LoaderRepository (src)  lr)
          Allow subclasses to override the ordering
 void setTranslator(Translator (src)  t)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

loaders

protected static java.util.Vector loaders

instance

protected static LoaderRepository (src)  instance

translator

protected Translator (src)  translator
Constructor Detail

LoaderRepository

public LoaderRepository()
Method Detail

getLoaders

public java.util.Vector getLoaders()

getURLs

public java.net.URL[] getURLs()

getCachedClass

public java.lang.Class getCachedClass(java.lang.String classname)

getTranslator

public Translator (src)  getTranslator()

setTranslator

public void setTranslator(Translator (src)  t)

compare

public int compare(LoaderRepository (src)  lr)
Compare two loader repository, by default we do no special ordering

Parameters:
lr - the loader repository
Returns:
-1, 0, 1 depending upon the order

loadClass

public abstract 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)
Parameters:
className - the class to load
Returns:
the found class
Throws:
java.lang.ClassNotFoundException - when there is no such class

loadClassWithout

public abstract java.lang.Class loadClassWithout(java.lang.ClassLoader loader,
                                                 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)
Parameters:
loader - 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 abstract 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)
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

newClassLoader

public abstract RepositoryClassLoader (src)  newClassLoader(java.net.URL url,
                                                     boolean addToRepository)
                                              throws java.lang.Exception
Create RepositoryClassLoader and optionally add it to the repository

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 abstract RepositoryClassLoader (src)  newClassLoader(java.net.URL url,
                                                     java.net.URL origURL,
                                                     boolean addToRepository)
                                              throws java.lang.Exception
Create RepositoryClassLoader and optionally add it to the repository

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 abstract java.lang.Class loadClass(java.lang.String name,
                                          boolean resolve,
                                          java.lang.ClassLoader cl)
                                   throws java.lang.ClassNotFoundException
Load the given class from the repository

Parameters:
name -
resolve -
cl -
Returns:
Throws:
java.lang.ClassNotFoundException

getResource

public abstract java.net.URL getResource(java.lang.String name,
                                         java.lang.ClassLoader cl)
Find a resource URL for the given name

Parameters:
name - the resource name
cl - the requesting class loader
Returns:
The resource URL if found, null otherwise

getResources

public abstract void getResources(java.lang.String name,
                                  java.lang.ClassLoader cl,
                                  java.util.List urls)
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.

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

addClassLoader

public abstract void addClassLoader(java.lang.ClassLoader cl)
Add a class loader to the repository


addClassLoaderURL

public abstract 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.

Parameters:
cl -
url -

removeClassLoader

public abstract void removeClassLoader(java.lang.ClassLoader cl)
Remove a cladd loader from the repository.

Parameters:
cl -

getNativeClassForName

public static final java.lang.Class getNativeClassForName(java.lang.String className)
Return the class of a java native type

Returns:
the class, or null if className is not a native class name

reverseCompare

protected int reverseCompare(LoaderRepository (src)  lr)
Allow subclasses to override the ordering

Parameters:
lr - the loader repository
Returns:
-1, 0, 1 depending upon the order