Exploring the application of CORBA technology 8/20/2001 9: 15: 2 · · Dave Bartlett ·· Transferred from IBM DeveloperWorks China website 1 2 Next June, we talked why you want to use CORBA and Java technology. This month, I want to pass a simple example of a available examples, let you start exploring the field of CORBA technology. However, don't forget that our goal is to create such a distributed application: allowing clients residing on a computer to issue a request to the service 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. The Idl Interface All CORBA Structures Starting from an interface, the best way to understand the interface is to imagine my car, right, my car. Although you are not familiar with it, if I said to you: "On my car, bring some sandwiches to come back", I am afraid you will not suspect that you can drive my car. You may want to know where it stops and open it is safe, but you will be sure that my car is not very different. This is because, in various cars, the interface between people and cars has been highly standardized. There may be some differences between my cars and your sports cars, but the installation of the car's accelerator pedal, brakes and steering wheel is standard, you will be easily and fast. Because CORBA is independent of language, it relies on how the client issues a request to implement the service to implement the interface. Our interface is a method: add (). This method will take two numbers (two IDL LONG models) and return these two numbers. Here is our interface computing 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 a namespace, and this keyword is accurately mapped to Java Keyword Package. When running the IDL-To-Java compiler, the generated Java file will save to the subdirectory called CalcsImpl. The IDL keyword interface is perfectly mapped to Java interface and represents an abstract type because both only define the way you communicate with objects without involving the implementation of objects. IDL keyword long is a basic integer type, which maps at least 4 bytes, which is int for the Java code. If you want to perform a mechanism to call the remote method, you will find how significance in the direction of defining parameters (clients to servers, servers or bidirectional delivery). In the IDL operation, these directions are declared with IN, OUT, and INOUT, each parameter must declare the direction in order to enable the Object Request Agent (ORB) to know the direction of the parameter. This affects parameter packaging, parameter unpacking, and memory management for sending parameters. The more the orb has more, the higher it is efficient. Keyword IN indicates that long x and long y are passed from the client to the server. Figure 1. Does the Idl compiler participating in the CORBA request require the IDL compiler? You may already have an ORB vendor and IDL-to-Java compiler. But if you haven't, where did you get it? There are many here, and some can be downloaded for free. I recommend Obect Oriented Concepts, INC. ORBACUS ORB. If you don't use it for commercial purposes, it can also be downloaded for free, and it is fully compliant with CORBA 2.3 specification. Another can try 60 days of compilers are the Visibroker of Inprise, and it is also fully compliant with CORBA 2.3 specification and downloadable. For these two products, please refer to the reference. After the interface definition, you must run on the IDL-to-Java compiler provided by the ORB vendor. The IDL compiler is a delicate utility that generates IDL's Stub and Skeleton and other support files. These source files generated, most of which will enhance the package functionality of the specific IDL type defined in the CORBA standard. The compiler will generate most of the network detection (Plumbing), which is very important in distributed systems. In the most basic level, the IDL-TO-Java compiler is just a definition of CORBA 2.3 specification to implement programs from IDL to Java language mapping. Manual generation These code is boring and time, it is easy to make an error; the IDL-to-java compiler handles this, so you don't have to worry about it; The IDL-to-Java compiler will impart the CORBA-LAND rules to your system. Enter the following command to execute the IDL-TO-JAVA compiler from ORBACUS, put all generated files in the output directory of ClassPath. Listing 2. Call IDL-to-Java compiler