1 package demo.interceptors; 2 3 import org.omg.CosNaming.*; 4 5 public class Client 6 { 7 public static void main(String args[]) 8 { 9 try 10 { 11 java.util.Properties props = new java.util.Properties (); 12 props.put 13 ("org.omg.PortableInterceptor.ORBInitializerClass.ForwardInit", 14 "demo.interceptors.ClientInitializer"); 15 16 MyServer grid; 17 org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args,props); 18 19 NamingContextExt nc = NamingContextExtHelper.narrow 20 (orb.resolve_initial_references("NameService")); 21 22 grid = MyServerHelper.narrow(nc.resolve(nc.to_name("grid1.example"))); 23 24 short x = grid.height(); 25 System.out.println("Height = " + x); 26 27 short y = grid.width(); 28 System.out.println("Width = " + y); 29 30 x -= 1; 31 y -= 1; 32 33 System.out.println("Old value at (" + x + "," + y +"): " + grid.get( x,y)); 34 System.out.println("Setting (" + x + "," + y +") to 470.11"); 35 36 grid.set( x, y, new java.math.BigDecimal ("470.11")); 37 38 System.out.println("New value at (" + x + "," + y +"): " + grid.get( x,y)); 39 40 try 41 { 42 grid.opWithException(); 43 } 44 catch (demo.interceptors.MyServerPackage.MyException ex) 45 { 46 System.out.println("MyException, reason: " + ex.why); 47 } 48 49 grid._release(); 50 System.out.println("done. "); 51 52 53 } 54 catch (Exception e) 55 { 56 e.printStackTrace(); 57 58 if (e instanceof org.omg.CosNaming.NamingContextPackage.NotFound ) 59 System.out.println("Reason: " + 60 ((org.omg.CosNaming.NamingContextPackage.NotFound ) e).why.value()); 61 } 62 } 63 } 64 65 66 | Popular Tags |