KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > trading > client > proxy > ProxyDemo


1
2 // Copyright (C) 1998-1999
3
// Object Oriented Concepts, Inc.
4

5 // **********************************************************************
6
//
7
// Copyright (c) 1997
8
// Mark Spruiell (mark@intellisoft.com)
9
//
10
// See the COPYING file for more information
11
//
12
// **********************************************************************
13

14 package org.jacorb.trading.client.proxy;
15
16 import java.io.*;
17 import java.util.*;
18
19 import org.omg.CORBA.*;
20 import org.omg.PortableServer.*;
21
22 public class ProxyDemo
23 {
24     public static void main(String JavaDoc[] args)
25     {
26         if( args.length != 1 )
27         {
28             usage();
29         }
30
31     String JavaDoc iorfile = args[0];
32
33     // initialize the ORB
34
ORB orb = ORB.init(args, null);
35
36         try
37         {
38             POA poa =
39                 POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
40
41             poa.the_POAManager().activate();
42         }
43         catch(Exception JavaDoc e)
44         {
45             e.printStackTrace();
46         }
47
48     // create the proxy lookup implementation
49
ProxyLookupImpl impl = new ProxyLookupImpl();
50         impl._this_object( orb );
51
52         try
53         {
54             FileOutputStream out = new FileOutputStream(iorfile);
55             PrintWriter pw = new PrintWriter(out);
56             pw.println(orb.object_to_string(impl._this()));
57             pw.flush();
58             out.close();
59         }
60         catch (IOException e)
61         {
62             System.err.println("Unable to write IOR to file " + iorfile);
63             System.exit(1);
64         }
65     
66     orb.run();
67     System.exit(0);
68     }
69
70
71     protected static void usage()
72     {
73     System.err.println("Usage: org.jacorb.trading.client.proxy.ProxyDemo iorfile");
74     System.exit(1);
75     }
76 }
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
Popular Tags