KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > demo > interceptors > Server2


1 package demo.interceptors;
2
3 import java.io.*;
4 import org.omg.CosNaming.*;
5
6 public class Server2
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 = poa.servant_to_reference(new gridImpl());
19
20             if( args.length == 1 )
21             {
22                 // write the object reference to args[0]
23

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