BEA Logo BEA WebLogic Server Release 5.0

  Corporate Info  |  News  |  Solutions  |  Products  |  Partners  |  Services  |  Events  |  Download  |  How To Buy

Accessing WebLogic Server objects from a CORBA client through delegation

Code example
Other related documents
Writing a server-side application
Using WebLogic RMI over IIOP


As described in Using WebLogic RMI over IIOP, WebLogic Server provides services that allow CORBA clients to access RMI remote objects. As an alternative method, you can also host a CORBA ORB (Object Request Broker) in WebLogic Server and delegate incoming and outgoing messages to allow corba clients to indirectly invoke any object that can be bound in the server. This document provides an overview of how this is done.



There are a number of objects that must work together to be able to delegate CORBA calls to an object hosted by WebLogic Server. First, you must have an ORB that is co-located with the JVM that is running WebLogic Server. To accomplish this, you can create a startup class that creates and initializes an ORB. You also need an object that will accept incoming messages from the ORB. To create this object, you must create an IDL (Interface Definition Language). Compiling the IDL will result in a number of classes, one of which will be the Tie class. Tie classes are used on the server side to process incoming calls, and dispatch the calls to the proper implementation class. The implementation class is responsible for connecting to the server, looking up the appropriate object, and invoking methods on the object on behalf of the CORBA client.

The following is a diagram of a CORBA client invoking an EJBean by delegating the call to an implementation class that connects to the server and operates upon the EJBean.

Using a similar architecture, the reverse situation will also work. You can have a startup class that brings up an ORB and obtains a reference to the CORBA implementation object of interest. This class can make itself available to other WebLogic objects throught the JNDI tree and delegate the appropriate calls to the CORBA object.


Code example

The following code example creates an implementation class that connects to the server, looks up the Foo object in the JNDI tree, and calls the bar method. This object is also a startup class that is responsible for initializing the CORBA environment by:
  • creating the ORB
  • creating the Tie object
  • associating the implementation class with the Tie object
  • registering the Tie object with the ORB
  • binding the Tie object within the ORB's naming service
For more information on how to implement a startup class, see Writing a server-side application.

  import org.omg.CosNaming.*;
  import org.omg.CosNaming.NamingContextPackage.*;
  import org.omg.CORBA.*;
  import java.rmi.*;
  import javax.naming.*;
  import weblogic.jndi.Environment;

  public class FooImpl implements Foo

    public FooImpl() throws RemoteException {

    public void bar() throws RemoteException, NamingException {
      // look up and call the instance to delegate the call to...
      weblogic.jndi.Environment env = new Environment();
      Context ctx = env.getInitialContext();
      Foo delegate = (Foo)ctx.lookup("Foo");;
      System.out.println("delegate called!");


    public static void main(String args[]) {
      try {
	FooImpl foo = new FooImpl();

	// Create and initialize the ORB
	ORB orb = ORB.init(args, null);

	// Create and register the tie with the ORB
	_FooImpl_Tie fooTie = new _FooImpl_Tie();

	// Get the naming context
	org.omg.CORBA.Object o = orb.resolve_initial_references("NameService");
	NamingContext ncRef = NamingContextHelper.narrow(o);

	// Bind the object reference in naming
	NameComponent nc = new NameComponent("Foo", "");
	NameComponent path[] = {nc};
	ncRef.rebind(path, fooTie);

	System.out.println("FooImpl created and bound in the ORB registry.");

      catch (Exception e) {
	System.out.println("FooImpl.main: an exception occurred:");


Copyright © 2000 BEA Systems, Inc. All rights reserved.
Required browser: Netscape 4.0 or higher, or Microsoft Internet Explorer 4.0 or higher.