Programming Stand-alone Clients

     Previous  Next    Open TOC in new window  Open Index in new window  View as PDF - New Window  Get Adobe Reader - New Window
Content starts here

Developing Clients for CORBA Objects

The following sections provide information on how to use the CORBA API:

 


Enhancements to and Limitations of CORBA Object Types

The RMI-IIOP runtime is extended to support all CORBA object types (as opposed to RMI valuetypes) and CORBA stubs. Enhancements include:

CORBA Object Type support has the following limitations:

 


Making Outbound CORBA Calls: Main Steps

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

This section provides examples of several mechanisms to access the WebLogic ORB. 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.

Listing 10-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.

Listing 10-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.

Listing 10-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 hosting 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:

Listing 10-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".


  Back to Top       Previous  Next