Java remote method call 1

zhaozj2021-02-08  438

Overview

Java Remote Method Invocation (RMI - Java Remote Method Call) Allows you to write distributed objects with Java. This article describes the advantages of RMI and how to connect them into existing and original systems, and connectors to components written in Java.

RMI provides a simple and straightforward way for distributed computing using Java objects. These objects can be new Java objects, or a simple Java packaging surrounding existing API. Java reflects "Writing once to run anywhere in any place. And RMI can extend Java mode to run anywhere."

Because the RMI is core based on Java, it brings powerful functions such as Java's security and portability to distributed calculations. You can move attributes such as proxy and tip. Logic to the most suitable place in the network. If you want to expand Java in the system, RMI will make you take advantage of its powerful features.

RMI can be connected to existing and original systems using standard Java native method interface JNI. RMI can also connect to an existing relational database using a standard JDBC package. The RMI / JNI and RMI / JDBC can help you communicate with RMI with existing servers currently using non-Java languages, and can extend Java on these servers when you need. RMI helps you take advantage of Java's powerful features when expanding usage.

advantage

From the most basic point of view, RMI is a remote procedure call (RPC) mechanism for Java. The RMI has several advantages compared to the traditional RPC system because it is part of the Java object-oriented method. Traditional RPC systems use neutral languages, so it is the most common system - they cannot provide all possible target platforms.

RMI uses Java as the core and can be connected to existing systems with the native method. That is to say, RMI can provide distributed computing technology in a natural, direct and functional way, and this technique can help you add Java features to your entire system in a constantly increasing and seamless way.

The main advantages of RMI are as follows:

Object-oriented: RMI can transmit a complete object as a parameter and return value, not just a predefined data type. That is, you can transfer complicated types of Java hash tables as a parameter. In the current RPC system, you can only rely on the client to break such objects into basic data types, and then pass these data types, and finally recreate the hash table on the server side. RMI does not require additional customer program code (breaking objects into basic data types), directly transfers the object.

Mobile Properties: RMI can move attributes from the client to the server, or move from the server to the client. For example, you can define an interface to check the employee's spending report to see if the employee has complied with the company's current policy. After the expense report is created, the client will get the object that implements the interface from the server side. If the policy changes, the server side will start returning another implementation program that uses the interface of the new policy. You don't have to install any new software on the user system to check the restrictions on the client - thus providing the user to provide the user's quick feedback, and reduce the server's workload. This will have the greatest flexibility, because when the policy changes you only need to write a new Java class and install it once on the server host.

Design method: Object transfer enables you to take advantage of the power-oriented technology in distributed computing, such as two-layer and three-layer structural systems. If you are able to pass attributes, you can use object-oriented design in your solution. All object-oriented design methods do not rely on different properties to function, if the full object cannot be passed - including implementation and type - will lose the advantages provided in design.

An All: RMI uses Java built-in security mechanism to ensure the security of user systems when downloading execution procedures. RMI uses a safety management process designed to protect the system from malicious apps to protect your system and network from potential malicious download procedures. When the situation is serious, the server rejects any execution program. Easy to write and use: RMI makes the Java remote service program and the writing of Java clients accessing these servers easily and simple. The remote interface is actually a Java interface. The service procedure is approximately three-line instructions itself is a service program, and other aspects are similar to any other Java object. This simple method is easy to quickly write a full-distributed object system service, and quickly make the software prototype and earlier to facilitate testing and evaluation. Since the RMI program is simple, maintenance is also simple.

Connecting existing / original systems: RMI can interact with existing systems via Java's native method interface JNI. With RMI and JNI, you can write client programs in Java language and use existing server-side programs. When using RMI / JNI to connect to an existing server, you can choose to rewrite any part of the service program with Java, and give the new program to the Java functionality. Similarly, RMI can use JDBC to interact with existing relational databases without modifying an existing non-Java source code using a database.

Write once, run everywhere: RMI is part of Java "Writing once, run everywhere" method. Any RMI-based system can be transferred from 100% to any Java virtual machine, and the RMI / JDBC system is no exception. If you use RMI / JNI to interact with existing systems, the code written in JNI can be compiled and run with any Java virtual machine.

Distributed garbage collection: RMI uses its distributed garbage collection function to collect remote service objects referenced by any client program in the network. Similar to the garbage collection of Java virtual machines, distributed garbage collection features allow users to define server objects according to their own needs, and clarify that these objects will be deleted when they are no longer referenced by the client.

Parallel Calculation: RMI uses multi-threaded process, allowing your server to use these Java threads to better deal with the client's request. Java Distributed Computing Solution: RMI starts from JDK 1.1 is the core part of the Java platform, so it exists in any 1.1 Java virtual machine. All RMI systems use the same public protocol, so all Java systems can be directly dialogue, without having to convert protocols in advance.

转载请注明原文地址:https://www.9cbs.com/read-910.html

New Post(0)