At a high-level prospective, Java RMI consists of several well-split layers:
-
Application Layer
Provides remote interface.
-
Stub/Proxy Layer
This layer automatically handles method invocation marshalling and unmarshalling, network transmission.
-
Remote Reference Layer
-
Transport Layer
Provides TCP-based communication for RPC.
Example
Remote Interface
Defines methods callable remotely.
1 | import java.rmi.Remote; |
Remote Object Implementation
Implement the interface defined and extend the remote object class.
1 | import java.rmi.server.UnicastRemoteObject; |