Jump to content

Jini and Network Computing/Specifying a Codebase

From Wikibooks, open books for an open world

The classic specification of an RMI codebase is typically performed using the java.rmi.server.codebase system property on the command line starting the Java Virtual Machine. There are more powerful techniques that allow a single JVM to serve out remote objects with varied codebases. This mechanism is through the codebase annotation service provider interface available through the RMIClassLoaderSPI abstract class.

One can simply subclass this class, providing the appropriate annotations that are appropriate for the classes in the getClassAnnotation(Class) call. A container could allow the user to specify a codebase that is associated with a classpath that it could associate with a specific ClassLoader. Then the implementation of RMIClassLoaderSPI would use the passed Class to find the appropriate ClassLoader that would then designate the codebase annotation that applied.