All EJB are transactional. If they start in a transaction they automatically are configured inside the transaction. A simple way to manage the transactions is through the SessionSynchronization interface. Here's a stateful sample implementing it:
@Stateful(name = "stateEngineRemote")
public class StateEngineRemoteBean implements SessionSynchronization {
...
@Override
public void afterBegin() throws EJBException, RemoteException {
logger.info("the bean is begun");
}
@Override
public void beforeCompletion() throws EJBException, RemoteException {
logger.info("the bean is completing");
}
@Override
public void afterCompletion(boolean committed) throws EJBException, RemoteException {
logger.info("the bean is completed");
}
...}
Here's a transactional client that invokes the EJB:
@Inject
private...