KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > load > simple > Server


1 package test.load.simple;
2
3 import java.io.*;
4
5 import org.omg.CORBA.*;
6 import org.omg.PortableServer.*;
7
8
9 public class Server
10 {
11     public static void main(String JavaDoc[] args)
12     {
13         if( args.length != 1 )
14     {
15             System.out.println(
16                 "Usage: jaco test.load.simple.Server <ior_file>");
17             System.exit( 1 );
18         }
19
20         try
21         {
22             //init ORB
23
ORB orb = ORB.init( args, null );
24
25         //init POA
26
POA poa =
27                 POAHelper.narrow( orb.resolve_initial_references( "RootPOA" ));
28
29         poa.the_POAManager().activate();
30
31             // create a GoodDay object
32
GoodDayImpl goodDayImpl = new GoodDayImpl( "" );
33     
34             // create the object reference
35
org.omg.CORBA.Object JavaDoc obj =
36                 poa.servant_to_reference( goodDayImpl );
37
38             PrintWriter pw =
39                 new PrintWriter( new FileWriter( args[ 0 ] ));
40
41             // print stringified object reference to file
42
pw.println( orb.object_to_string( obj ));
43             
44             pw.flush();
45             pw.close();
46     
47             // wait for requests
48
orb.run();
49         }
50         catch( Exception JavaDoc e )
51         {
52             System.out.println( e );
53         }
54     }
55 }
56
Popular Tags