FileDocCategorySizeDatePackage
Client.javaAPI DocJBoss 4.2.12550Fri Jul 13 20:55:06 BST 2007org.jboss.tutorial.stateful_deployment_descriptor.client

Client

public class Client extends Object
Comment
author
Bill Burke
version
$Revision: 60233 $

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

      InitialContext ctx = new InitialContext();
      ShoppingCart cart = (ShoppingCart) ctx.lookup(ShoppingCart.class.getName());

      System.out.println("Buying 1 memory stick");
      cart.buy("Memory stick", 1);
      System.out.println("Buying another memory stick");
      cart.buy("Memory stick", 1);

      System.out.println("Buying a laptop");
      cart.buy("Laptop", 1);

      System.out.println("Print cart:");
      HashMap<String, Integer> fullCart = cart.getCartContents();
      for (String product : fullCart.keySet())
      {
         System.out.println(fullCart.get(product) + "     " + product);
      }

      System.out.println("Checkout");
      cart.checkout();

      System.out.println("Should throw an object not found exception by invoking on cart after @Remove method");
      try
      {
         cart.getCartContents();
      }
      catch (NoSuchEJBException e)
      {
            System.out.println("Successfully caught no such object exception.");
      }