Explore the application field of CORBA technology

Source: Internet
Author: User
Tags definition

June, we talked about why you want to use CORBA and Java technology. This month, I'm going to start exploring many areas of CORBA technology with a simple, usable example. But don't forget our goal is to create a distributed application that enables clients residing on one computer to make requests to services running on another computer. We don't want to worry about details such as hardware or operating system software, but just want this service to respond to client requests.

IDL interface

All CORBA structures start with an interface, and the best way to understand the interface is to imagine my car, yes, my car. Although you are not familiar with it, if I say to you: "Drive my car, bring some sandwiches back for lunch", I am afraid you will not doubt whether you can drive my car. You may want to know where it is parked and whether it is safe to drive, but you will be sure that driving my car is not the same as driving your car. This is because, in all kinds of cars, the interface between people and cars has been highly standardized. There may be some difference between my car and your sports car, but the car's accelerator pedal, brake and steering wheel installation are standard, you will be able to easily and quickly road.

Because CORBA is language-independent, it relies on an interface definition language (IDL) to express how the client makes a request to the service that implements the interface. Our interface is one way: Add (). This method takes two numbers (a long of two IDL) and returns the sum of the two numbers. The following is our interface calculation program:

Listing 1. Calcsimpl.idl

module corbasem {
  module gen {
   module calcsimpl {
     interface calculator {
      long add(in long x, in long y);
     };
   };
  };
};

The IDL keywords in this interface are: module, interface, Long, and in. IDL uses keyword module to create namespaces, and this keyword is accurately mapped to Java keyword package. When you run the Idl-to-java compiler, the generated Java files are saved to a subdirectory named Calcsimpl. The IDL keyword interface is perfectly mapped to the Java interface and represents an abstract type, because both define only how you communicate with the object, not the object's implementation. The IDL keyword Long is a basic integer type that is mapped at least to a 4-byte type, which is an int in Java code.

If you think about the mechanism for remote method calls, you'll find how meaningful it is to define the direction in which parameters are passed (client to server, server to client, or two-way delivery). In IDL operations, these orientations are declared in the in, out, and InOut keywords, and each parameter must declare a direction so that the object request agent (ORB) knows where the parameter is going. This affects the parameter packaging, parameter unpack, and memory management for sending. The more the ORB understands the parameters, the more efficient it becomes. The keyword in indicates that long x and long y are passed from the client to the server.

Figure 1. Participate in various parts of CORBA request

Does the IDL compiler require an IDL compiler?

You may already have the ORB vendor and the Idl-to-java compiler. But if not, where do you get it? There are many, and some are free to download. I recommend the Object oriented Concepts, Inc. 's Orbacus ORB. If it is not used for commercial purposes, it can also be downloaded free of charge and fully compliant with the CORBA 2.3 specification. Another 60-day compiler is the Inprise Visibroker, fully compliant with the CORBA 2.3 specification and downloadable. For both products, please refer to resources.

After the interface definition, it must be run on the Idl-to-java compiler provided by the ORB vendor. The IDL compiler is an ingenious utility that generates the stub and skeleton of IDL and other supporting files. Most of the generated source files will enhance the packaging capabilities of the specific IDL types defined in the CORBA standard. The compiler will generate most of the network probes (plumbing), which is very important in distributed systems. At the most basic level, the Idl-to-java compiler is just a program that implements the mapping from IDL to Java language as defined by the CORBA 2.3 specification. Manually generating this code is tedious, time-consuming, and error-prone; the Idl-to-java compiler handles all this, so you don't have to worry about it, and it will constrain you with certain rules and force you to perform the encapsulation. The Idl-to-java compiler will impose corba-land rules on your system.

Enter the following command, execute the Idl-to-java compiler from Orbacus, and put all the generated files in the CLASSPATH output directory.

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.