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 SessionContextctxprivate EntityManageremprivate static org.slf4j.Loggerlogprivate HotelReservationistreservationist
-
Constructor Summary
Constructors Constructor Description HotelRegistrationEJB()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcancelReservation(Reservation reservation)This method will cause the current transaction to be rolled back if the business logic reports an exception cancelling a reservation.voidcleanupReservation(String confirmation)voidclose()This method is called whenever the EJB is evicted from the container; which is not too often for stateless session beans under normal circumstances.ReservationcommitReservation(Reservation reservation)This method is just a pass-thru to the business logic.ReservationcreateReservation(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.ReservationgetReservationByConfirmation(String confirmation)List<Reservation>getReservations(int index, int count)List<Reservation>getReservationsForPerson(Person person, int index, int count)voidinit()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:
cancelReservationin interfaceHotelReservationist- Throws:
HotelReservationException
-
commitReservation
public Reservation commitReservation(Reservation reservation) throws HotelReservationException
This method is just a pass-thru to the business logic.- Specified by:
commitReservationin 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:
createReservationin interfaceHotelReservationist- Throws:
HotelReservationException
-
getReservations
public List<Reservation> getReservations(int index, int count) throws HotelReservationException
- Specified by:
getReservationsin interfaceHotelReservationist- Throws:
HotelReservationException
-
getReservationsForPerson
public List<Reservation> getReservationsForPerson(Person person, int index, int count) throws HotelReservationException
- Specified by:
getReservationsForPersonin interfaceHotelReservationist- Throws:
HotelReservationException
-
getReservationByConfirmation
public Reservation getReservationByConfirmation(String confirmation) throws HotelReservationException
- Specified by:
getReservationByConfirmationin interfaceHotelReservationist- Throws:
HotelReservationException
-
cleanupReservation
public void cleanupReservation(String confirmation) throws HotelReservationException
- Specified by:
cleanupReservationin interfaceHotelReservationist- Throws:
HotelReservationException
-
-