KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > tutorial > entity > client > Client


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7 package org.jboss.tutorial.entity.client;
8
9
10 import org.jboss.tutorial.entity.bean.LineItem;
11 import org.jboss.tutorial.entity.bean.Order;
12 import org.jboss.tutorial.entity.bean.ShoppingCart;
13
14 import javax.naming.InitialContext JavaDoc;
15
16 /**
17  * Comment
18  *
19  * @author <a HREF="mailto:bill@jboss.org">Bill Burke</a>
20  * @version $Revision: 1.1.6.3 $
21  */

22 public class Client
23 {
24    public static void main(String JavaDoc[] args) throws Exception JavaDoc
25    {
26       InitialContext JavaDoc ctx = new InitialContext JavaDoc();
27       ShoppingCart cart = (ShoppingCart) ctx.lookup(ShoppingCart.class.getName());
28
29       System.out.println("Buying 2 memory sticks");
30       cart.buy("Memory stick", 2, 500.00);
31       System.out.println("Buying a laptop");
32       cart.buy("Laptop", 1, 2000.00);
33
34       System.out.println("Print cart:");
35       Order order = cart.getOrder();
36       System.out.println("Total: $" + order.getTotal());
37       for (LineItem item : order.getLineItems())
38       {
39          System.out.println(item.getQuantity() + " " + item.getProduct() + " " + item.getSubtotal());
40       }
41
42       System.out.println("Checkout");
43       cart.checkout();
44
45    }
46 }
47
Popular Tags