ejb.reserving
Class ReserveAndBuyBean

java.lang.Object
  |
  +--ejb.reserving.ReserveAndBuyBean
All Implemented Interfaces:
EnterpriseBean, Serializable, SessionBean

public class ReserveAndBuyBean
extends Object
implements SessionBean

This is the bean class for the ReserveAndBuy stateless session bean. For information about the ReserveAndBuy component, its behavior and exception handling, please see ReserveAndBuy.

Version:
1.0
Author:
Team Two: Matthew Bass, Vijay Sai, Mannik Bhojwani, Paulo Merson
See Also:
ReserveAndBuy, Serialized Form

Field Summary
 SessionContext context
           
 
Constructor Summary
ReserveAndBuyBean()
           
 
Method Summary
 void buyTickets(int reservationId, CreditCardValue creditCard, long transId)
           
 void cancelReservation(int reservationId, long transId)
          Removes a reservation from the database.
 void ejbActivate()
           
 void ejbCreate()
           
 void ejbPassivate()
           
 void ejbRemove()
           
 int makeReservation(FlightSelection selection, String[] passengers, CreditCardValue creditCard, long transId)
          Adds a reservation to the database.
 ReservationValue readReservation(int reservationId)
           
 void setSessionContext(SessionContext context)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

context

public SessionContext context
Constructor Detail

ReserveAndBuyBean

public ReserveAndBuyBean()
Method Detail

setSessionContext

public void setSessionContext(SessionContext context)
                       throws EJBException,
                              RemoteException
Specified by:
setSessionContext in interface SessionBean
See Also:
SessionBean.setSessionContext(javax.ejb.SessionContext)

ejbRemove

public void ejbRemove()
               throws EJBException,
                      RemoteException
Specified by:
ejbRemove in interface SessionBean
See Also:
SessionBean.ejbRemove()

ejbActivate

public void ejbActivate()
                 throws EJBException,
                        RemoteException
Specified by:
ejbActivate in interface SessionBean
See Also:
SessionBean.ejbActivate()

ejbPassivate

public void ejbPassivate()
                  throws EJBException,
                         RemoteException
Specified by:
ejbPassivate in interface SessionBean
See Also:
SessionBean.ejbPassivate()

ejbCreate

public void ejbCreate()
               throws EJBException,
                      RemoteException
See Also:
SessionBean.ejbPassivate()

makeReservation

public int makeReservation(FlightSelection selection,
                           String[] passengers,
                           CreditCardValue creditCard,
                           long transId)
                    throws ValidationException
Adds a reservation to the database. The steps in the operation are:
  1. Get the reservation id
  2. Get the next passenger id
  3. Start the transaction
  4. Insert an entry into the ARS_RESERVATION table
  5. Insert all entries into the ARS_FLIGHTS_RESERVATION table
  6. Insert all entries into the ARS_PASSENGERS table
  7. End the transaction
  8. Return the reservation id
Parameters:
selection - - the flight selections made by the customer
passengers - - a list of passengers taking the flight(s)
creditCard - - the booking credit card
Returns:
int - the reservation id; 0 if a failure occurs
Throws:
ValidationException -  
See Also:
ReserveAndBuy.makeReservation(common.FlightSelection, java.lang.String[], vo.CreditCardValue, long)

cancelReservation

public void cancelReservation(int reservationId,
                              long transId)
                       throws ValidationException
Removes a reservation from the database. The steps in the operation are:
  1. Start the transaction
  2. Delete the entry in the ARS_RESERVATIONS table - if found
  3. Delete all entries in the ARS_FLIGHTS_RESERVATIONS table
  4. Delete all entries in the ARS_PASSENGERS table
  5. End the transaction

If the reservation cannot be found in the database then the cancellation may be a repeat/recovery from a failed repsonse to a client request (in which case it can be ignored) or it may be an erroneous request (in which case an exception needs to be generated) - this is determined by examining the last transaction id in the ARS_USERS table.
All (non ARS_USERS) table entries are determined by the reservationId.
Parameters:
reservationId - - the id of the reservation to be cancelled
Throws:
ValidationException -  
See Also:
ReserveAndBuy.cancelReservation(int, long)

buyTickets

public void buyTickets(int reservationId,
                       CreditCardValue creditCard,
                       long transId)
                throws ValidationException
See Also:
ReserveAndBuy.buyTickets(int, vo.CreditCardValue, long)

readReservation

public ReservationValue readReservation(int reservationId)
See Also:
ReserveAndBuy.readReservation(int)


Copyright © 2003 Team Two.