Yurttas/PL/OOL/Java/F/08/02/01/00/InventoryServer00.java
Jump to navigation
Jump to search
1// The package containing our stubs.
2import Inventory00.*;
3
4// InventoryServer00 will use the naming service.
5import org.omg.CosNaming.*;
6
7// The package containing special exceptions thrown by the name service.
8import org.omg.CosNaming.NamingContextPackage.*;
9
10// All CORBA applications need these classes.
11import org.omg.CORBA.*;
12
13import org.omg.PortableServer.*;
14
15public class InventoryServer00 {
16
17 public static void main(String args[]) {
18 try {
19 // create and initialize the ORB
20 ORB orb = ORB.init(args, null);
21
22 // get reference to rootpoa & activate the POAManager
23 POA rootpoa = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
24 rootpoa.the_POAManager().activate();
25
26 // create servant and register it with the ORB
27 InventoryServant00 inventoryServant = new InventoryServant00();
28
29 //inventoryServant.setORB(orb);
30
31 org.omg.CORBA.Object ref = rootpoa.servant_to_reference(inventoryServant);
32 Inventory inventoryRef = InventoryHelper.narrow(ref);
33
34 // Get the root naming context
35 org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService");
36 NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);
37
38 // Bind the object reference in naming
39 String name = "Inventory00";
40 NameComponent path[] = ncRef.to_name(name);
41 ncRef.rebind(path, inventoryRef);
42 orb.run();
43 }
44 catch(Exception e) {
45 System.err.println("ERROR: " + e);
46 e.printStackTrace(System.out);
47 }
48 }
49
50}