KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > demo > value > idl > Server


1 package demo.value.idl;
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: java demo.value.idl.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             ValueServerImpl s = new ValueServerImpl();
32     
33             // create the object reference
34
org.omg.CORBA.Object JavaDoc obj = poa.servant_to_reference( s );
35
36             PrintWriter pw =
37                 new PrintWriter( new FileWriter( args[ 0 ] ));
38
39             // print stringified object reference to file
40
pw.println( orb.object_to_string( obj ));
41             
42             pw.flush();
43             pw.close();
44     
45             // wait for requests
46
orb.run();
47         }
48         catch( Exception JavaDoc e )
49         {
50             System.out.println( e );
51         }
52     }
53 }
54
Popular Tags