KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > imr > Client


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