How the stub and skeleton of the EJB work

Source: Internet
Author: User
Tags stub throwable

I. The principle of RMI operation

The nature of RMI is to implement calls between different JVMs, and it is implemented by opening a stub and skeleton in two JVMs, both of which are passed through the socket communication to implement parameters and return values.

The RMI example code can be found on the internet a lot, but most are through the extend the interface Java.rmi.Remote implementation, has been encapsulated very perfect, unavoidably make people have a sense of smoke and mirrors. The following example is what I see in "Enterprise JavaBeans", although it is very rough but intuitive and helps to understand how quickly it works.

1, define a person's interface, which has two business method, Getage () and GetName ()

Code:

public interface Person {
public int getAge() throws Throwable;
public String getName() throws Throwable;
}

2, person's realization Personserver class

Code:

public class PersonServer implements Person {
int age;
String name;
public PersonServer(String name, int age) {
this.age = age;
this.name = name;
}
public int getAge() {
return age;
}
public String getName() {
return name;
}
}

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.