Package examples.rmi_iiop.hello

Source Code of examples.rmi_iiop.hello.HelloClient

package examples.rmi_iiop.hello;

import java.lang.*;

import org.omg.CosNaming.NameComponent;
import org.omg.CosNaming.NamingContextHelper;
import org.omg.CosNaming.NamingContext;
import org.omg.CORBA.ORB;
import org.omg.CORBA.Object;


/**
* This CORBA client initializes an ORB, obtains a reference to the
* HelloServer, and calls HelloServer methods.
*
* @author Copyright (c) 2000 by BEA Systems, Inc. All Rights Reserved.
*/
final public class HelloClient {
    static String rmiObj = "HelloServer"

  public static void main(String args[]) {
    if (args.length < 1) {
      System.out.println("Usage:  java examples.rmi-iiop.hello.HelloClient "
                         + "serverIOR");
    } else {
    
      // initialize ORB
      ORB  orb = ORB.init(args, null);

      // get WebLogic Server IOR from command line argument
      String ior = args[0];
      org.omg.CORBA.Object obj = orb.string_to_object(ior);

      // obtain naming context for WebLogic Server
      NamingContext nc = NamingContextHelper.narrow(obj);

      NameComponent nComp = new NameComponent(rmiObj, "");
      NameComponent path[] = {nComp};
      try {
        // resolve and narrow to RMI object
        obj = nc.resolve(path);
        HelloWorld hi = HelloWorldHelper.narrow(obj);

        // call method on RMI object
        hi.sayHello();
        System.out.println("Method call completed successfully!");
      } catch (Throwable t) {
        t.printStackTrace();
      }

    }
     
  }

}
TOP

Related Classes of examples.rmi_iiop.hello.HelloClient

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.