KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > connection > timeout > Server


1 package test.connection.timeout;
2
3 import java.io.*;
4 import org.omg.CosNaming.*;
5
6 public class Server
7 {
8     public static void main( String JavaDoc[] args )
9     {
10     org.omg.CORBA.ORB JavaDoc orb = org.omg.CORBA.ORB.init(args, null);
11     try
12     {
13             org.omg.PortableServer.POA JavaDoc poa =
14         org.omg.PortableServer.POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
15
16         poa.the_POAManager().activate();
17         
18         org.omg.CORBA.Object JavaDoc o =
19                 poa.servant_to_reference( new gridImpl() );
20
21         if( args.length == 1 )
22         {
23             // write the object reference to args[0]
24

25         PrintWriter ps =
26                     new PrintWriter(new FileOutputStream(new File( args[0] )));
27         ps.println( orb.object_to_string( o ) );
28         ps.close();
29         }
30         else
31         {
32                 // use the naming service
33

34         NamingContextExt nc =
35                     NamingContextExtHelper.narrow(orb.resolve_initial_references("NameService"));
36         nc.bind( nc.to_name("grid.example"), o);
37         }
38
39             orb.run();
40     }
41     catch ( Exception JavaDoc e )
42     {
43         e.printStackTrace();
44     }
45     }
46 }
47
48
49
Popular Tags