Accessing WebLogic Server objects from a CORBA client through delegation
IntroductionAs 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.
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.
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 { super(); } 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"); delegate.bar(); System.out.println("delegate Foo.bar 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(); fooTie.setTarget(foo); orb.connect(fooTie); // 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:"); e.printStackTrace(); } } } |
|
Copyright © 2000 BEA Systems, Inc. All rights reserved.
|