GNU Classpath (0.95) | |
Frames | No Frames |
1: /* ClassLoaderRepository.java -- Represents a collection of class loadersx. 2: Copyright (C) 2006 Free Software Foundation, Inc. 3: 4: This file is part of GNU Classpath. 5: 6: GNU Classpath is free software; you can redistribute it and/or modify 7: it under the terms of the GNU General Public License as published by 8: the Free Software Foundation; either version 2, or (at your option) 9: any later version. 10: 11: GNU Classpath is distributed in the hope that it will be useful, but 12: WITHOUT ANY WARRANTY; without even the implied warranty of 13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14: General Public License for more details. 15: 16: You should have received a copy of the GNU General Public License 17: along with GNU Classpath; see the file COPYING. If not, write to the 18: Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 19: 02110-1301 USA. 20: 21: Linking this library statically or dynamically with other modules is 22: making a combined work based on this library. Thus, the terms and 23: conditions of the GNU General Public License cover the whole 24: combination. 25: 26: As a special exception, the copyright holders of this library give you 27: permission to link this library with independent modules to produce an 28: executable, regardless of the license terms of these independent 29: modules, and to copy and distribute the resulting executable under 30: terms of your choice, provided that you also meet, for each linked 31: independent module, the terms and conditions of the license of that 32: module. An independent module is a module which is not derived from 33: or based on this library. If you modify this library, you may extend 34: this exception to your version of the library, but you are not 35: obligated to do so. If you do not wish to do so, delete this 36: exception statement from your version. */ 37: 38: package javax.management.loading; 39: 40: /** 41: * Implementations of this interface maintain a list of 42: * {@link ClassLoader}s for use by the management servers, 43: * allowing classes to be loaded by the first {@link ClassLoader} 44: * that will do so. A class loader is added to the list 45: * whenever a {@link ClassLoader} instance is registered with 46: * the management server, and it does not implement the 47: * {@link PrivateClassLoader} interface. They are removed when 48: * unregistered. The first class loader in the list is always 49: * the one which was used to load the management server itself. 50: * 51: * @author Andrew John Hughes (gnu_andrew@member.fsf.org) 52: * @since 1.5 53: * @see MBeanServerFactory 54: */ 55: public interface ClassLoaderRepository 56: { 57: 58: /** 59: * Attempts to load the given class using class loaders 60: * supplied by the list. The {@link ClassLoader#loadClass(String)} 61: * method of each class loader is called. If the method 62: * returns successfully, then the returned {@link Class} instance 63: * is returned. If a {@link ClassNotFoundException} is thrown, 64: * then the next loader is tried. Any other exception thrown 65: * by the method is passed back to the caller. This method 66: * throws a {@link ClassNotFoundException} itself if all the 67: * class loaders listed prove fruitless. 68: * 69: * @param name the name of the class to load. 70: * @return the loaded class. 71: * @throws ClassNotFoundException if all the class loaders fail 72: * to load the class. 73: */ 74: Class<?> loadClass(String name) 75: throws ClassNotFoundException; 76: 77: /** 78: * <p> 79: * Attempts to load the given class using class loaders 80: * supplied by the list, stopping when the specified 81: * loader is reached. The {@link ClassLoader#loadClass(String)} 82: * method of each class loader is called. If the method 83: * returns successfully, then the returned {@link Class} instance 84: * is returned. If a {@link ClassNotFoundException} is thrown, 85: * then the next loader is tried. Any other exception thrown 86: * by the method is passed back to the caller. This method 87: * throws a {@link ClassNotFoundException} itself if all the 88: * class loaders listed prove fruitless. 89: * </p> 90: * <p> 91: * This method is usually used by the class loader specified 92: * by the <code>stop</code> argument to load classes using the 93: * loaders that appear before it in the list. By stopping when 94: * the loader is reached, the deadlock that occurs when the loader 95: * is merely skipped is avoided. 96: * </p> 97: * 98: * @param stop the class loader at which to stop, or <code>null</code> 99: * to obtain the same behaviour as {@link #loadClass(String)}. 100: * @param name the name of the class to load. 101: * @return the loaded class. 102: * @throws ClassNotFoundException if all the class loaders fail 103: * to load the class. 104: */ 105: Class<?> loadClassBefore(ClassLoader stop, String name) 106: throws ClassNotFoundException; 107: 108: /** 109: * <p> 110: * Attempts to load the given class using class loaders 111: * supplied by the list, excluding the one specified. 112: * The {@link ClassLoader#loadClass(String)} 113: * method of each class loader is called. If the method 114: * returns successfully, then the returned {@link Class} instance 115: * is returned. If a {@link ClassNotFoundException} is thrown, 116: * then the next loader is tried. Any other exception thrown 117: * by the method is passed back to the caller. This method 118: * throws a {@link ClassNotFoundException} itself if all the 119: * class loaders listed prove fruitless. 120: * </p> 121: * <p> 122: * Note that this method may deadlock if called simultaneously 123: * by two class loaders in the list. 124: * {@link loadClassBefore(ClassLoader, String)} should be used 125: * in preference to this method to avoid this. 126: * </p> 127: * 128: * @param exclude the class loader to exclude, or <code>null</code> 129: * to obtain the same behaviour as {@link #loadClass(String)}. 130: * @param name the name of the class to load. 131: * @return the loaded class. 132: * @throws ClassNotFoundException if all the class loaders fail 133: * to load the class. 134: */ 135: Class<?> loadClassWithout(ClassLoader exclude, String name) 136: throws ClassNotFoundException; 137: 138: }
GNU Classpath (0.95) |