com.ibm.websphere.samples.plantsbywebsphereejb
Class ShoppingCartBean

java.lang.Object
  extended by com.ibm.websphere.samples.plantsbywebsphereejb.ShoppingCartBean
All Implemented Interfaces:
java.io.Serializable, javax.ejb.EnterpriseBean, javax.ejb.SessionBean

public class ShoppingCartBean
extends java.lang.Object
implements javax.ejb.SessionBean

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, ShoppingCartHome, Serialized Form

Constructor Summary
ShoppingCartBean()
           
 
Method Summary
 void addItem(StoreItem new_item)
          Add an item to the cart.
 void checkInventory(StoreItem si)
          Method checkInventory.
 void checkInventory(java.util.Vector items)
          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.Vector items)
          Create an order with contents of a shopping cart.
 void ejbActivate()
          ejbActivate Session EJB lifecycle callback method.
 void ejbCreate()
          Create a shopping cart.
 void ejbCreate(ShoppingCartContents cartContents)
          Create a shopping cart.
 void ejbPassivate()
          ejbPassivate Session EJB lifecycle callback method.
 void ejbPostCreate()
          Create a shopping cart.
 void ejbPostCreate(ShoppingCartContents cartContents)
          ejbPostCreate
 void ejbRemove()
          ejbRemove Session EJB lifecycle callback method.
 ShoppingCartContents getCartContents()
          Get the contents of the shopping cart.
 java.util.Vector getItems()
          Get the items in the shopping cart.
 javax.ejb.SessionContext getSessionContext()
           
 float getTotalCost()
          Get the total cost of all items in the shopping cart.
 void removeItem(StoreItem item)
          Remove an item from the cart.
 void setItems(java.util.Vector items)
          Set the items in the shopping cart.
 void setSessionContext(javax.ejb.SessionContext ctx)
          setSessionContext Session EJB lifecycle callback method to set the EJB sessionContext for this EJB.
 
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

ejbCreate

public void ejbCreate()
               throws javax.ejb.CreateException
Create a shopping cart.

Throws:
javax.ejb.CreateException

ejbPostCreate

public void ejbPostCreate()
                   throws javax.ejb.CreateException
Create a shopping cart.

Throws:
javax.ejb.CreateException

ejbCreate

public void ejbCreate(ShoppingCartContents cartContents)
               throws javax.ejb.CreateException
Create a shopping cart.

Parameters:
cartContents - Contents to populate cart with.
Throws:
javax.ejb.CreateException

ejbPostCreate

public void ejbPostCreate(ShoppingCartContents cartContents)
                   throws javax.ejb.CreateException
ejbPostCreate

Throws:
javax.ejb.CreateException

addItem

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

Parameters:
new_item - Item to add to the cart.

removeItem

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

Parameters:
item - Item to remove from cart.

getItems

public java.util.Vector getItems()
Get the items in the shopping cart.

Returns:
A Vector of StoreItem's.

setItems

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

Parameters:
items - A Vector of StoreItem's.

getTotalCost

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

Returns:
The total cost of all items in the shopping cart.

checkInventory

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

Parameters:
si - - Store item

checkInventory

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

Parameters:
items -

getCartContents

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

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.Vector items)
Create an order with contents of a shopping cart.

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

ejbRemove

public void ejbRemove()
ejbRemove Session EJB lifecycle callback method. This method is empty for Stateless EJB. Called just before the end of life for this object.

Specified by:
ejbRemove in interface javax.ejb.SessionBean

ejbActivate

public void ejbActivate()
ejbActivate Session EJB lifecycle callback method. This method is empty for Stateless EJB.

Specified by:
ejbActivate in interface javax.ejb.SessionBean

ejbPassivate

public void ejbPassivate()
ejbPassivate Session EJB lifecycle callback method. This method is empty for Stateless EJB. Called when the instance is passivated from its "active" state, and releases.

Specified by:
ejbPassivate in interface javax.ejb.SessionBean

setSessionContext

public void setSessionContext(javax.ejb.SessionContext ctx)
setSessionContext Session EJB lifecycle callback method to set the EJB sessionContext for this EJB.

Specified by:
setSessionContext in interface javax.ejb.SessionBean
Parameters:
ctx - javax.ejb.SessionContext The context for this session EJB.

getSessionContext

public javax.ejb.SessionContext getSessionContext()