11.6. Creating an RMI Server
The RMI server is responsible for creating an instance of a service implementation and then registering it with the remote method invocation registry (rmiregistry). This actually amounts to only a few lines of code, and is extremely easy to do. In small systems, the server could even be combined with the service implementation by adding a main() method for this purpose, though a separation of classes is a cleaner design.
Code for LightBulbServer
import java.rmi.*; import java.rmi.server.*; // Chapter 11, Listing 3 public class LightBulbServer { public static void main(String args[]) { System.out.println ("Loading RMI service"); try { // Load the service RMILightBulbImpl bulbService = new RMILightBulbImpl(); // Examine ...
Get Java™ Network Programming and Distributed Computing now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.