Programming Stand-alone Clients
RMI over IIOP with CORBA/IDL clients involves an Object Request Broker (ORB) and a compiler that creates an interoperating language called IDL. C, C++, and COBOL are examples of languages that ORBs may compile into IDL. A CORBA programmer can use the interfaces of the CORBA Interface Definition Language (IDL) to enable CORBA objects to be defined, implemented, and accessed from the Java programming language. The following sections provide information on how to develop clients for heterogeneous distributed applications:
Using RMI-IIOP with a CORBA/IDL client enables interoperability between non-Java clients and Java objects. If you have existing CORBA applications, you should program according to the RMI-IIOP with CORBA/IDL client model. Basically, you will be generating IDL interfaces from Java. Your client code will communicate with WebLogic Server through these IDL interfaces. This is basic CORBA programming.
In CORBA, interfaces to remote objects are described in a platform-neutral interface definition language (IDL). To map the IDL to a specific language, you compile the IDL with an IDL compiler. The IDL compiler generates a number of classes such as stubs and skeletons that the client and server use to obtain references to remote objects, forward requests, and marshall incoming calls. Even with IDL clients it is strongly recommended that you begin programming with the Java remote interface and implementation class, then generate the IDL to allow interoperability with WebLogic and CORBA clients, as illustrated in the following sections. Writing code in IDL that can be then reverse-mapped to create Java code is a difficult and bug-filled enterprise, and BEA does not recommend it.
In WebLogic RMI, interfaces to remote objects are described in a Java remote interface that extends
java.rmi.Remote. The Java-to-IDL mapping specification defines how an IDL is derived from a Java remote interface. In the WebLogic RMI over IIOP implementation, you run the implementation class through the WebLogic RMI compiler or WebLogic EJB compiler with the
-idl option. This process creates an IDL equivalent of the remote interface. You then compile the IDL with an IDL compiler to generate the classes required by the CORBA client.
The client obtains a reference to the remote object and forwards method calls through the stub. WebLogic Server implements a
CosNaming service that parses incoming IIOP requests and dispatches them directly into the RMI runtime environment.
The Objects-by-Value specification allows complex data types to be passed between the two programming languages involved. In order for an IDL client to support Objects-by-Value, you develop the client in conjunction with an Object Request Broker (ORB) that supports Objects-by-Value. To date, relatively few ORBs support Objects-by-Value correctly.
When developing an RMI over IIOP application that uses IDL, consider whether your IDL clients will support Objects-by-Value, and design your RMI interface accordingly. If your client ORB does not support Objects-by-Value, you must limit your RMI interface to pass only other interfaces or CORBA primitive data types. The following table lists ORBs that BEA Systems has tested with respect to Objects-by-Value support:
For more information on Objects-by-Value, see "Limitations of Passing Objects by Value" in Programming WebLogic RMI.
The required stub classes will be generated when you compile the IDL file. For general information on the these compilers, refer to "Understanding WebLogic RMI and Programming WebLogic Enterprise JavaBeans. Also reference the Java IDL specification at Java Language Mapping to OMG IDL Specification.
The compiler generates the IDL file within sub-directories of the
idlDirectoy according to the package of the implementation class. For example, the preceding command generates a
Hello.idl file in the
/IDL/rmi_iiop directory. If the
idlDirectory option is not used, the IDL file is generated relative to the location of the generated stub and skeleton classes.
The IDL file generated by the WebLogic compilers contains the directives:
#include orb.idl. This IDL file should be provided by your ORB vendor. An
orb.idl file is shipped in the
/lib directory of the WebLogic distribution. This file is only intended for use with the ORB included in the JDK that comes with WebLogic Server.
IDL clients are pure CORBA clients and do not require any WebLogic classes. Depending on your ORB vendor, additional classes may be generated to help resolve, narrow, and obtain a reference to the remote class. In the following example of a client developed against a VisiBroker 4.1 ORB, the client initializes a naming context, obtains a reference to the remote object, and calls a method on the remote object.
Notice that before obtaining a naming context, initial references were resolved using the standard Object URL (CORBA/IIOP 2.4.2 Specification, section 13.6.7). Lookups are resolved on the server by a wrapper around JNDI that implements the COS Naming Service API.