APIdia Launch Partner
Top Description Inners Fields Constructors Methods
com.sun.jmx.mbeanserver

pack-priv final Class ClassLoaderRepositorySupport

extends Object
implements ModifiableClassLoaderRepository
Class Inheritance
All Implemented Interfaces
com.sun.jmx.mbeanserver.ModifiableClassLoaderRepository, javax.management.loading.ClassLoaderRepository
Static Imports
com.sun.jmx.defaults.JmxProperties.MBEANSERVER_LOGGER

This class keeps the list of Class Loaders registered in the MBean Server. It provides the necessary methods to load classes using the registered Class Loaders.
Since
1.5

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private static final ClassLoaderRepositorySupport.LoaderEntry[]
private ClassLoaderRepositorySupport.LoaderEntry[]
loaders

List of class loaders Only read-only actions should be performed on this object.

private final Map<ObjectName, ClassLoader>
loadersWithNames

List of named class loaders.

private final Map<String, List<ClassLoader>>
search

List of valid search

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
private synchronized boolean
add(ObjectName name, ClassLoader cl)

Same behavior as add(Object o) in java.util.List.

public final void
addClassLoader(ClassLoader loader)

Implements com.sun.jmx.mbeanserver.ModifiableClassLoaderRepository.addClassLoader.

Add an anonymous ClassLoader to the repository.

public final synchronized void
addClassLoader(ObjectName name, ClassLoader loader)

Implements com.sun.jmx.mbeanserver.ModifiableClassLoaderRepository.addClassLoader.

Add a named ClassLoader to the repository.

public final ClassLoader
getClassLoader(ObjectName name)

Implements com.sun.jmx.mbeanserver.ModifiableClassLoaderRepository.getClassLoader.

Get a named ClassLoader from the repository.

public final Class<?>
loadClass(String className)

Implements javax.management.loading.ClassLoaderRepository.loadClass.

Load the given class name through the list of class loaders.

private Class<?>
loadClass(final ClassLoaderRepositorySupport.LoaderEntry[] list, final String className, final ClassLoader without, final ClassLoader stop)

public final Class<?>
loadClassBefore(ClassLoader stop, String className)

Implements javax.management.loading.ClassLoaderRepository.loadClassBefore.

Load the given class name through the list of class loaders, stopping at the given one.

public final Class<?>
loadClassWithout(ClassLoader without, String className)

Implements javax.management.loading.ClassLoaderRepository.loadClassWithout.

Load the given class name through the list of class loaders, excluding the given one.

private synchronized boolean
remove(ObjectName name, ClassLoader cl)

Same behavior as remove(Object o) in java.util.List.

public final void
removeClassLoader(ClassLoader loader)

Implements com.sun.jmx.mbeanserver.ModifiableClassLoaderRepository.removeClassLoader.

Remove the specified ClassLoader to the repository.

public final synchronized void
removeClassLoader(ObjectName name)

Implements com.sun.jmx.mbeanserver.ModifiableClassLoaderRepository.removeClassLoader.

Remove a named ClassLoader from the repository.

private synchronized void
startValidSearch(ClassLoader aloader, String className)

private synchronized void
stopValidSearch(ClassLoader aloader, String className)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

EMPTY_LOADER_ARRAYback to summary
private static final ClassLoaderRepositorySupport.LoaderEntry[] EMPTY_LOADER_ARRAY
loadersback to summary
private ClassLoaderRepositorySupport.LoaderEntry[] loaders

List of class loaders Only read-only actions should be performed on this object. We do O(n) operations on this array, e.g. when removing a ClassLoader. The assumption is that the number of elements is small, probably less than ten, and that the vast majority of operations are searches (loadClass) which are by definition linear.

loadersWithNamesback to summary
private final Map<ObjectName, ClassLoader> loadersWithNames

List of named class loaders.

Constructor Detail

ClassLoaderRepositorySupportback to summary
pack-priv ClassLoaderRepositorySupport()

Method Detail

addback to summary
private synchronized boolean add(ObjectName name, ClassLoader cl)

Same behavior as add(Object o) in java.util.List. Replace the loader list with a new one in which the new loader has been added.

addClassLoaderback to summary
public final void addClassLoader(ClassLoader loader)

Implements com.sun.jmx.mbeanserver.ModifiableClassLoaderRepository.addClassLoader.

Doc from com.sun.jmx.mbeanserver.ModifiableClassLoaderRepository.addClassLoader.

Add an anonymous ClassLoader to the repository.

addClassLoaderback to summary
public final synchronized void addClassLoader(ObjectName name, ClassLoader loader)

Implements com.sun.jmx.mbeanserver.ModifiableClassLoaderRepository.addClassLoader.

Doc from com.sun.jmx.mbeanserver.ModifiableClassLoaderRepository.addClassLoader.

Add a named ClassLoader to the repository.

getClassLoaderback to summary
public final ClassLoader getClassLoader(ObjectName name)

Implements com.sun.jmx.mbeanserver.ModifiableClassLoaderRepository.getClassLoader.

Doc from com.sun.jmx.mbeanserver.ModifiableClassLoaderRepository.getClassLoader.

Get a named ClassLoader from the repository.

loadClassback to summary
public final Class<?> loadClass(String className) throws ClassNotFoundException

Implements javax.management.loading.ClassLoaderRepository.loadClass.

Doc from javax.management.loading.ClassLoaderRepository.loadClass.

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) method. If it successfully returns a Class object, that is the result of this method. If it throws a 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 is thrown.

Exceptions
ClassNotFoundException:
The specified class could not be found.
loadClassback to summary
private Class<?> loadClass(final ClassLoaderRepositorySupport.LoaderEntry[] list, final String className, final ClassLoader without, final ClassLoader stop) throws ClassNotFoundException
loadClassBeforeback to summary
public final Class<?> loadClassBefore(ClassLoader stop, String className) throws ClassNotFoundException

Implements javax.management.loading.ClassLoaderRepository.loadClassBefore.

Doc from javax.management.loading.ClassLoaderRepository.loadClassBefore.

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) method. If it successfully returns a Class object, that is the result of this method. If it throws a 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 is thrown.

Typically this method is called from the loadClass 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.

Exceptions
ClassNotFoundException:
The specified class could not be found.
loadClassWithoutback to summary
public final Class<?> loadClassWithout(ClassLoader without, String className) throws ClassNotFoundException

Implements javax.management.loading.ClassLoaderRepository.loadClassWithout.

Doc from javax.management.loading.ClassLoaderRepository.loadClassWithout.

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) method. If it successfully returns a Class object, that is the result of this method. If it throws a 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 is thrown.

Be aware that if a ClassLoader in the ClassLoaderRepository calls this method from its loadClass method, it exposes itself to a deadlock if another ClassLoader in the ClassLoaderRepository does the same thing at the same time. The loadClassBefore method is recommended to avoid the risk of deadlock.

Exceptions
ClassNotFoundException:
The specified class could not be found.
removeback to summary
private synchronized boolean remove(ObjectName name, ClassLoader cl)

Same behavior as remove(Object o) in java.util.List. Replace the loader list with a new one in which the old loader has been removed. The ObjectName may be null, in which case the entry to be removed must also have a null ObjectName and the ClassLoader values must match. If the ObjectName is not null, then the first entry with a matching ObjectName is removed, regardless of whether ClassLoader values match. (In fact, the ClassLoader parameter will usually be null in this case.)

removeClassLoaderback to summary
public final void removeClassLoader(ClassLoader loader)

Implements com.sun.jmx.mbeanserver.ModifiableClassLoaderRepository.removeClassLoader.

Doc from com.sun.jmx.mbeanserver.ModifiableClassLoaderRepository.removeClassLoader.

Remove the specified ClassLoader to the repository. The class loader may or may not be anonymous.

removeClassLoaderback to summary
public final synchronized void removeClassLoader(ObjectName name)

Implements com.sun.jmx.mbeanserver.ModifiableClassLoaderRepository.removeClassLoader.

Doc from com.sun.jmx.mbeanserver.ModifiableClassLoaderRepository.removeClassLoader.

Remove a named ClassLoader from the repository.

startValidSearchback to summary
private synchronized void startValidSearch(ClassLoader aloader, String className) throws ClassNotFoundException
stopValidSearchback to summary
private synchronized void stopValidSearch(ClassLoader aloader, String className)
com.sun.jmx.mbeanserver back to summary

private Class ClassLoaderRepositorySupport.LoaderEntry

extends Object
Class Inheritance
  • java.lang.Object
  • com.sun.jmx.mbeanserver.ClassLoaderRepositorySupport.LoaderEntry

Field Summary

Modifier and TypeField and Description
pack-priv ClassLoader
pack-priv ObjectName

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

loaderback to summary
pack-priv ClassLoader loader
nameback to summary
pack-priv ObjectName name

Constructor Detail

LoaderEntryback to summary
pack-priv LoaderEntry(ObjectName name, ClassLoader loader)