<
Java

Sample Code for Example.idl

The JavaTM 2 SDK, Standard Edition, v1.3 includes a new version of the IDL-to-Java compiler, idlj. This compiler supports new CORBA-standard features required for RMI-IIOP. This document shows the code generated by the IDL-to-Java compiler in accordance with the CORBA 2.3 specification.

The followng file, Example.idl, is written in the OMG Interface Definition Language. OMG IDL is a purely declarative language designed for specifying programming-language-independent operational interfaces for distributed applications. OMG specifies a mapping from IDL to several different programming languages, including C, C++, Smalltalk, COBOL, Ada, and Java. When mapped, each statement in OMG IDL is translated to a corresponding statement in the programming language of choice.



Generated Files

The idlj compiler uses the IDL-to-Java mapping to convert IDL interface definitions to corresponding Java interfaces, classes, and methods, which you can then use to implement your client and server code. The following files are generated when Example.idl is compiled with the IDL-to-Java compiler, using the following command:



Counter.java, the signature interface

The signature interface file, Counter.java extends org.omg.portable.IDLEntity, org.omg.CORBA.Object, and the operations interface, CounterOperations. The signature interface is used as the signature type in method declarations when interfaces of the specified type are used in other interfaces. From the client's point of view, an object reference for a CORBA Counter object implements this interface.

Note: The Stub implements the Counter interface, where it generates code for each method to marshall the arguments, invoke the method, and then unmarshall the arguments.



CounterOperations.java, the operations interface

The Java operations interface, CounterOperations.java, is used in the server-side mapping and as a mechanism for providing optimized calls for co-located clients and server. The server developer provides implementation for the methods indicated by the operations interface.



CounterHelper.java, the Helper class

The Java class CounterHelper defines auxiliary methods, notably narrow(), which is the CORBA counterpart of Java casting.



CounterHolder.java, the Holder class

The Java class called CounterHolder holds a public Counter member. Holders are required for CORBA operations that take out or inout arguments, which, unlike CORBA in arguments, don't map directly to Java's pass-by-value semantics.



_CounterStub.java, the client stub

The Java class _CounterStub is the stub file for the client-side mapping.



_CounterImplBase.java, the server skeleton

The Java class _CounterImplBase is the skeleton file for the server-side mapping.



Completing the application

To complete the application, the developer must write the client and server code.



Copyright © 2000 Sun Microsystems, Inc. All Rights Reserved.

Send questions or comments to: JavaIDL@eng.sun.com.

Sun

Java Software