Book Image

SPRING COOKBOOK

Book Image

SPRING COOKBOOK

Overview of this book

Table of Contents (19 chapters)
Spring Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Creating a Hessian service


Hessian is a remote method invocation technology; here, a client executes a method located on a server-the Hessian service. It uses HTTP, so it can go over proxies and firewalls. It also has implementations in multiple languages (PHP, Python, Ruby, and so on). So, for example, the client can use Java and the server can use PHP.

In this recipe, we will add a Hessian service to an existing Spring web application. It will expose the methods of a Java class.

Getting ready

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",...