Dead
[official-gcc.git] / gomp-20050608-branch / libjava / classpath / java / rmi / server / RMIClassLoader.java
blobf8997fd7e09596b1443c9d07424ec6ca8652f5eb
1 /* RMIClassLoader.java --
2 Copyright (c) 1996, 1997, 1998, 1999, 2002, 2003, 2004
3 Free Software Foundation, Inc.
5 This file is part of GNU Classpath.
7 GNU Classpath is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
12 GNU Classpath is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU Classpath; see the file COPYING. If not, write to the
19 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 02110-1301 USA.
22 Linking this library statically or dynamically with other modules is
23 making a combined work based on this library. Thus, the terms and
24 conditions of the GNU General Public License cover the whole
25 combination.
27 As a special exception, the copyright holders of this library give you
28 permission to link this library with independent modules to produce an
29 executable, regardless of the license terms of these independent
30 modules, and to copy and distribute the resulting executable under
31 terms of your choice, provided that you also meet, for each linked
32 independent module, the terms and conditions of the license of that
33 module. An independent module is a module which is not derived from
34 or based on this library. If you modify this library, you may extend
35 this exception to your version of the library, but you are not
36 obligated to do so. If you do not wish to do so, delete this
37 exception statement from your version. */
39 package java.rmi.server;
41 import gnu.java.rmi.server.RMIClassLoaderImpl;
43 import java.net.MalformedURLException;
44 import java.net.URL;
46 /**
47 * This class provides a set of public static utility methods for supporting
48 * network-based class loading in RMI. These methods are called by RMI's
49 * internal marshal streams to implement the dynamic class loading of types for
50 * RMI parameters and return values.
52 public class RMIClassLoader
54 /**
55 * This class isn't intended to be instantiated.
57 private RMIClassLoader() {}
59 /**
60 * @deprecated
62 public static Class loadClass(String name)
63 throws MalformedURLException, ClassNotFoundException
65 return loadClass("", name);
68 public static Class loadClass(String codebase, String name)
69 throws MalformedURLException, ClassNotFoundException
71 RMIClassLoaderSpi spi = getProviderInstance();
72 if (spi == null)
73 spi = getDefaultProviderInstance();
74 return spi.loadClass(codebase, name, null);
77 public static Class loadClass(String codebase, String name,
78 ClassLoader defaultLoader)
79 throws MalformedURLException, ClassNotFoundException
81 RMIClassLoaderSpi spi = getProviderInstance();
82 if (spi == null)
83 spi = getDefaultProviderInstance();
84 return spi.loadClass(codebase, name, defaultLoader);
87 /**
88 * Loads a class from <code>codeBase</code>.
90 * This method delegates to
91 * {@link RMIClassLoaderSpi#loadClass(String, String, ClassLoader)} and
92 * passes <code>codeBase.toString()</code> as first argument,
93 * <code>name</code> as second argument and <code>null</code> as third
94 * argument.
96 * @param codeBase the code base from which to load the class
97 * @param name the name of the class
99 * @return the loaded class
101 * @throws MalformedURLException if the URL is not well formed
102 * @throws ClassNotFoundException if the requested class cannot be found
104 public static Class loadClass(URL codeBase, String name)
105 throws MalformedURLException, ClassNotFoundException
107 RMIClassLoaderSpi spi = getProviderInstance();
108 if (spi == null)
109 spi = getDefaultProviderInstance();
110 return spi.loadClass(codeBase.toString(), name, null);
114 * Gets a classloader for the given codebase and with the current
115 * context classloader as parent.
117 * @param codebase
119 * @return a classloader for the given codebase
121 * @throws MalformedURLException if the codebase contains a malformed URL
123 public static ClassLoader getClassLoader(String codebase)
124 throws MalformedURLException
126 RMIClassLoaderSpi spi = getProviderInstance();
127 if (spi == null)
128 spi = getDefaultProviderInstance();
129 return spi.getClassLoader(codebase);
133 * Returns a string representation of the network location where a remote
134 * endpoint can get the class-definition of the given class.
136 * @param cl
138 * @return a space seperated list of URLs where the class-definition
139 * of cl may be found
141 public static String getClassAnnotation(Class cl)
143 RMIClassLoaderSpi spi = getProviderInstance();
144 if (spi == null)
145 spi = getDefaultProviderInstance();
146 return spi.getClassAnnotation(cl);
150 * @deprecated
152 public static Object getSecurityContext (ClassLoader loader)
154 throw new Error ("Not implemented");
158 * Returns the default service provider for <code>RMIClassLoader</code>.
160 * @return the default provider for <code>RMIClassLoader</code>
162 public static RMIClassLoaderSpi getDefaultProviderInstance()
164 return RMIClassLoaderImpl.getInstance();
168 * Chooses, instantiates and returns a service provider.
170 * @return a service provider
172 private static RMIClassLoaderSpi getProviderInstance()
174 // TODO: Do something more useful here.
175 return null;