Used for exporting a remote object with JRMP and obtaining a stub
that communicates to the remote object. Stubs are either generated
at runtime using dynamic proxy objects, or they are generated statically
at build time, typically using the rmic
tool.
Deprecated: Static Stubs. Support for statically
generated stubs is deprecated. This includes the API in this class that
requires the use of static stubs, as well as the runtime support for
loading static stubs. Generating stubs dynamically is preferred, using one
of the five non-deprecated ways of exporting objects as listed below. Do
not run rmic
to generate static stub classes. It is unnecessary, and
it is also deprecated.
There are six ways to export remote objects:
UnicastRemoteObject
and calling the
UnicastRemoteObject()
constructor.
UnicastRemoteObject
and calling the
UnicastRemoteObject(port)
constructor.
UnicastRemoteObject
and calling the
UnicastRemoteObject(int, RMIClientSocketFactory, RMIServerSocketFactory)
constructor.
exportObject(Remote)
method.
Deprecated.
exportObject(Remote, port)
method.
exportObject(Remote, int, RMIClientSocketFactory, RMIServerSocketFactory)
method.
The fourth technique, exportObject(Remote)
,
always uses statically generated stubs and is deprecated.
The other five techniques all use the following approach: if the
java.rmi.server.ignoreStubClasses
property is true
(case insensitive) or if a static stub cannot be found, stubs are generated
dynamically using Proxy
objects. Otherwise,
static stubs are used.
The default value of the
java.rmi.server.ignoreStubClasses
property is false
.
Statically generated stubs are typically pregenerated from the
remote object's class using the rmic
tool. A static stub is
loaded and an instance of that stub class is constructed as described
below.
Remote
, then
the remote object's class is the root class; otherwise, the root class is
the most derived superclass of the remote object's class that directly
implements an interface that extends Remote
.
_Stub
.
RemoteStub
and must have a
public constructor that has one parameter of type RemoteRef
.
RemoteRef
.
StubNotFoundException
is thrown.
Stubs are dynamically generated by constructing an instance of
a Proxy
with the following characteristics:
RemoteObjectInvocationHandler
instance constructed with a
RemoteRef
.
StubNotFoundException
will be thrown.
extends
@implNote
Depending upon which constructor or static method is used for exporting an
object, RMISocketFactory
may be used for creating sockets.
By default, server sockets created by RMISocketFactory
listen on all network interfaces. See the
RMISocketFactory
class and the section
RMI Socket Factories
in the
Java RMI Specification.