Yurttas/PL/OOL/Java/F/08/02/01/00/InventoryClient00.java
Jump to navigation
Jump to search
1import Inventory00.*; // The package containing our stubs.
2import org.omg.CosNaming.*; // InventoryClient00 will use the naming service.
3import org.omg.CORBA.*; // All CORBA applications need these classes.
4
5public class InventoryClient00 {
6
7 public static void main(String args[]) {
8 try {
9 // Create and initialize the ORB
10 ORB orb = ORB.init(args, null);
11
12 // Get the root naming context
13 org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService");
14 NamingContext ncRef = NamingContextHelper.narrow(objRef);
15
16 // Resolve the object reference in naming
17 NameComponent nc = new NameComponent("Inventory00", "");
18 NameComponent path[] = {nc};
19 Inventory inventoryRef = InventoryHelper.narrow(ncRef.resolve(path));
20
21 CatalogItem[] rtnItems = inventoryRef.getCatalogItems();
22 CatalogItem item= null;
23
24 for(int i=0, len=rtnItems.length; i<len; i++)
25 System.out.println("CatalogItem = " + rtnItems[i].aCD.title);
26 }
27 catch(Exception e) {
28 System.out.println("ERROR : " + e);
29 e.printStackTrace(System.out);
30 }
31 }
32
33}