| The package path diagram for the CORBA client file goes as:   
               javatech|
 |__ cor19
 |
 |__ client
 
 The code for the client classs is shown here.   
              
                 
                  | Client.java |   
                  |  package 
                      javatech.cor19.client;
 // import all the IDL-generated classes
 import javatech.cor19.server.*;
 
 // import required CORBA packages
 import org.omg.CORBA.*;
 import org.omg.CosNaming.*;
 import org.omg.CosNaming.NamingContextPackage.*;
 import org.omg.PortableServer.*;
 
 public class Client
 {
 public static void main (String[] args) {
 try {
 // Create and initialize 
                      the ORB
 ORB orb = ORB.init(args, 
                      null);
 
 // Get the root naming 
                      context
 org.omg.CORBA.Object 
                      objRef =
 orb.resolve_initial_references 
                      ("NameService");
 
 // Use NamingContextExt 
                      instead of NamingContext. This is
 // part of the Interoperable 
                      naming Service.
 NamingContextExt ncRef 
                      = NamingContextExtHelper.narrow (objRef);
 
 // Get a Cor19Example 
                      from the name server.
 String name = "Cor19";
 Cor19Example cor19 =
 Cor19ExampleHelper.narrow 
                      (ncRef.resolve_str (name));
 
 // Call method1() and 
                      add() methods on it.
 cor19.method1 ("Hello");
 int result = cor19.add 
                      (4, 9);
 System.err.println ("add(4,9) 
                      returns " + result);
 
 // Try getting and setting 
                      the huh and hah attributes.
 System.err.println ("hah() 
                      = " + cor19.hah());
 System.err.println ("Before 
                      setting, huh() = " + cor19.huh());
 cor19.huh (19);
 System.err.println ("After 
                      setting, huh() = " + cor19.huh());
 
 // Create and populate 
                      a CustomData object.
 CustomData cd = new 
                      CustomData ();
 cd.someFloatValue = 
                      12.0f;
 cd.someIntegerValue 
                      = -13;
 // Creata a CustomDataHolder 
                      to hold the CustomData.
 CustomDataHolder cdh 
                      = new CustomDataHolder (cd);
 System.err.println ("Before 
                      calling demo():" +
 "\ncd.someFloatValue 
                      = " + cd.someFloatValue +
 "\ncd.someIntegerValue 
                      = " + cd.someIntegerValue);
 // Call demo() to manipulate 
                      the CustomData within the (inout)
 // CustomDataHolder 
                      parameter.
 cor19.demo (cdh);
 // Retrieve and print 
                      the modified CustomData from the holder.
 cd = cdh.value;
 System.err.println ("After 
                      demo():" +
 "\ncd.someFloatValue 
                      = " + cd.someFloatValue +
 "\ncd.someIntegerValue 
                      = " + cd.someIntegerValue);
 }
 catch (Exception e) {
 e.printStackTrace (System.err);
 }
 } // main
 } // class Client
 |      Most recent update: Oct. 13, 2005 |