Jump to Real's How-to Main page

Call Corba (PB) component from Java

// inter-component, on the same server
Properties props = new Properties();
props.put("org.omg.CORBA.ORBClass","com.sybase.CORBA.ORB");
ORB orb = ORB.init((String[])null,props);
MyPack.MyComponent stub =
  MyPack.MyComponentHelper.narrow
     (orb.string_to_object("MyPack/MyComponent"));

// same server but to identify ourself
Properties p = new Properties();
p.put("org.omg.CORBA.ORBClass", "com.sybase.CORBA.ORB");
               
p.put(javax.naming.Context.SECURITY_PRINCIPAL, 
   request.getParameter("user"));    
p.put(javax.naming.Context.SECURITY_CREDENTIALS, 
   request.getParameter("pwd")); 
MyPack.MyComponent stub =
  MyPack.MyComponentHelper.narrow(orb.string_to_object
     ("MyPack/MyComponent"));

// different server
String[] args={""};
java.util.Properties p = new java.util.Properties();    
p.put("org.omg.CORBA.ORBClass", "com.sybase.CORBA.ORB");
org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args, p);
org.omg.CORBA.Object ior =
     orb.string_to_object("iiop://localhost:9000");
SessionManager.Manager manager =
   SessionManager.ManagerHelper.narrow(ior);
SessionManager.Session session = manager.createSession
   ("jagadmin", "");
SessionManager.Factory factory =
   SessionManager.FactoryHelper.narrow(session.lookup
     ("MyPack/MyComponent"));
MyPack.MyComponent stub =
   MyPack.MyComponentHelper.narrow(factory.create());

If you find this article useful, consider making a small donation
to show your supportfor this Web site and its content.

Written and compiled by Réal Gagnon ©1998-2005
[ home ]