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