01: package demo.hello;
02:
03: import java.io.*;
04: import org.omg.CORBA.*;
05:
06: public class Client {
07: public static void main(String args[]) {
08: if (args.length != 1) {
09: System.out
10: .println("Usage: jaco demo.hello.Client <ior_file>");
11: System.exit(1);
12: }
13:
14: try {
15: File f = new File(args[0]);
16:
17: //check if file exists
18: if (!f.exists()) {
19: System.out.println("File " + args[0]
20: + " does not exist.");
21:
22: System.exit(-1);
23: }
24:
25: //check if args[0] points to a directory
26: if (f.isDirectory()) {
27: System.out.println("File " + args[0]
28: + " is a directory.");
29:
30: System.exit(-1);
31: }
32:
33: // initialize the ORB.
34: ORB orb = ORB.init(args, null);
35:
36: BufferedReader br = new BufferedReader(new FileReader(f));
37:
38: // get object reference from command-line argument file
39: org.omg.CORBA.Object obj = orb.string_to_object(br
40: .readLine());
41:
42: br.close();
43:
44: // and narrow it to HelloWorld.GoodDay
45: // if this fails, a BAD_PARAM will be thrown
46: GoodDay goodDay = GoodDayHelper.narrow(obj);
47:
48: // invoke the operation and print the result
49: System.out.println(goodDay.hello_simple());
50:
51: // invoke the operation again and print the wide string result
52: System.out
53: .println("wide string: "
54: + goodDay
55: .hello_wide("Hello Wörld, from ß ö 1 2 3 0 *&^%$#@!@"));
56:
57: } catch (Exception ex) {
58: ex.printStackTrace();
59: }
60: }
61: }
|