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