javax.management.loading
Interface ClassLoaderRepository


public interface ClassLoaderRepository

Instances of this interface are used to keep the list of ClassLoaders registered in an MBean Server. They provide the necessary methods to load classes using the registered ClassLoaders.

The first ClassLoader in a ClassLoaderRepository is always the MBean Server's own ClassLoader.

When an MBean is registered in an MBean Server, if it is of a subclass of ClassLoader sample code for java.lang.ClassLoader definition code for java.lang.ClassLoader and if it does not implement the interface PrivateClassLoader sample code for javax.management.loading.PrivateClassLoader definition code for javax.management.loading.PrivateClassLoader , it is added to the end of the MBean Server's ClassLoaderRepository. If it is subsequently unregistered from the MBean Server, it is removed from the ClassLoaderRepository.

The order of MBeans in the ClassLoaderRepository is significant. For any two MBeans X and Y in the ClassLoaderRepository, X must appear before Y if the registration of X was completed before the registration of Y started. If X and Y were registered concurrently, their order is indeterminate. The registration of an MBean corresponds to the call to MBeanServer.registerMBean(java.lang.Object, javax.management.ObjectName) sample code for javax.management.MBeanServer.registerMBean(java.lang.Object, javax.management.ObjectName) definition code for javax.management.MBeanServer.registerMBean(java.lang.Object, javax.management.ObjectName) or one of the MBeanServer sample code for javax.management.MBeanServer definition code for javax.management.MBeanServer .createMBean methods.

Since:
1.5
See Also:
MBeanServerFactory sample code for javax.management.MBeanServerFactory definition code for javax.management.MBeanServerFactory

Method Summary
 Class sample code for java.lang.Class definition code for java.lang.Class loadClass sample code for javax.management.loading.ClassLoaderRepository.loadClass(java.lang.String) definition code for javax.management.loading.ClassLoaderRepository.loadClass(java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  className)
          Load the given class name through the list of class loaders.
 Class sample code for java.lang.Class definition code for java.lang.Class loadClassBefore sample code for javax.management.loading.ClassLoaderRepository.loadClassBefore(java.lang.ClassLoader, java.lang.String) definition code for javax.management.loading.ClassLoaderRepository.loadClassBefore(java.lang.ClassLoader, java.lang.String) (ClassLoader sample code for java.lang.ClassLoader definition code for java.lang.ClassLoader  stop, String sample code for java.lang.String definition code for java.lang.String  className)
          Load the given class name through the list of class loaders, stopping at the given one.
 Class sample code for java.lang.Class definition code for java.lang.Class loadClassWithout sample code for javax.management.loading.ClassLoaderRepository.loadClassWithout(java.lang.ClassLoader, java.lang.String) definition code for javax.management.loading.ClassLoaderRepository.loadClassWithout(java.lang.ClassLoader, java.lang.String) (ClassLoader sample code for java.lang.ClassLoader definition code for java.lang.ClassLoader  exclude, String sample code for java.lang.String definition code for java.lang.String  className)
          Load the given class name through the list of class loaders, excluding the given one.
 

Method Detail

loadClass sample code for javax.management.loading.ClassLoaderRepository.loadClass(java.lang.String) definition code for javax.management.loading.ClassLoaderRepository.loadClass(java.lang.String)

Class sample code for java.lang.Class definition code for java.lang.Class  loadClass(String sample code for java.lang.String definition code for java.lang.String  className)
                throws ClassNotFoundException sample code for java.lang.ClassNotFoundException definition code for java.lang.ClassNotFoundException 

Load the given class name through the list of class loaders. Each ClassLoader in turn from the ClassLoaderRepository is asked to load the class via its ClassLoader.loadClass(String) sample code for java.lang.ClassLoader.loadClass(java.lang.String) definition code for java.lang.ClassLoader.loadClass(java.lang.String) method. If it successfully returns a Class sample code for java.lang.Class definition code for java.lang.Class object, that is the result of this method. If it throws a ClassNotFoundException sample code for java.lang.ClassNotFoundException definition code for java.lang.ClassNotFoundException , the search continues with the next ClassLoader. If it throws another exception, the exception is propagated from this method. If the end of the list is reached, a ClassNotFoundException sample code for java.lang.ClassNotFoundException definition code for java.lang.ClassNotFoundException is thrown.

Parameters:
className - The name of the class to be loaded.
Returns:
the loaded class.
Throws:
ClassNotFoundException sample code for java.lang.ClassNotFoundException definition code for java.lang.ClassNotFoundException - The specified class could not be found.

loadClassWithout sample code for javax.management.loading.ClassLoaderRepository.loadClassWithout(java.lang.ClassLoader, java.lang.String) definition code for javax.management.loading.ClassLoaderRepository.loadClassWithout(java.lang.ClassLoader, java.lang.String)

Class sample code for java.lang.Class definition code for java.lang.Class  loadClassWithout(ClassLoader sample code for java.lang.ClassLoader definition code for java.lang.ClassLoader  exclude,
                       String sample code for java.lang.String definition code for java.lang.String  className)
                       throws ClassNotFoundException sample code for java.lang.ClassNotFoundException definition code for java.lang.ClassNotFoundException 

Load the given class name through the list of class loaders, excluding the given one. Each ClassLoader in turn from the ClassLoaderRepository, except exclude, is asked to load the class via its ClassLoader.loadClass(String) sample code for java.lang.ClassLoader.loadClass(java.lang.String) definition code for java.lang.ClassLoader.loadClass(java.lang.String) method. If it successfully returns a Class sample code for java.lang.Class definition code for java.lang.Class object, that is the result of this method. If it throws a ClassNotFoundException sample code for java.lang.ClassNotFoundException definition code for java.lang.ClassNotFoundException , the search continues with the next ClassLoader. If it throws another exception, the exception is propagated from this method. If the end of the list is reached, a ClassNotFoundException sample code for java.lang.ClassNotFoundException definition code for java.lang.ClassNotFoundException is thrown.

Be aware that if a ClassLoader in the ClassLoaderRepository calls this method from its loadClass sample code for java.lang.ClassLoader.loadClass(java.lang.String) definition code for java.lang.ClassLoader.loadClass(java.lang.String) method, it exposes itself to a deadlock if another ClassLoader in the ClassLoaderRepository does the same thing at the same time. The loadClassBefore(java.lang.ClassLoader, java.lang.String) sample code for javax.management.loading.ClassLoaderRepository.loadClassBefore(java.lang.ClassLoader, java.lang.String) definition code for javax.management.loading.ClassLoaderRepository.loadClassBefore(java.lang.ClassLoader, java.lang.String) method is recommended to avoid the risk of deadlock.

Parameters:
className - The name of the class to be loaded.
exclude - The class loader to be excluded. May be null, in which case this method is equivalent to loadClass(className) sample code for javax.management.loading.ClassLoaderRepository.loadClass(java.lang.String) definition code for javax.management.loading.ClassLoaderRepository.loadClass(java.lang.String) .
Returns:
the loaded class.
Throws:
ClassNotFoundException sample code for java.lang.ClassNotFoundException definition code for java.lang.ClassNotFoundException - The specified class could not be found.

loadClassBefore sample code for javax.management.loading.ClassLoaderRepository.loadClassBefore(java.lang.ClassLoader, java.lang.String) definition code for javax.management.loading.ClassLoaderRepository.loadClassBefore(java.lang.ClassLoader, java.lang.String)

Class sample code for java.lang.Class definition code for java.lang.Class  loadClassBefore(ClassLoader sample code for java.lang.ClassLoader definition code for java.lang.ClassLoader  stop,
                      String sample code for java.lang.String definition code for java.lang.String  className)
                      throws ClassNotFoundException sample code for java.lang.ClassNotFoundException definition code for java.lang.ClassNotFoundException 

Load the given class name through the list of class loaders, stopping at the given one. Each ClassLoader in turn from the ClassLoaderRepository is asked to load the class via its ClassLoader.loadClass(String) sample code for java.lang.ClassLoader.loadClass(java.lang.String) definition code for java.lang.ClassLoader.loadClass(java.lang.String) method. If it successfully returns a Class sample code for java.lang.Class definition code for java.lang.Class object, that is the result of this method. If it throws a ClassNotFoundException sample code for java.lang.ClassNotFoundException definition code for java.lang.ClassNotFoundException , the search continues with the next ClassLoader. If it throws another exception, the exception is propagated from this method. If the search reaches stop or the end of the list, a ClassNotFoundException sample code for java.lang.ClassNotFoundException definition code for java.lang.ClassNotFoundException is thrown.

Typically this method is called from the loadClass sample code for java.lang.ClassLoader.loadClass(java.lang.String) definition code for java.lang.ClassLoader.loadClass(java.lang.String) method of stop, to consult loaders that appear before it in the ClassLoaderRepository. By stopping the search as soon as stop is reached, a potential deadlock with concurrent class loading is avoided.

Parameters:
className - The name of the class to be loaded.
stop - The class loader at which to stop. May be null, in which case this method is equivalent to loadClass(className) sample code for javax.management.loading.ClassLoaderRepository.loadClass(java.lang.String) definition code for javax.management.loading.ClassLoaderRepository.loadClass(java.lang.String) .
Returns:
the loaded class.
Throws:
ClassNotFoundException sample code for java.lang.ClassNotFoundException definition code for java.lang.ClassNotFoundException - The specified class could not be found.