KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > demo > grid > TieServer


1 package demo.grid;
2
3 import java.io.*;
4 import org.omg.CosNaming.*;
5
6 public class TieServer
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         org.omg.CORBA.Object JavaDoc o =
17                 poa.servant_to_reference( new MyServerPOATie(new gridOperationsImpl()) );
18
19         poa.the_POAManager().activate();
20
21         if( args.length == 1 )
22         {
23         // write the object reference to args[0]
24

25         PrintWriter ps = new PrintWriter(new FileOutputStream(new File( args[0] )));
26         ps.println( orb.object_to_string( o ) );
27         ps.close();
28         }
29         else
30         {
31         NamingContextExt nc =
32                     NamingContextExtHelper.narrow(orb.resolve_initial_references("NameService"));
33         NameComponent [] name = new NameComponent[1];
34         name[0] = new NameComponent("grid", "example");
35         nc.bind( name, o );
36         }
37     }
38     catch ( Exception JavaDoc e )
39     {
40         e.printStackTrace();
41     }
42     orb.run();
43     }
44 }
45
46
47
48
49
Popular Tags