Remote package Learning notes provided by Spring 2

Source: Internet
Author: User

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");
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.