SPRING2 for remote Access Service, a Sqlremote package provided. It provides a unified set of remote service publishing capabilities.
Let's take a look at Spring2 support for those remote services features:
1. RMI Service
2. Hessian or burlap remote Invoke service via HTTP
3. HTTP Caller Exposure Service
Here's an example to see how Spring2 encapsulates and manages these services.
First look at the server-side source code
public interface IBookService {
Book getById(String id);
}
public class Book {
public String name;
public String id;
public String author;
}
public class BookService implements IBookService {
public Book getById(String id) {
return BookStore.getById(id);
}
}
Client source code
public class BookQueryService {
private IBookService bookService;
public void setAccountService(IBookService bookService) {
this.bookService = bookService;
}
public Book getBookById(String id) {
return bookService.getById(id);
}
}
//客户端调用示例
public static void main(String[] args) {
ClassPathXmlApplicationContext context;
context = new ClassPathXmlApplicationContext("applicationContext.xml");
BookQueryService bookQueryService = (BookQueryService) context.getBean("bookQueryService");
Book book = bookQueryService.getBookById("1");
}