Here is an exapmle code of Java ORB using IIOP Connect

This example will invoke the methods of CountServer object.

You can find CountServer's isl/server file here


import java.io.*;

public class IluProxyCounterExample
{
  public static void main(String args[])
  {
    try{
      if (args.length == 0){
        System.out.println("usage:");
        System.out.println("  java IluProxyTest <IOR of IluProxyServer>");
      }

      //
      // initialization of ORB
      //
      System.out.println("Initializing the ORB");
      CORBA.ORB orb = CORBA.ORB.init();

      //
      // bind to the IIOP connect proxy object running on the server side
      // Note: pass the IOR of this object as an argument to this program.
      //
      System.out.println("Binding to Proxy Object");
      CORBA.Object object = orb.string_to_object(args[0]);
      IluProxy.ORBProxy proxy = IluProxy.ORBProxy_var.narrow(object);
      
      //
      // Lookup an object in the DL world
      //
      IluProxy.IluObject obj = proxy.bind("CountServer");
      
      //
      // Prepare dynamic method to invoke
      // e.g. setSum(0), getSum(), increment()
      //
      IluProxy.Request setSum = proxy.request(obj, "setSum");
      IluProxy.Any arg = new IluProxy.Any(0);
      setSum.add_arg("", arg);
      IluProxy.Request getSum = proxy.request(obj, "getSum");
      IluProxy.Request incr = proxy.request(obj, "increment");


      //
      // invoke setSum(0) method
      //
      setSum.invoke();
      System.out.println("Set counter to 0.");

      // for perfomance check
      long startTime = System.currentTimeMillis();
      long stopCount = 100;

      System.out.println("Running..");

      //
      // invoke increment() method (100 times)
      //
      for ( int i = 0 ; i < stopCount ; i++ {
        incr.invoke();
      }
      
      // for performance check
      long stopTime = System.currentTimeMillis();

      //
      // invoke getSum() method
      //
      getSum.invoke();
      IluProxy.Any result = getSum.result();

      System.out.println("Avg Ping = "
            + Float.toString((float)(stopTime - startTime)/result.to_short())
            + " msecs")

      //
      // remove Request objects from server
      //
      proxy.delete(setSum);
      proxy.delete(getSum);
      proxy.delete(incr);

    }catch(CORBA.SystemException e){
      System.err.println("SystemException " + e);
    }catch(IluProxy.IluProxyException e){
      System.err.println("IluProxy Exception " + e);
    }
  }
}