11.4. Implementing an RMI Service Interface

Once a service interface is defined, the next step is to implement it. This implementation will provide the functionality for each of the methods, and may also define additional methods. However, only those methods defined by the RMI service interface will be accessible remotely, even if they are marked public in scope or as being able to throw a RemoteException.

For our lightbulb system, the following implementation could be created.

Code for RMILightBulbImpl

 // Chapter 11, Listing 2 public class RMILightBulbImpl // Extends for remote object functionality extends java.rmi.server.UnicastRemoteObject // Implements a light bulb RMI interface implements RMILightBulb { // A constructor must be provided ...

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.