|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectjava.rmi.server.RMIClassLoaderSpi
net.jini.loader.pref.PreferredClassProvider
An RMIClassLoader provider that supports preferred
classes.
See the RMIClassLoader specification for information
about how to install and configure the RMIClassLoader
service provider.
PreferredClassProvider uses instances of PreferredClassLoader to load classes from codebase URL paths
supplied to RMIClassLoader.loadClass methods.
PreferredClassProvider does not enforce DownloadPermission by default, but a subclass can configure it to
do so by passing true as the argument to the
protected constructor.
By overriding the getClassAnnotation
method, a subclass can also configure the class annotations to be
used for classes defined by the system class loader, its ancestor
class loaders, and any class loader that is not an instance of
ClassAnnotation or URLClassLoader.
This implementation uses the Logger named
net.jini.loader.pref.PreferredClassProvider to log
information at the following levels:
| Level | Description |
|---|---|
FAILED | class loading failures |
FINE | invocations of loadClass and loadProxyClass
|
FINEST | detailed activity of
loadClass and loadProxyClass
implementations
|
| Constructor Summary | |
|
PreferredClassProvider()
Creates a new PreferredClassProvider.
|
protected |
PreferredClassProvider(boolean requireDlPerm)
Creates a new PreferredClassProvider.
|
| Method Summary | |
String |
getClassAnnotation(Class cl)
Provides the implementation for RMIClassLoaderSpi.getClassAnnotation(Class).
|
protected String |
getClassAnnotation(ClassLoader loader)
Returns the class annotation string to use for classes defined by the specified class loader. |
ClassLoader |
getClassLoader(String codebase)
Provides the implementation for RMIClassLoaderSpi.getClassLoader(String).
|
Class |
loadClass(String codebase,
String name,
ClassLoader defaultLoader)
Provides the implementation for RMIClassLoaderSpi.loadClass(String,String,ClassLoader).
|
Class |
loadProxyClass(String codebase,
String[] interfaces,
ClassLoader defaultLoader)
Provides the implementation of RMIClassLoaderSpi.loadProxyClass(String,String[],ClassLoader).
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public PreferredClassProvider()
PreferredClassProvider.
This constructor is used by the RMIClassLoader
service provider location mechanism when
PreferredClassProvider is configured as the
RMIClassLoader provider class.
DownloadPermission is not enforced by the created
provider.
protected PreferredClassProvider(boolean requireDlPerm)
PreferredClassProvider.
This constructor is used by subclasses to control whether
or not DownloadPermission is enforced.
requireDlPerm - if true, the class loaders
created by the provider will only define classes with a CodeSource that is granted DownloadPermission| Method Detail |
public Class loadClass(String codebase,
String name,
ClassLoader defaultLoader)
throws MalformedURLException,
ClassNotFoundException
RMIClassLoaderSpi.loadClass(String,String,ClassLoader).
Loads a class from a codebase URL path, only using the supplied
loader if the given name is not preferred by the class loader
for the codebase path.
If the name parameter is marked as preferred in the preferred
class loader which is requested to load the named class, that
class loader will not delegate to its parent to load the
requested class. Instead the class loader will only search its
own resources to find the class.
If a definition for the class cannot be found, a
ClassNotFoundException is thrown, otherwise the
class object for the requested class is returned.
If codebase is null, then the
value of the system property
java.rmi.server.codebase (or possibly an earlier
cached value) is used as the codebase URL path.
codebase - the list of URLs (separated by spaces) from
which the class should be loaded , or nullname - the name of the class to loaddefaultLoader - additional contextual class loader
to use, or null
Class object representing the loaded class
MalformedURLException - if codebase is
non-null and contains an invalid URL, or if
codebase is null and the value of
java.rmi.server.codebase contains an invalid URL
ClassNotFoundException - if a definition for the class
could not be found at the specified locationpublic String getClassAnnotation(Class cl)
RMIClassLoaderSpi.getClassAnnotation(Class).
PreferredClassProvider implements this method
as follows:
If cl is an array class (of one or more
dimensions) with a primitive component type, then this method
returns null.
If the defining class loader of cl is the
system class loader or an ancestor of the system class loader,
then this method invokes getClassAnnotation with the
loader and returns the result.
If the defining class loader of cl is an
instance of ClassAnnotation, then this method invokes
getClassAnnotation
on that loader and returns the result.
If the defining class loader of cl is an
instance of URLClassLoader and the current security
context has the permissions necessary to connect to all of the
URLs returned by an invocation of getURLs on the loader, then this method returns a
space-separated list of those URLs.
Otherwise, this method invokes getClassAnnotation with the
defining class loader of cl and returns the
result.
cl - the class to obtain the annotation for
nullprotected String getClassAnnotation(ClassLoader loader)
This method is invoked by PreferredClassProvider.getClassAnnotation(Class) when it is
passed a class defined by the system class loader, an ancestor
of the system class loader, any class loader that is not an
instance of ClassAnnotation or URLClassLoader,
or a URLClassLoader for which the current security
context does not have permission to connect to all of its URLs.
PreferredClassProvider implements this method
as follows:
This method returns the value of the system property
java.rmi.server.codebase (or possibly an earlier
cached value).
loader - the defining class loader of the class to obtain
the annotation for
null
public ClassLoader getClassLoader(String codebase)
throws MalformedURLException
RMIClassLoaderSpi.getClassLoader(String).
Returns a class loader that loads classes from the given
codebase URL path.
If codebase is null, then the
value of the system property
java.rmi.server.codebase (or possibly an earlier
cached value) is used as the codebase URL path.
If there is a security manager, its
checkPermission method will be invoked with a
RuntimePermission("getClassLoader") permission;
this could result in a SecurityException. This
method also verifies that the current security context has all
of the security permissions necessary to connect to all of the
URLs in the codebase URL path.
codebase - the list of URLs (space-separated) that the
returned class loader will load classes from, or
null
MalformedURLException - if codebase is
non-null and contains an invalid URL, or if
codebase is null and the value of
java.rmi.server.codebase contains an invalid URL
SecurityException - if there is a security manager and
the invocation of its checkPermission method
fails, or if the current security context does not have the
permissions necessary to connect to all of the URLs in the
codebase URL path
public Class loadProxyClass(String codebase,
String[] interfaces,
ClassLoader defaultLoader)
throws MalformedURLException,
ClassNotFoundException
RMIClassLoaderSpi.loadProxyClass(String,String[],ClassLoader).
Defines and returns a dynamic proxy class in a class loader
with URLs supplied in the given location. The proxy class will
implement interface classes named by the given array of
interface names.
If codebase is null, then the
value of the system property
java.rmi.server.codebase (or possibly an earlier
cached value) is used as the codebase URL path.
codebase - the list of URLs (space-separated) to load
classes from, or nullinterfaces - the names of the interfaces for the proxy class
to implementdefaultLoader - additional contextual class loader
to use, or null
MalformedURLException - if codebase is
non-null and contains an invalid URL, or if
codebase is null and the value of
java.rmi.server.codebase contains an invalid URL
ClassNotFoundException - if a definition for one of
the named interfaces could not be found at the specified location,
or if creation of the dynamic proxy class failed (such as if
Proxy.getProxyClass
would throw an IllegalArgumentException for the given
interface list)
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||