RMIClassLoader
comprises static methods to support
dynamic class loading with RMI. Included are methods for loading
classes from a network location (one or more URLs) and obtaining
the location from which an existing class should be loaded by
remote parties. These methods are used by the RMI runtime when
marshalling and unmarshalling classes contained in the arguments
and return values of remote method calls, and they also may be
invoked directly by applications in order to mimic RMI's dynamic
class loading behavior.
The implementation of the following static methods
loadClass(URL, String)
loadClass(String, String)
loadClass(String, String, ClassLoader)
loadProxyClass(String, String[], ClassLoader)
getClassLoader(String)
getClassAnnotation(Class)
RMIClassLoaderSpi
, the
service provider interface for those methods. When one of the
methods is invoked, its behavior is to delegate to a corresponding
method on the service provider instance. The details of how each
method delegates to the provider instance is described in the
documentation for each particular method.
The service provider instance is chosen as follows:
java.rmi.server.RMIClassLoaderSpi
is defined, then if
its value equals the string "default"
, the provider
instance will be the value returned by an invocation of the getDefaultProviderInstance()
method, and for any other value, if
a class named with the value of the property can be loaded by the
system class loader (see ClassLoader#getSystemClassLoader
)
and that class is assignable to RMIClassLoaderSpi
and has a
public no-argument constructor, then that constructor will be
invoked to create the provider instance. If the property is
defined but any other of those conditions are not true, then an
unspecified Error
will be thrown to code that attempts
to use RMIClassLoader
, indicating the failure to
obtain a provider instance.
META-INF/services/java.rmi.server.RMIClassLoaderSpi
is
visible to the system class loader, then the contents of that
resource are interpreted as a provider-configuration file, and the
first class name specified in that file is used as the provider
class name. If a class with that name can be loaded by the system
class loader and that class is assignable to RMIClassLoaderSpi
and has a public no-argument constructor, then
that constructor will be invoked to create the provider instance.
If the resource is found but a provider cannot be instantiated as
described, then an unspecified Error
will be thrown to
code that attempts to use RMIClassLoader
, indicating
the failure to obtain a provider instance.
getDefaultProviderInstance()
method.
RMIClassLoaderSpi
Modifier and Type | Field and Description |
---|---|
private static final RMIClassLoaderSpi | defaultProvider
"default" provider instance |
private static final RMIClassLoaderSpi | provider
provider instance |
Access | Constructor and Description |
---|---|
private |
Modifier and Type | Method and Description |
---|---|
public static String | Returns: a string to be used to annotate the given class when it gets marshalled, ornull the class to obtain the annotation for cl)Returns the annotation string (representing a location for the class definition) that RMI will use to annotate the class descriptor when marshalling objects of the given class. |
public static ClassLoader | Returns: a class loader that loads classes from the given codebase URL paththe list of URLs (space-separated) from which
the returned class loader will load classes from, or codebase)null Returns a class loader that loads classes from the given codebase URL path. |
public static RMIClassLoaderSpi | Returns: the canonical instance of the default service providerReturns the canonical instance of the default provider
for the service provider interface |
public static Object | Returns: the security contexta class loader from which to get the security context loader)
Deprecated
no replacement. As of the Java 2 platform v1.2, RMI no
longer uses this method to obtain a class loader's security context.
Returns the security context of the given class loader.
|
private static RMIClassLoaderSpi | |
public static Class | |
public static Class | |
public static Class | |
public static Class | Returns: theClass object representing the loaded classthe list of URLs (separated by spaces) to load
the class from, or codebase, String null the name of the class to load name, ClassLoader additional contextual class loader
to use, or defaultLoader)null Loads a class from a codebase URL path, optionally using the supplied loader. |
public static Class | Returns: a dynamic proxy class that implements the named interfacesthe list of URLs (space-separated) to load
classes from, or codebase, String[] null the names of the interfaces for the proxy class
to implement interfaces, ClassLoader additional contextual class loader
to use, or defaultLoader)null Loads a dynamic proxy class (see |
private static RMIClassLoaderSpi |
defaultProvider | back to summary |
---|---|
private static final RMIClassLoaderSpi defaultProvider "default" provider instance |
provider | back to summary |
---|---|
private static final RMIClassLoaderSpi provider provider instance
|
RMIClassLoader | back to summary |
---|---|
private RMIClassLoader() |
getClassAnnotation | back to summary |
---|---|
public static String getClassAnnotation(Class<?> cl) Returns the annotation string (representing a location for the class definition) that RMI will use to annotate the class descriptor when marshalling objects of the given class. This method delegates to the
|
getClassLoader | back to summary |
---|---|
public static ClassLoader getClassLoader(String codebase) throws MalformedURLException, SecurityException Returns a class loader that loads classes from the given codebase URL path. The class loader returned is the class loader that the
This method delegates to the
If there is a security manager, its
|
getDefaultProviderInstance | back to summary |
---|---|
public static RMIClassLoaderSpi getDefaultProviderInstance() Returns the canonical instance of the default provider
for the service provider interface
If there is a security manager, its
The default service provider instance implements
|
getSecurityContext | back to summary |
---|---|
public static Object getSecurityContext(ClassLoader loader)
Deprecated no replacement. As of the Java 2 platform v1.2, RMI no longer uses this method to obtain a class loader's security context. Returns the security context of the given class loader.
|
initializeProvider | back to summary |
---|---|
private static RMIClassLoaderSpi initializeProvider() Chooses provider instance, following above documentation. This method assumes that it has been invoked in a privileged block. |
loadClass | back to summary |
---|---|
public static Class Deprecated replaced by Loads the class with the specified This method delegates to
|
loadClass | back to summary |
---|---|
public static Class Loads a class from a codebase URL.
If This method delegates to the
|
loadClass | back to summary |
---|---|
public static Class Loads a class from a codebase URL path. This method delegates to the
|
loadClass | back to summary |
---|---|
public static Class Loads a class from a codebase URL path, optionally using the
supplied loader.
This method should be used when the caller would like to make
available to the provider implementation an additional contextual
class loader to consider, such as the loader of a caller on the
stack. Typically, a provider implementation will attempt to
resolve the named class using the given This method delegates to the
|
loadProxyClass | back to summary |
---|---|
public static Class Loads a dynamic proxy class (see The interfaces will be resolved similar to classes loaded via
the This method delegates to the
|
newDefaultProviderInstance | back to summary |
---|---|
private static RMIClassLoaderSpi newDefaultProviderInstance() Creates an instance of the default provider class. |