JAVA Remote Object

Source: Internet
Author: User

The RMI remote method invocation is a communication mechanism between computers that use remote objects to call each other to achieve communication between the two parties. With this mechanism, an object on one computer can invoke an object on another computer to obtain remote data. RMI is the backbone of enterprise JavaBean and a convenient way to build distributed Java applications. In the past, TCP/IP Sockets communication is the main means of remote communication, but this development method does not use an object-oriented approach to development, in the development of such a communication mechanism often makes the programmer feel bored, the RPC (remote Procedure call) came into being, Makes it easier for programmers to invoke remote programs, but RPC is still not well supported in the face of complex messaging, and RPC has failed to achieve object-oriented development patterns.

RMI Development Steps:

1. First create the remote interface and declare the remote method, note that this is only the interface to achieve communication between the two, need to inherit remote.

2. Develop a class to implement remote interfaces and remote methods, it is worth noting that the implementation class needs to inherit UnicastRemoteObject.

3. Compile the file through the Java command, register the service with the Java-server command, and start the remote object.

4. Finally the client looks for the remote object and calls the remote method.

Java instance:

1. First create a model layer for the service, note that because this object requires remote transport, you must inherit serializable.

2. Create the remote interface Personservice, and note that the remote interface needs to inherit remotes.

3. Establish Personserviceimpl to implement the remote interface, note that this is a remote object implementation class, need to inherit unicastremoteobject.

4. Establish server side, register RMI communication port and communication path on server side, then communicate javac command to compile file, register service through Java-server command.

5. Do after I establish the client to test, note that the RMI path called must be server configuration consistent.

JAVA Remote Object

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.