1 7 package org.jboss.tutorial.stateful.bean; 8 9 import java.io.Serializable ; 10 import java.util.HashMap ; 11 import javax.ejb.Remove ; 12 import javax.ejb.Stateful ; 13 import javax.ejb.Remote ; 14 15 16 @Stateful 17 @Remote (ShoppingCart.class) 18 public class ShoppingCartBean implements ShoppingCart, Serializable 19 { 20 private HashMap <String , Integer > cart = new HashMap <String , Integer >(); 21 22 public void buy(String product, int quantity) 23 { 24 if (cart.containsKey(product)) 25 { 26 int currq = cart.get(product); 27 currq += quantity; 28 cart.put(product, currq); 29 } 30 else 31 { 32 cart.put(product, quantity); 33 } 34 } 35 36 public HashMap <String , Integer > getCartContents() 37 { 38 return cart; 39 } 40 41 @Remove 42 public void checkout() 43 { 44 System.out.println("To be implemented"); 45 } 46 } 47 | Popular Tags |