Package ejava.examples.txhotel.ejb
Class HotelRegistrationEJB
- java.lang.Object
-
- ejava.examples.txhotel.ejb.HotelRegistrationEJB
-
- All Implemented Interfaces:
HotelReservationist
,HotelRegistrationLocal
,HotelRegistrationRemote
public class HotelRegistrationEJB extends Object implements HotelRegistrationRemote, HotelRegistrationLocal
This class provides a stateless EJB wrapper around stateless logic that performs operations on the hotel.
-
-
Field Summary
Fields Modifier and Type Field Description private SessionContext
ctx
private EntityManager
em
private static org.slf4j.Logger
log
private HotelReservationist
reservationist
-
Constructor Summary
Constructors Constructor Description HotelRegistrationEJB()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cancelReservation(Reservation reservation)
This method will cause the current transaction to be rolled back if the business logic reports an exception cancelling a reservation.void
cleanupReservation(String confirmation)
void
close()
This method is called whenever the EJB is evicted from the container; which is not too often for stateless session beans under normal circumstances.Reservation
commitReservation(Reservation reservation)
This method is just a pass-thru to the business logic.Reservation
createReservation(Person person, Date startDate, Date endDate)
This method will rollack the current transaction if the business logic throws an exception while trying to create a reservation.Reservation
getReservationByConfirmation(String confirmation)
List<Reservation>
getReservations(int index, int count)
List<Reservation>
getReservationsForPerson(Person person, int index, int count)
void
init()
This method is called when the bean is created and is responsble for instantiating the business logic implementation, a DAO, and assigning the EntityManager for the DAO(s) to use.
-
-
-
Field Detail
-
log
private static final org.slf4j.Logger log
-
em
private EntityManager em
-
ctx
private SessionContext ctx
-
reservationist
private HotelReservationist reservationist
-
-
Method Detail
-
init
@PostConstruct public void init()
This method is called when the bean is created and is responsble for instantiating the business logic implementation, a DAO, and assigning the EntityManager for the DAO(s) to use.
-
close
@PreDestroy public void close()
This method is called whenever the EJB is evicted from the container; which is not too often for stateless session beans under normal circumstances.
-
cancelReservation
public void cancelReservation(Reservation reservation) throws HotelReservationException
This method will cause the current transaction to be rolled back if the business logic reports an exception cancelling a reservation.- Specified by:
cancelReservation
in interfaceHotelReservationist
- Throws:
HotelReservationException
-
commitReservation
public Reservation commitReservation(Reservation reservation) throws HotelReservationException
This method is just a pass-thru to the business logic.- Specified by:
commitReservation
in interfaceHotelReservationist
- Throws:
HotelReservationException
-
createReservation
public Reservation createReservation(Person person, Date startDate, Date endDate) throws HotelReservationException
This method will rollack the current transaction if the business logic throws an exception while trying to create a reservation.- Specified by:
createReservation
in interfaceHotelReservationist
- Throws:
HotelReservationException
-
getReservations
public List<Reservation> getReservations(int index, int count) throws HotelReservationException
- Specified by:
getReservations
in interfaceHotelReservationist
- Throws:
HotelReservationException
-
getReservationsForPerson
public List<Reservation> getReservationsForPerson(Person person, int index, int count) throws HotelReservationException
- Specified by:
getReservationsForPerson
in interfaceHotelReservationist
- Throws:
HotelReservationException
-
getReservationByConfirmation
public Reservation getReservationByConfirmation(String confirmation) throws HotelReservationException
- Specified by:
getReservationByConfirmation
in interfaceHotelReservationist
- Throws:
HotelReservationException
-
cleanupReservation
public void cleanupReservation(String confirmation) throws HotelReservationException
- Specified by:
cleanupReservation
in interfaceHotelReservationist
- Throws:
HotelReservationException
-
-