Implementing a Remote Interface - rsanchez-wsu/jfiles GitHub Wiki

A class that implements a remote interface generally adhere to the following rules:

  • Your class should usually extend java.rmi.server.UnicastRemoteObject.
  • Your class should be able to implement any number of remote interfaces.
  • Your class should be able to extend another remote implementation class.
  • Your class can use methods not specified in the remote interface, but they must not be available remotely, only locally.

The class that implements the remote interface does not necessarily HAVE to extend java.rmi.server.UnicastRemoteObject, and can extend some other class in place of it. However, the class must then implement functionality to properly export the new object.

reference: https://docs.oracle.com/javase/7/docs/platform/rmi/spec/rmi-objmodel6.html

To get started implementing these in our project, I believe that we should start by creating an Interface. This interface should follow the below rules.

  1. Use the current server class methods to create the interface.
  2. Extend interface with RMI
    a. must import java.rmi.* and java.rmi.server.*
  3. All methods must throw remote exception

Our next step will need to implement this interface on our server.

  1. Implement interface from above
  2. Extend from UnicastRemoteObject
  3. Should throw remote exception
  4. Use a registry and place objects on the registry
    a. Use Naming.rebind(BINDNAME, OBJECT)

reference: https://www.youtube.com/watch?v=3RnbKojS5_g