The RMI module has an RMI wizard and several RMI templates. You can use
either tool to generate Java source files (.java
files) for the different
parts of RMI programs. The kind of RMI program you are writing determines
the files you need to generate.
Remote interface files are Java interfaces that extend java.rmi.Remote
. The remote interface
defines the interface of an RMI server. It is compiled to create the stub
and skeleton files that enable client and server to communicate. On the
server side, you need a remote interface in the package with your implementation
class. On the client side, you need to know the method signatures
declared in the remote interface, because your client will be invoking
these methods. You also need a remote interface, which is required
for compiling.
You can use an existing remote interface or you can write your own:
The RMI templates include a template named RemoteInterface that generates a remote interface you complete in the IDE's editing window. The RMI wizard provides more support for writing a remote interface; it has buttons that add interface elements in correct syntax.
The files you need for a client-side program are:
If you are writing a client program to access an existing RMI server, you need a copy of the remote interface, which contains method signatures for the server-side methods your program can invoke.
The files you need for a server-side program are:
The RMI module generates implementation classes that include their own startup code. This means that they create instances of themselves, export themselves, and register themselves with an RMI registry. You can generate an implementation class with either the RMI templates or the RMI wizard.
After generating an implementation class, you need to write the business logic. If your business logic is complex, you can supplement the public methods declared in the remote interface with private methods that are invoked by the declared remote methods.
If you are using the RMI templates to generate your server-side files, you should generate and complete a remote interface (or obtain a copy of an existing interface) before generating the other server-side files. If you are using the RMI Wizard, the wizard can help you write a remote interface.
See also | |
---|---|
RMI Technology
Steps for Creating an RMI Program |