The RMI module has several RMI templates available from the New
Wizard. You can use the templates 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 a client and a 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 Remote that generates a remote interface that you complete in the IDE's editing window. The template wizard provides support for writing a remote interface, it provides you with dialog boxes that enable you to 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 the RMI templates.
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.
See also | |
---|---|
RMI Technology
Steps for Creating an RMI Program |