Showing the changes to java/pkg/java/rmi/server/RMIClassLoaderSpi.java (1 of 18352 files). Show all
Unified · Split
| @@ -0,0 +1,192 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved. | ||
| 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
| 4 | * | ||
| 5 | * This code is free software; you can redistribute it and/or modify it | ||
| 6 | * under the terms of the GNU General Public License version 2 only, as | ||
| 7 | * published by the Free Software Foundation. Oracle designates this | ||
| 8 | * particular file as subject to the "Classpath" exception as provided | ||
| 9 | * by Oracle in the LICENSE file that accompanied this code. | ||
| 10 | * | ||
| 11 | * This code is distributed in the hope that it will be useful, but WITHOUT | ||
| 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
| 14 | * version 2 for more details (a copy is included in the LICENSE file that | ||
| 15 | * accompanied this code). | ||
| 16 | * | ||
| 17 | * You should have received a copy of the GNU General Public License version | ||
| 18 | * 2 along with this work; if not, write to the Free Software Foundation, | ||
| 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
| 20 | * | ||
| 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
| 22 | * or visit www.oracle.com if you need additional information or have any | ||
| 23 | * questions. | ||
| 24 | */ | ||
| 25 | |||
| 26 | package java.rmi.server; | ||
| 27 | |||
| 28 | import java.net.MalformedURLException; | ||
| 29 | import java.net.URL; | ||
| 30 | |||
| 31 | /** | ||
| 32 | * <code>RMIClassLoaderSpi</code> is the service provider interface for | ||
| 33 | * <code>RMIClassLoader</code>. | ||
| 34 | * | ||
| 35 | * In particular, an <code>RMIClassLoaderSpi</code> instance provides an | ||
| 36 | * implementation of the following static methods of | ||
| 37 | * <code>RMIClassLoader</code>: | ||
| 38 | * | ||
| 39 | * <ul> | ||
| 40 | * | ||
| 41 | * <li>{@link RMIClassLoader#loadClass(URL,String)} | ||
| 42 | * <li>{@link RMIClassLoader#loadClass(String,String)} | ||
| 43 | * <li>{@link RMIClassLoader#loadClass(String,String,ClassLoader)} | ||
| 44 | * <li>{@link RMIClassLoader#loadProxyClass(String,String[],ClassLoader)} | ||
| 45 | * <li>{@link RMIClassLoader#getClassLoader(String)} | ||
| 46 | * <li>{@link RMIClassLoader#getClassAnnotation(Class)} | ||
| 47 | * | ||
| 48 | * </ul> | ||
| 49 | * | ||
| 50 | * When one of those methods is invoked, its behavior is to delegate | ||
| 51 | * to a corresponding method on an instance of this class. | ||
| 52 | * The details of how each method delegates to the provider instance is | ||
| 53 | * described in the documentation for each particular method. | ||
| 54 | * See the documentation for {@link RMIClassLoader} for a description | ||
| 55 | * of how a provider instance is chosen. | ||
| 56 | * | ||
| 57 | * @author Peter Jones | ||
| 58 | * @author Laird Dornin | ||
| 59 | * @see RMIClassLoader | ||
| 60 | * @since 1.4 | ||
| 61 | */ | ||
| 62 | public abstract class RMIClassLoaderSpi { | ||
| 63 | |||
| 64 | /** | ||
| 65 | * Provides the implementation for | ||
| 66 | * {@link RMIClassLoader#loadClass(URL,String)}, | ||
| 67 | * {@link RMIClassLoader#loadClass(String,String)}, and | ||
| 68 | * {@link RMIClassLoader#loadClass(String,String,ClassLoader)}. | ||
| 69 | * | ||
| 70 | * Loads a class from a codebase URL path, optionally using the | ||
| 71 | * supplied loader. | ||
| 72 | * | ||
| 73 | * Typically, a provider implementation will attempt to | ||
| 74 | * resolve the named class using the given <code>defaultLoader</code>, | ||
| 75 | * if specified, before attempting to resolve the class from the | ||
| 76 | * codebase URL path. | ||
| 77 | * | ||
| 78 | * <p>An implementation of this method must either return a class | ||
| 79 | * with the given name or throw an exception. | ||
| 80 | * | ||
| 81 | * @param codebase the list of URLs (separated by spaces) to load | ||
| 82 | * the class from, or <code>null</code> | ||
| 83 | * | ||
| 84 | * @param name the name of the class to load | ||
| 85 | * | ||
| 86 | * @param defaultLoader additional contextual class loader | ||
| 87 | * to use, or <code>null</code> | ||
| 88 | * | ||
| 89 | * @return the <code>Class</code> object representing the loaded class | ||
| 90 | * | ||
| 91 | * @throws MalformedURLException if <code>codebase</code> is | ||
| 92 | * non-<code>null</code> and contains an invalid URL, or | ||
| 93 | * if <code>codebase</code> is <code>null</code> and a provider-specific | ||
| 94 | * URL used to load classes is invalid | ||
| 95 | * | ||
| 96 | * @throws ClassNotFoundException if a definition for the class | ||
| 97 | * could not be found at the specified location | ||
| 98 | */ | ||
| 99 | public abstract Class<?> loadClass(String codebase, String name, | ||
| 100 | ClassLoader defaultLoader) | ||
| 101 | throws MalformedURLException, ClassNotFoundException; | ||
| 102 | |||
| 103 | /** | ||
| 104 | * Provides the implementation for | ||
| 105 | * {@link RMIClassLoader#loadProxyClass(String,String[],ClassLoader)}. | ||
| 106 | * | ||
| 107 | * Loads a dynamic proxy class (see {@link java.lang.reflect.Proxy} | ||
| 108 | * that implements a set of interfaces with the given names | ||
| 109 | * from a codebase URL path, optionally using the supplied loader. | ||
| 110 | * | ||
| 111 | * <p>An implementation of this method must either return a proxy | ||
| 112 | * class that implements the named interfaces or throw an exception. | ||
| 113 | * | ||
| 114 | * @param codebase the list of URLs (space-separated) to load | ||
| 115 | * classes from, or <code>null</code> | ||
| 116 | * | ||
| 117 | * @param interfaces the names of the interfaces for the proxy class | ||
| 118 | * to implement | ||
| 119 | * | ||
| 120 | * @return a dynamic proxy class that implements the named interfaces | ||
| 121 | * | ||
| 122 | * @param defaultLoader additional contextual class loader | ||
| 123 | * to use, or <code>null</code> | ||
| 124 | * | ||
| 125 | * @throws MalformedURLException if <code>codebase</code> is | ||
| 126 | * non-<code>null</code> and contains an invalid URL, or | ||
| 127 | * if <code>codebase</code> is <code>null</code> and a provider-specific | ||
| 128 | * URL used to load classes is invalid | ||
| 129 | * | ||
| 130 | * @throws ClassNotFoundException if a definition for one of | ||
| 131 | * the named interfaces could not be found at the specified location, | ||
| 132 | * or if creation of the dynamic proxy class failed (such as if | ||
| 133 | * {@link java.lang.reflect.Proxy#getProxyClass(ClassLoader,Class[])} | ||
| 134 | * would throw an <code>IllegalArgumentException</code> for the given | ||
| 135 | * interface list) | ||
| 136 | */ | ||
| 137 | public abstract Class<?> loadProxyClass(String codebase, | ||
| 138 | String[] interfaces, | ||
| 139 | ClassLoader defaultLoader) | ||
| 140 | throws MalformedURLException, ClassNotFoundException; | ||
| 141 | |||
| 142 | /** | ||
| 143 | * Provides the implementation for | ||
| 144 | * {@link RMIClassLoader#getClassLoader(String)}. | ||
| 145 | * | ||
| 146 | * Returns a class loader that loads classes from the given codebase | ||
| 147 | * URL path. | ||
| 148 | * | ||
| 149 | * <p>If there is a security manger, its <code>checkPermission</code> | ||
| 150 | * method will be invoked with a | ||
| 151 | * <code>RuntimePermission("getClassLoader")</code> permission; | ||
| 152 | * this could result in a <code>SecurityException</code>. | ||
| 153 | * The implementation of this method may also perform further security | ||
| 154 | * checks to verify that the calling context has permission to connect | ||
| 155 | * to all of the URLs in the codebase URL path. | ||
| 156 | * | ||
| 157 | * @param codebase the list of URLs (space-separated) from which | ||
| 158 | * the returned class loader will load classes from, or <code>null</code> | ||
| 159 | * | ||
| 160 | * @return a class loader that loads classes from the given codebase URL | ||
| 161 | * path | ||
| 162 | * | ||
| 163 | * @throws MalformedURLException if <code>codebase</code> is | ||
| 164 | * non-<code>null</code> and contains an invalid URL, or | ||
| 165 | * if <code>codebase</code> is <code>null</code> and a provider-specific | ||
| 166 | * URL used to identify the class loader is invalid | ||
| 167 | * | ||
| 168 | * @throws SecurityException if there is a security manager and the | ||
| 169 | * invocation of its <code>checkPermission</code> method fails, or | ||
| 170 | * if the caller does not have permission to connect to all of the | ||
| 171 | * URLs in the codebase URL path | ||
| 172 | */ | ||
| 173 | public abstract ClassLoader getClassLoader(String codebase) | ||
| 174 | throws MalformedURLException; // SecurityException | ||
| 175 | |||
| 176 | /** | ||
| 177 | * Provides the implementation for | ||
| 178 | * {@link RMIClassLoader#getClassAnnotation(Class)}. | ||
| 179 | * | ||
| 180 | * Returns the annotation string (representing a location for | ||
| 181 | * the class definition) that RMI will use to annotate the class | ||
| 182 | * descriptor when marshalling objects of the given class. | ||
| 183 | * | ||
| 184 | * @param cl the class to obtain the annotation for | ||
| 185 | * | ||
| 186 | * @return a string to be used to annotate the given class when | ||
| 187 | * it gets marshalled, or <code>null</code> | ||
| 188 | * | ||
| 189 | * @throws NullPointerException if <code>cl</code> is <code>null</code> | ||
| 190 | */ | ||
| 191 | public abstract String getClassAnnotation(Class<?> cl); | ||
| 192 | } | ||