1/**
2 * Copyright(C) 2000
3 * All Rights Reserved. Salih Yurttas, ZCubes, BitsOfCode Software Systems, Inc..
4 *
5 * Permission to use, copy, modify, and distribute this
6 * software and its documentation for EDUCATIONAL purposes
7 * and without fee is hereby granted provided that this
8 * copyright notice appears in all copies.
9 *
10 * @date : July 1, 2000.
11 * @authorĀ : Salih Yurttas.
12 */
13
14
15import PhoneBook00.*; // The package containing our stubs.
16
17import org.omg.CosNaming.*; // HelloClient will use the naming service.
18import org.omg.CORBA.*; // All CORBA applications need these classes.
19
20public class PhoneBookClientA {
21
22 public static void main(String args[]) {
23 try {
24 // Create and initialize the ORB
25 ORB orb = ORB.init(args, null);
26
27 // Get the root naming context
28 org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService");
29 NamingContext ncRef = NamingContextHelper.narrow(objRef);
30
31 // Resolve the object reference in naming
32 NameComponent nc = new NameComponent("PhoneBook", "");
33 NameComponent path[] = {nc};
34 PhoneBook phoneBookRef = PhoneBookHelper.narrow(ncRef.resolve(path));
35
36 // Call the Hello server object and print results
37 PhoneBookEntry result = phoneBookRef.lookUpNumber("Julie Nelson");
38
39 if(result.name.equals("")||result.phoneNumber.equals("")) {
40 System.out.println("Name is not in the phonebook\n");
41 System.exit(0);
42 }
43 if(result!=null)
44 System.out.println("The number is " + result.phoneNumber);
45
46 /* PhoneBookEntry[] results = phoneBookRef.list();
47 for(int i=0; i<results.length; i++)
48 System.out.println("Name is "+results[i].name); */
49 }
50 catch(Exception e) {
51 System.out.println("ERRORĀ : " + e);
52 e.printStackTrace(System.out);
53 }
54 }
55
56}