FileDocCategorySizeDatePackage
BookMapBookServiceClient.javaAPI DocExample2000Fri Sep 20 12:36:24 BST 2002ora.jwsnut.chapter2.client

BookMapBookServiceClient

public class BookMapBookServiceClient extends Object

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

        
        try {
            if (args.length != 1) {
                usage();
            }
            
            // Get a reference to the stub and set the service address
            BookService_Impl service = new BookService_Impl();
            BookQuery bookQuery = (BookQuery)service.getBookQueryPort();
            ((Stub)bookQuery )._setProperty(Stub.ENDPOINT_ADDRESS_PROPERTY, args[0]);
            
            // Perform the RPC and print the results          
            HashMap map = bookQuery.getBookMap();
            Iterator iter = map.entrySet().iterator();
            while (iter.hasNext()) {
                Map.Entry entry = (Map.Entry)iter.next();
                BookInfo info = (BookInfo)entry.getValue();
                System.out.println("KEY: [" + entry.getKey() + "], value = "+
                                info.getTitle() + " by " +
                                info.getAuthor() + ", edited by " +
                                info.getEditor() + ", price USD " +
                                info.getPrice());
            }
            System.exit(0);
        } catch (Throwable t) {
            System.out.println("CLASS: " + t.getClass().getName() + "\n\n");
            System.out.println(t.getMessage());
            t.printStackTrace(System.out);
        }
    
private static voidusage()

        System.err.println("Usage: BookMapBookServiceClient address");
        System.exit(1);