public class AgentReservationSessionEJB extends Object implements AgentReservationSessionLocal, AgentReservationSessionRemote, SessionSynchronization
Note too that this session bean declares its transaction properties using class annotations. By default, this stateful session bean runs without a tranaction while caching reservations for the user. A transaction is required only for the commit() call, which also signals the removal of this bean instance.
The bean also implements the javax.ejb.SessionSynchronization interface. This allows it to be called at the start and end of a transaction so that it has a chance to update its cached values appropriately. This bean, however, just prints some debug.
Modifier and Type | Field and Description |
---|---|
private AgentReservationSession |
agentSession |
private SessionContext |
ctx |
private EntityManager |
em |
private static org.apache.commons.logging.Log |
log |
private HotelReservationSessionRemote |
reservationSession |
Constructor and Description |
---|
AgentReservationSessionEJB() |
Modifier and Type | Method and Description |
---|---|
void |
addReservation(Person person,
Date startDate,
Date endDate) |
void |
afterBegin()
This method is called at the beginning of a transaction because of
the implements SessionSynchronization interface.
|
void |
afterCompletion(boolean status)
This method is called just after the transaction has committed to
tell us what happened.
|
void |
beforeCompletion()
This method is called just before the transaction has committed to
give the bean a chance to complain.
|
void |
cancelBooking() |
void |
close() |
void |
closing()
This method should be called when the bean is destroyed because of
the @PreDestory annotation.
|
Booking |
commit()
This method implements the big-bang.
|
void |
createBooking() |
void |
init()
This method is called immediately after dependency injection and
before any business method because of the @PostConstruct annotation.
|
private static final org.apache.commons.logging.Log log
private SessionContext ctx
private EntityManager em
private HotelReservationSessionRemote reservationSession
private AgentReservationSession agentSession
@PostConstruct public void init()
@PreDestroy public void closing()
public void createBooking() throws AgentReservationException
createBooking
in interface AgentReservationSession
AgentReservationException
public void addReservation(Person person, Date startDate, Date endDate) throws AgentReservationException
addReservation
in interface AgentReservationSession
AgentReservationException
public void cancelBooking() throws AgentReservationException
cancelBooking
in interface AgentReservationSession
AgentReservationException
public Booking commit() throws AgentReservationException
commit
in interface AgentReservationSession
AgentReservationException
public void close()
close
in interface AgentReservationSession
public void afterBegin()
afterBegin
in interface SessionSynchronization
public void beforeCompletion() throws EJBException, RemoteException
beforeCompletion
in interface SessionSynchronization
EJBException
RemoteException
public void afterCompletion(boolean status)
afterCompletion
in interface SessionSynchronization
Copyright © 2015 John's Hopkins University, Engineering Programs for Professionals. All rights reserved.