-
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
and if it does not implement the interfacePrivateClassLoader
, it is added to the end of the MBean Server'sClassLoaderRepository
. If it is subsequently unregistered from the MBean Server, it is removed from theClassLoaderRepository
.The order of MBeans in the
ClassLoaderRepository
is significant. For any two MBeans X and Y in theClassLoaderRepository
, 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 toMBeanServer.registerMBean(java.lang.Object, javax.management.ObjectName)
or one of theMBeanServer
.createMBean
methods.- Since:
- 1.5
- See Also:
MBeanServerFactory
-
-
Method Summary
Methods Modifier and Type Method and Description Class<?>
loadClass(String className)
Load the given class name through the list of class loaders.Class<?>
loadClassBefore(ClassLoader stop, String className)
Load the given class name through the list of class loaders, stopping at the given one.Class<?>
loadClassWithout(ClassLoader exclude, String className)
Load the given class name through the list of class loaders, excluding the given one.
-
-
-
Method Detail
-
loadClass
Class<?> loadClass(String className) throws 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)
method. If it successfully returns aClass
object, that is the result of this method. If it throws aClassNotFoundException
, 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, aClassNotFoundException
is thrown.- Parameters:
className
- The name of the class to be loaded.- Returns:
- the loaded class.
- Throws:
ClassNotFoundException
- The specified class could not be found.
-
loadClassWithout
Class<?> loadClassWithout(ClassLoader exclude, String className) throws 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 itsClassLoader.loadClass(String)
method. If it successfully returns aClass
object, that is the result of this method. If it throws aClassNotFoundException
, 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, aClassNotFoundException
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. TheloadClassBefore(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 toloadClass(className)
.- Returns:
- the loaded class.
- Throws:
ClassNotFoundException
- The specified class could not be found.
-
loadClassBefore
Class<?> loadClassBefore(ClassLoader stop, String className) throws 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)
method. If it successfully returns aClass
object, that is the result of this method. If it throws aClassNotFoundException
, the search continues with the next ClassLoader. If it throws another exception, the exception is propagated from this method. If the search reachesstop
or the end of the list, aClassNotFoundException
is thrown.Typically this method is called from the
loadClass
method ofstop
, to consult loaders that appear before it in theClassLoaderRepository
. By stopping the search as soon asstop
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 toloadClass(className)
.- Returns:
- the loaded class.
- Throws:
ClassNotFoundException
- The specified class could not be found.
-
-
Deutsche Übersetzung
Sie haben gebeten, diese Seite auf Deutsch zu besuchen. Momentan ist nur die Oberfläche übersetzt, aber noch nicht der gesamte Inhalt.Wenn Sie mir bei Übersetzungen helfen wollen, ist Ihr Beitrag willkommen. Alles, was Sie tun müssen, ist, sich auf der Website zu registrieren und mir eine Nachricht zu schicken, in der Sie gebeten werden, Sie der Gruppe der Übersetzer hinzuzufügen, die Ihnen die Möglichkeit gibt, die gewünschten Seiten zu übersetzen. Ein Link am Ende jeder übersetzten Seite zeigt an, dass Sie der Übersetzer sind und einen Link zu Ihrem Profil haben.
Vielen Dank im Voraus.
Dokument erstellt 11/06/2005, zuletzt geändert 04/03/2020
Quelle des gedruckten Dokuments:https://www.gaudry.be/de/java-api-rf-javax/management/loading/classloaderrepository.html
Die Infobro ist eine persönliche Seite, deren Inhalt in meiner alleinigen Verantwortung liegt. Der Text ist unter der CreativeCommons-Lizenz (BY-NC-SA) verfügbar. Weitere Informationen auf die Nutzungsbedingungen und dem Autor.
Referenzen
Diese Verweise und Links verweisen auf Dokumente, die während des Schreibens dieser Seite konsultiert wurden, oder die zusätzliche Informationen liefern können, aber die Autoren dieser Quellen können nicht für den Inhalt dieser Seite verantwortlich gemacht werden.
Der Autor Diese Website ist allein dafür verantwortlich, wie die verschiedenen Konzepte und Freiheiten, die mit den Nachschlagewerken gemacht werden, hier dargestellt werden. Denken Sie daran, dass Sie mehrere Quellinformationen austauschen müssen, um das Risiko von Fehlern zu reduzieren.