6 Developing Clients for CORBA Objects

Learn how to use the CORBA API to develop clients using CORBA objects.

This chapter includes the following sections:

Enhancements and Limitations of CORBA Object Types

Learn about the enhancements and limitations of CORBA. The RMI-IIOP run time is extended to support all CORBA object types (as opposed to RMI valuetypes) and CORBA stubs.

Enhancements include:

  • Support for out and in-out parameters

  • Support for a call to a CORBA service from WebLogic Server using transactions and security

  • Support for a WebLogic ORB hosted in JNDI rather than an instance of the JDK ORB used in previous releases

CORBA Object Type support has the following limitations:

  • It should not be used to make calls from one WebLogic Server instance to another WebLogic Server instance.

  • Clustering is not supported. If a clustered object reference is detected, WebLogic Server uses internal RMI-IIOP support to make the call. Out and in-out parameters will not be supported.

  • CORBA services created by ORB.connect() result in a second object hosted inside the server. It is important that you use ORB.disconnect()to remove the object when it is no longer needed.

Making Outbound CORBA Calls: Main Steps

Learn how to implement a development model for customers using CORBA to make outbound calls.

Follow these steps to implement a typical development model for customers wanting to use the CORBA API for outbound calls.

  1. Generate CORBA stubs from IDL using idlj, the JDKs IDL compiler.

  2. Compile the stubs using javac.

  3. Build EJB(s) including the generated stubs in the jar.

  4. Use the WebLogic ORB hosted in JNDI to reference the external service.

Using the WebLogic ORB Hosted in JNDI

Learn about various mechanisms to access the WebLogic ORB with the help of examples provided in this section. Each mechanism achieves the same effect and their constituent components can be mixed to some degree.

The object returned by narrow() will be a CORBA stub representing the external ORB service and can be invoked as a normal CORBA reference. In the following code examples it is assumed that the CORBA interface is called MySvc and the service is hosted at "where" in a foreign ORB's CosNaming service located at exthost:extport:

ORB from JNDI

The following code listing provides information on how to access the WebLogic ORB from JNDI.

Example 6-1 Accessing the WebLogic ORB from JNDI

.
.
.
ORB orb = (ORB)new InitialContext().lookup("java:comp/ORB");
NamingContext nc = NamingContextHelper.narrow(orb.string_to_object("corbaloc:iiop:exthost:extport/NameService"));
MySvc svc = MySvcHelper.narrow( nc.resolve(new NameComponent[] { new NameComponent("where", "")}));
.
.
.

Direct ORB creation

The following code listing provides information on how to create a WebLogic ORB.

Example 6-2 Direct ORB Creation

.
.
.
ORB orb = ORB.init();
MySvc svc = MySvcHelper.narrow(orb.string_to_object("corbaname:iiop:exthost:extport#where"));
.
.
.

Using JNDI

The following code listing provides information on how to access the WebLogic ORB using JNDI.

Example 6-3 Accessing the WebLogic ORB Using JNDI

.
.
.
MySvc svc = MySvcHelper.narrow(new InitialContext().lookup("corbaname:iiop:exthost:extport#where"));
.
.
.

The WebLogic ORB supports most client ORB functions, including DII (Dynamic Invocation Interface). To use this support, you must not instantiate a foreign ORB inside the server. This will not yield any of the integration benefits of using the WebLogic ORB.

Supporting Inbound CORBA Calls

WebLogic Server also provides basic support for inbound CORBA calls as an alternative to host an ORB inside the server. To do this, you use ORB.connect() to publish a CORBA server inside WebLogic Server by writing an RMI-object that implements a CORBA interface.

Given the MySVC examples above:

Example 6-4 Supporting Inbound CORBA Calls

.
.
.
class MySvcImpl implements MvSvcOperations, Remote
{
public void do_something_remote() {}

public static main() {
MySvc svc = new MySvcTie(this);
InitialContext ic = new InitialContext();
((ORB)ic.lookup("java:comp/ORB")).connect(svc);
ic.bind("where", svc);
}
}
.
.
.

When registered as a startup class, the CORBA service will be available inside the WebLogic Server CosNaming service at the location "where".