KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > demo > poa_monitor > root_poa > Server


1 package demo.poa_monitor.root_poa;
2
3 import demo.poa_monitor.foox.*;
4 import org.omg.CORBA.ORB JavaDoc;
5 import org.omg.PortableServer.*;
6 import org.omg.CosNaming.*;
7 import java.io.*;
8
9 public class Server
10 {
11     public static String JavaDoc description = "Root-POA only";
12
13     public static void main(String JavaDoc[] args)
14     {
15         try
16         {
17             ORB JavaDoc orb = org.omg.CORBA.ORB.init(args, null);
18             POA rootPOA = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
19             POAManager poaMgr = rootPOA.the_POAManager();
20
21             FooFactoryImpl servant = new FooFactoryImpl();
22             FooFactory reference = servant._this(orb);
23
24             /*
25             PrintWriter pw = new PrintWriter(new FileWriter("../fooFactory.ior"));
26             pw.println(orb.object_to_string(reference));
27             pw.close();
28             */

29             // CORBA compliant:
30
NamingContextExt nc = NamingContextExtHelper.narrow(orb.resolve_initial_references("NameService"));
31             NameComponent [] name = new NameComponent[1];
32             name[0] = new NameComponent("FooFactory", "service");
33             nc.bind(name, reference);
34
35             poaMgr.activate();
36             System.out.println("[ Server ready ]");
37             orb.run();
38                                     
39         }
40         catch (Exception JavaDoc e)
41         {
42             e.printStackTrace();
43         }
44     }
45 }
46
47
48
Popular Tags