0N/A/*
2362N/A * Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage javax.management.loading;
0N/A
0N/Aimport javax.management.MBeanServer; // for Javadoc
0N/A
0N/A/**
0N/A * <p>Instances of this interface are used to keep the list of ClassLoaders
0N/A * registered in an MBean Server.
0N/A * They provide the necessary methods to load classes using the registered
0N/A * ClassLoaders.</p>
0N/A *
0N/A * <p>The first ClassLoader in a <code>ClassLoaderRepository</code> is
0N/A * always the MBean Server's own ClassLoader.</p>
0N/A *
0N/A * <p>When an MBean is registered in an MBean Server, if it is of a
0N/A * subclass of {@link java.lang.ClassLoader} and if it does not
0N/A * implement the interface {@link PrivateClassLoader}, it is added to
0N/A * the end of the MBean Server's <code>ClassLoaderRepository</code>.
0N/A * If it is subsequently unregistered from the MBean Server, it is
0N/A * removed from the <code>ClassLoaderRepository</code>.</p>
0N/A *
0N/A * <p>The order of MBeans in the <code>ClassLoaderRepository</code> is
0N/A * significant. For any two MBeans <em>X</em> and <em>Y</em> in the
0N/A * <code>ClassLoaderRepository</code>, <em>X</em> must appear before
0N/A * <em>Y</em> if the registration of <em>X</em> was completed before
0N/A * the registration of <em>Y</em> started. If <em>X</em> and
0N/A * <em>Y</em> were registered concurrently, their order is
0N/A * indeterminate. The registration of an MBean corresponds to the
0N/A * call to {@link MBeanServer#registerMBean} or one of the {@link
0N/A * MBeanServer}<code>.createMBean</code> methods.</p>
0N/A *
0N/A * @see javax.management.MBeanServerFactory
0N/A *
0N/A * @since 1.5
0N/A */
0N/Apublic interface ClassLoaderRepository {
0N/A
0N/A /**
0N/A * <p>Load the given class name through the list of class loaders.
0N/A * Each ClassLoader in turn from the ClassLoaderRepository is
0N/A * asked to load the class via its {@link
0N/A * ClassLoader#loadClass(String)} method. If it successfully
0N/A * returns a {@link Class} object, that is the result of this
0N/A * method. If it throws a {@link ClassNotFoundException}, the
0N/A * search continues with the next ClassLoader. If it throws
0N/A * another exception, the exception is propagated from this
0N/A * method. If the end of the list is reached, a {@link
0N/A * ClassNotFoundException} is thrown.</p>
0N/A *
0N/A * @param className The name of the class to be loaded.
0N/A *
0N/A * @return the loaded class.
0N/A *
0N/A * @exception ClassNotFoundException The specified class could not be
0N/A * found.
0N/A */
0N/A public Class<?> loadClass(String className)
0N/A throws ClassNotFoundException;
0N/A
0N/A /**
0N/A * <p>Load the given class name through the list of class loaders,
0N/A * excluding the given one. Each ClassLoader in turn from the
0N/A * ClassLoaderRepository, except <code>exclude</code>, is asked to
0N/A * load the class via its {@link ClassLoader#loadClass(String)}
0N/A * method. If it successfully returns a {@link Class} object,
0N/A * that is the result of this method. If it throws a {@link
0N/A * ClassNotFoundException}, the search continues with the next
0N/A * ClassLoader. If it throws another exception, the exception is
0N/A * propagated from this method. If the end of the list is
0N/A * reached, a {@link ClassNotFoundException} is thrown.</p>
0N/A *
0N/A * <p>Be aware that if a ClassLoader in the ClassLoaderRepository
0N/A * calls this method from its {@link ClassLoader#loadClass(String)
0N/A * loadClass} method, it exposes itself to a deadlock if another
0N/A * ClassLoader in the ClassLoaderRepository does the same thing at
0N/A * the same time. The {@link #loadClassBefore} method is
0N/A * recommended to avoid the risk of deadlock.</p>
0N/A *
0N/A * @param className The name of the class to be loaded.
0N/A * @param exclude The class loader to be excluded. May be null,
0N/A * in which case this method is equivalent to {@link #loadClass
0N/A * loadClass(className)}.
0N/A *
0N/A * @return the loaded class.
0N/A *
0N/A * @exception ClassNotFoundException The specified class could not
0N/A * be found.
0N/A */
0N/A public Class<?> loadClassWithout(ClassLoader exclude,
0N/A String className)
0N/A throws ClassNotFoundException;
0N/A
0N/A /**
0N/A * <p>Load the given class name through the list of class loaders,
0N/A * stopping at the given one. Each ClassLoader in turn from the
0N/A * ClassLoaderRepository is asked to load the class via its {@link
0N/A * ClassLoader#loadClass(String)} method. If it successfully
0N/A * returns a {@link Class} object, that is the result of this
0N/A * method. If it throws a {@link ClassNotFoundException}, the
0N/A * search continues with the next ClassLoader. If it throws
0N/A * another exception, the exception is propagated from this
0N/A * method. If the search reaches <code>stop</code> or the end of
0N/A * the list, a {@link ClassNotFoundException} is thrown.</p>
0N/A *
0N/A * <p>Typically this method is called from the {@link
0N/A * ClassLoader#loadClass(String) loadClass} method of
0N/A * <code>stop</code>, to consult loaders that appear before it
0N/A * in the <code>ClassLoaderRepository</code>. By stopping the
0N/A * search as soon as <code>stop</code> is reached, a potential
0N/A * deadlock with concurrent class loading is avoided.</p>
0N/A *
0N/A * @param className The name of the class to be loaded.
0N/A * @param stop The class loader at which to stop. May be null, in
0N/A * which case this method is equivalent to {@link #loadClass(String)
0N/A * loadClass(className)}.
0N/A *
0N/A * @return the loaded class.
0N/A *
0N/A * @exception ClassNotFoundException The specified class could not
0N/A * be found.
0N/A *
0N/A */
0N/A public Class<?> loadClassBefore(ClassLoader stop,
0N/A String className)
0N/A throws ClassNotFoundException;
0N/A
0N/A}