com.ibm.websphere.samples.plantsbywebsphereejb
Class ShoppingCartBean

java.lang.Object
  extended by com.ibm.websphere.samples.plantsbywebsphereejb.ShoppingCartBean
All Implemented Interfaces:
ShoppingCart

public class ShoppingCartBean
extends java.lang.Object
implements ShoppingCart

ShoppingCartBean is the implementation class for the ShoppingCart stateful session EJB. ShoppingCartBean implements each of the business methods in the ShoppingCart EJB local interface and each of the EJB lifecycle methods in the javax.ejb.SessionBean interface.

See Also:
ShoppingCart

Constructor Summary
ShoppingCartBean()
           
 
Method Summary
 void addItem(ShoppingCartItem new_item)
          Add an item to the cart.
 void checkInventory(java.util.Collection<ShoppingCartItem> items)
          Method checkInventory.
 void checkInventory(ShoppingCartItem si)
          Method checkInventory.
 OrderInfo createOrder(java.lang.String customerID, java.lang.String billName, java.lang.String billAddr1, java.lang.String billAddr2, java.lang.String billCity, java.lang.String billState, java.lang.String billZip, java.lang.String billPhone, java.lang.String shipName, java.lang.String shipAddr1, java.lang.String shipAddr2, java.lang.String shipCity, java.lang.String shipState, java.lang.String shipZip, java.lang.String shipPhone, java.lang.String creditCard, java.lang.String ccNum, java.lang.String ccExpireMonth, java.lang.String ccExpireYear, java.lang.String cardHolder, int shippingMethod, java.util.Collection<ShoppingCartItem> items)
          Create an order with contents of a shopping cart.
 ShoppingCartContents getCartContents()
          Get the contents of the shopping cart.
 java.util.Collection<ShoppingCartItem> getItems()
          Get the items in the shopping cart.
 float getTotalCost()
          Get the total cost of all items in the shopping cart.
 void removeItem(ShoppingCartItem item)
          Remove an item from the cart.
 void setCartContents(ShoppingCartContents cartContents)
          Create a shopping cart.
 void setItems(java.util.Collection items)
          Set the items in the shopping cart.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ShoppingCartBean

public ShoppingCartBean()
Method Detail

setCartContents

public void setCartContents(ShoppingCartContents cartContents)
Create a shopping cart.

Specified by:
setCartContents in interface ShoppingCart
Parameters:
cartContents - Contents to populate cart with.

addItem

public void addItem(ShoppingCartItem new_item)
Add an item to the cart.

Specified by:
addItem in interface ShoppingCart
Parameters:
new_item - Item to add to the cart.

removeItem

public void removeItem(ShoppingCartItem item)
Remove an item from the cart.

Specified by:
removeItem in interface ShoppingCart
Parameters:
item - Item to remove from cart.

getItems

public java.util.Collection<ShoppingCartItem> getItems()
Get the items in the shopping cart.

Specified by:
getItems in interface ShoppingCart
Returns:
A Collection of ShoppingCartItems.

setItems

public void setItems(java.util.Collection items)
Set the items in the shopping cart.

Specified by:
setItems in interface ShoppingCart
Parameters:
items - A Vector of ShoppingCartItem's.

getTotalCost

public float getTotalCost()
Get the total cost of all items in the shopping cart.

Specified by:
getTotalCost in interface ShoppingCart
Returns:
The total cost of all items in the shopping cart.

checkInventory

public void checkInventory(ShoppingCartItem si)
Method checkInventory. Check the inventory level of a store item. Order additional inventory when necessary.

Specified by:
checkInventory in interface ShoppingCart
Parameters:
si - - Store item

checkInventory

public void checkInventory(java.util.Collection<ShoppingCartItem> items)
Method checkInventory. Check the inventory level all items in the shopping cart. Order additional inventory when necessary

Specified by:
checkInventory in interface ShoppingCart
Parameters:
items -

getCartContents

public ShoppingCartContents getCartContents()
Get the contents of the shopping cart.

Specified by:
getCartContents in interface ShoppingCart
Returns:
The contents of the shopping cart.

createOrder

public OrderInfo createOrder(java.lang.String customerID,
                             java.lang.String billName,
                             java.lang.String billAddr1,
                             java.lang.String billAddr2,
                             java.lang.String billCity,
                             java.lang.String billState,
                             java.lang.String billZip,
                             java.lang.String billPhone,
                             java.lang.String shipName,
                             java.lang.String shipAddr1,
                             java.lang.String shipAddr2,
                             java.lang.String shipCity,
                             java.lang.String shipState,
                             java.lang.String shipZip,
                             java.lang.String shipPhone,
                             java.lang.String creditCard,
                             java.lang.String ccNum,
                             java.lang.String ccExpireMonth,
                             java.lang.String ccExpireYear,
                             java.lang.String cardHolder,
                             int shippingMethod,
                             java.util.Collection<ShoppingCartItem> items)
Create an order with contents of a shopping cart.

Specified by:
createOrder in interface ShoppingCart
Parameters:
customerID - customer's ID
billName - billing name
billAddr1 - billing address line 1
billAddr2 - billing address line 2
billCity - billing address city
billState - billing address state
billZip - billing address zip code
billPhone - billing phone
shipName - shippng name
shipAddr1 - shippng address line 1
shipAddr2 - shippng address line 2
shipCity - shippng address city
shipState - shippng address state
shipZip - shippng address zip code
shipPhone - shippng phone
creditCard - credit card
ccNum - credit card number
ccExpireMonth - credit card expiration month
ccExpireYear - credit card expiration year
cardHolder - credit card holder name
shippingMethod - int of shipping method used
items - vector of StoreItems ordered
Returns:
OrderInfo