Home >Java >javaTutorial >Detailed explanation of Java implementation of Service and Client (Developed by Corba)

Detailed explanation of Java implementation of Service and Client (Developed by Corba)

黄舟
黄舟Original
2017-10-19 09:38:122457browse

This article mainly introduces the detailed explanation of the Java implementation of Service and Client developed by Corba. I hope this article can help everyone. Friends in need can refer to the following

Detailed explanation of the Java developed by Corba Implementing Service and Client

1 Overview

CORBA (Common Object Request Broker Architecture, Common Object Request Broker Architecture) is a type developed by the OMG organization Standard object-oriented application architecture specification. In other words, the CORBA architecture is a solution proposed by OMG to solve the interconnection of hardware and software systems in a distributed processing environment (DCE).

OMG: Object Management Group, object management organization. It is an international, open-member, non-profit computer industry standards association. The association was established in 1989. Its responsibilities are to provide a public framework for application development, formulate industry guidelines and object management specifications, and accelerate the development of object technology. . . Any organization can join OMG and participate in the standards development process. OMG has developed modeling standards such as Unified Modeling Language (UML) and ModelDriven Architecture (MDA). Enables processes such as powerful visual design, execution and maintenance software. Moreover, OMG has also developed the well-known middleware standard CommonObject Request Broker Architecture (CORBA?).

Common Object Request Broker Architecture CORBA (Common Object Request Broker Architecture) is a solution defined by OMG to achieve interoperability between a large number of today's hardware and software. CORBA is also moving towards object-oriented standardization and interoperability. An important step.

Simply put, CORBA allows applications to communicate with each other regardless of where they exist and who designed them, that is, cross-platform and cross-language. CORBA1.1 was released by OMG in 1991, which defined the interface definition language (IDL) and the application programming interface (API) that implements the interaction between client objects and server objects in the object request broker (ORB). CORBA2.0 was released in 1994 and specified the communication rules for ORBs between various vendors.

The CORBA standard is mainly divided into three parts: Interface Definition Language (IDL), Object Request Broker (ORB), and the interoperability protocol IIOP between ORBs.

IDL is a language defined by CORBA. CORBA also defines the mapping of IDL to various languages. The standard mappings include Ada, C, C++, Smalltalk, Java, and Python. With these mappings, IDL can be translated into various languages, thus achieving cross-language. IDL language is an interface definition language. The IDL language is different from all existing programming languages. It is a descriptive language, that is to say, the interface described by it cannot be directly compiled and executed. The OMG IDL language uses the ISOLatin-1 (8859.1) character set. The character set can be divided into letters, numbers, graphic symbols, space characters, and format symbols. The letters include the 26 uppercase and lowercase letters in English, and the numbers include the 10 Arabic numerals 0 to 9.

ORB is the core of CORBA and is the middleware that establishes Client/Server relationships between objects. Using ORB, clients can transparently call methods on a service object, which can be local or on other machines connected through the network. The ORB intercepts this call and is responsible for finding the object that implements the service, passing parameters to it, and calling the method to return the final result. The client does not know where the service object is located, what its programming language and operating system are, or other parts of the system that are not part of the object's interface. In this way, ORB provides interoperability for applications on different machines in a heterogeneous distributed environment and seamlessly integrates multiple object systems.

When the client calls the server-side code, the ORB is invisible to the client. The client feels as if it is calling the method of its own object, but the network transmission process is encapsulated in the ORB.

2 idl file creation

Before development, you need to configure the Eclipse plug-in development environment according to the previous chapter,

1. Client development idl File, idl file is provided by the server interface, or customized, as shown below:




##

modulehelloapp {
  interfaceHello {
    string sayHello();
    oneway void shutdown();
  };
};

2. Select the IDL file, right-click ORBMenu--->Compile, and the corresponding operation file will be automatically generated

Automatically generate the required operations There are 7 files in total;

## 3 Server-side development

1. Right-click on src New--->Other-- ->CORBAWizard--->Server--->Active object map--->Next as shown below:

2. In the pop-up dialog box, select /{projectName}/src/{IDLname}.idl in the IDL filename column

Select the interface name defined in the IDL file in the Interface column

Package Fill in the package name in the column

Fill in the server class name in the Server classname column

--->Next In the pop-up dialog box, select the Createserver class: item


3. Add unimplemented methods to the generated server class and fill in the method body


Now the server configuration is completed, Server_AOM class is the server startup entrance.

4 Client development

1. Create a new java project;

2. Right-click on src New--->Other---> ;CORBA Wizard--->IDL files--->Simple IDL, as shown below:

3. Select the previous idl file,

After completion, the client file operation is automatically generated, as shown below:

4. In the main method of the client class, uncomment test .getORBInterface().operation1("Amessage in the bottle..."); and call the previously customized method to modify the passed String content. The client call is completed.

Note: Run the server program Server_AOM.java, and then run the client program MyServiceClientImpl.java

The simple Service and client development is now complete!

The above is the detailed content of Detailed explanation of Java implementation of Service and Client (Developed by Corba). For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn