|
Remote Method Invocation (RMI) is a Java technology in which an object running in Java Virtual Machine (JVM) could be invoked from another object running in a different JVM. The technology provides a remote access of objects in Java programming language.
The RMI technology consists of a server and a client. The server usually creates remote objects and binds these objects to the rmiregistry allowing the objects to be accessed remotely. The client would connect to the server and get one or more remote reference and then invoke the methods on the remote objects. The RMI technology wraps the underlying communication and hence the developer only needs to code the business logic, instead of worrying about the communication between the client and the server.
Remote objects are objects that could be called across JVMs. An object becomes remote by implementing a remote interface. The implemented remote interface should extend the java.rmi.Remote interface and all the methods declared in the interface should throw the exception java.rmi.RemoteException.
RMI passes a remote stub for a remote object. The stub, which acts as proxy for the remote object, is the remote reference to the client in the client environment. The client invokes a method on the local stub, which is responsible for carrying out the method call on the remote object. The stub for a remote object implements the same set of remote interfaces that the remote object implements. Again, only those methods defined in a remote interface are available to the client.
The stub and the skeleton are created by invoking the rmic compiler (available with the JDK package) on the remote interface implementing classes.
|
|
Note: Use javac to compile the source files. Next, use the rmic compiler to create stubs for the remote objects. |
|