KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > Map > Server


1 package Map;
2
3 // Server.java
4

5 import java.io.*;
6 import org.omg.PortableServer.*;
7 import org.omg.CosNaming.*;
8
9 public class Server
10 {
11
12     public static void main(String JavaDoc[] args)
13         throws Exception JavaDoc
14     {
15         // Initialize ORB
16
org.omg.CORBA.ORB JavaDoc orb = org.omg.CORBA.ORB.init( args , null );
17
18         // Resolve Root POA
19
POA rootPoa = POAHelper.narrow( orb.resolve_initial_references("RootPOA"));
20         rootPoa.the_POAManager().activate();
21       
22         // Create policies for our persistent POA
23
org.omg.CORBA.Policy JavaDoc[] policies = {
24             rootPoa.create_lifespan_policy(LifespanPolicyValue.PERSISTENT)
25        };
26
27         // Create managerPOA with the right policies
28
POA serverPoa =
29             rootPoa.create_POA("serverPoa", rootPoa.the_POAManager(), policies );
30
31         PointManagerImpl pointManager =
32             new PointManagerImpl("PointManager1", true);
33
34         // Export the newly created object.
35
byte [] oid = serverPoa.activate_object(pointManager);
36         org.omg.CORBA.Object JavaDoc o = serverPoa.id_to_reference( oid );
37
38         // use the naming service
39

40         NamingContextExt nc =
41             NamingContextExtHelper.narrow(orb.resolve_initial_references("NameService"));
42         nc.bind( nc.to_name("PointManager1.example"), o);
43
44         System.out.println("PointManager is ready.");
45
46         // Wait for incoming requests
47
orb.run();
48     
49     }
50
51 }
52
53
Popular Tags