KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > interceptor > client_flow > Client


1 package test.interceptor.client_flow;
2
3 import java.io.*;
4 import org.omg.CORBA.ORB JavaDoc;
5 import org.omg.CORBA.Any JavaDoc;
6 import org.omg.PortableInterceptor.*;
7
8 public class Client
9 {
10     public static ORB JavaDoc orb = null;
11
12     public static void main( String JavaDoc args[] )
13     {
14         if( args.length != 1 )
15     {
16             System.out.println( "Usage: jaco test.interceptor.ctx_passing.Client <ior_file>" );
17             System.exit( 1 );
18         }
19
20         try
21     {
22             File f = new File( args[ 0 ] );
23
24             //check if file exists
25
if( ! f.exists() )
26             {
27                 System.out.println("File " + args[0] +
28                                    " does not exist.");
29                 
30                 System.exit( -1 );
31             }
32             
33             //check if args[0] points to a directory
34
if( f.isDirectory() )
35             {
36                 System.out.println("File " + args[0] +
37                                    " is a directory.");
38                 
39                 System.exit( -1 );
40             }
41
42             System.setProperty( "org.omg.PortableInterceptor.ORBInitializerClass.a",
43                                 "test.interceptor.client_flow.ClientInitializer" );
44             
45             // initialize the ORB.
46
orb = ORB.init( args, null );
47
48             BufferedReader br =
49                 new BufferedReader( new FileReader( f ));
50
51             // get object reference from command-line argument file
52
org.omg.CORBA.Object JavaDoc obj =
53                 orb.string_to_object( br.readLine() );
54
55             br.close();
56
57             TestObject to = TestObjectHelper.narrow( obj );
58             
59             to.foo();
60         }
61         catch( Exception JavaDoc ex )
62     {
63             System.err.println( ex );
64         }
65     }
66 }
67
68
Popular Tags