The Java RMI is a Java remote method invocation technology; a client executes a method ocated on a server, the Java RMI service.
In this recipe, we will set up a Java RMI service that will expose the methods of a normal Java class. The service will be part of an existing Spring web application but will use its own port.
The server will expose the methods of the UserService
interface:
Public interface UserService { public abstract List<User> findAll(); public abstract void addUser(User user); }
The UserService
interface is implemented by UserServiceImpl
:
public class UserServiceImpl implements UserService { private List<User> userList = new LinkedList<User>(); public UserServiceImpl() { User user1 = new User("Merlin", 777); userList.add(user1); User user2 = new User("Arthur", 123); userList.add(user2); } public List<User> findAll() { return userList; } public void addUser(User user...