1 package demo.unions; 2 3 import org.omg.CosNaming.*; 4 5 7 public class Client 8 { 9 public static void main( String [] args ) 10 { 11 try 12 { 13 org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args,null); 14 NamingContextExt nc = 15 NamingContextExtHelper.narrow(orb.resolve_initial_references("NameService")); 16 17 MyServer s = MyServerHelper.narrow(nc.resolve(nc.to_name("union.example"))); 18 19 UnitedColors my_union = new UnitedColors(); 20 UnitedColorsHolder my_union_holder = new UnitedColorsHolder(); 21 22 24 my_union.s("hallo"); 25 s.writeUnion(my_union, my_union_holder); 26 27 29 my_union = my_union_holder.value; 30 31 33 switch (my_union.discriminator().value() ) 34 { 35 case colorT._blue : 36 System.out.println("Blue: " + my_union.s() ); 37 break; 38 case colorT._red : 39 System.out.println("Red: " + my_union.s() ); 40 break; 41 default : 42 System.out.println("default: " + my_union.i() ); 43 } 44 45 String [] strs = {"hello", "world"}; 46 47 my_union.strs( strs ); 48 s.writeUnion(my_union, my_union_holder); 49 50 51 52 Nums n = new Nums(); 53 n.l(4711); 54 s.write2ndUnion(n); 55 56 } 57 catch (Exception se) 58 { 59 se.printStackTrace(); 60 } 61 } 62 } 63 64 65 | Popular Tags |