use of org.jboss.as.quickstarts.ejb.entity.CalleeUser in project quickstart by wildfly.
the class StatelessBean method successOnCall.
/**
* Stateless remote ejb method to be called from the client side.
*
* @return information about the host that this EJB resides on
*/
@Override
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public String successOnCall() {
log.debugf("Called '%s.successOnCall()' with transaction status %s", this.getClass().getName(), InfoUtils.getTransactionStatus());
// transaction enlists XAResource #1
try {
tm.getTransaction().enlistResource(new MockXAResource());
} catch (SystemException | RollbackException sre) {
throw new IllegalStateException("Cannot enlist a " + MockXAResource.class.getName() + " to the current transaction", sre);
}
// transaction enlists XAResource #2
em.persist(new CalleeUser("Bard", "The Bowman"));
return InfoUtils.getHostInfo();
}
use of org.jboss.as.quickstarts.ejb.entity.CalleeUser in project quickstart by wildfly.
the class StatefulBean method successOnCall.
/**
* Stateful bean remote method to be called from the client side.
*
* @return information about the host that this EJB resides on
*/
@Override
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public String successOnCall() {
log.debugf("Called '%s.successOnCall()' with transaction status %s", this.getClass().getName(), InfoUtils.getTransactionStatus());
em.persist(new CalleeUser("Thorin", "Oakenshield"));
return InfoUtils.getHostInfo();
}
use of org.jboss.as.quickstarts.ejb.entity.CalleeUser in project quickstart by wildfly.
the class StatelessBean method failOnCall.
/**
* Failure during the commit processing does not mean an exception is thrown by transaction manager processing.
* The business method is marked as succesfully finished.
* The uncommitted {@link javax.transaction.xa.XAResource}s will be committed later by periodic recovery.
*/
@Override
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public String failOnCall() {
log.debugf("Called '%s.failOnCall()' with transaction status %s", this.getClass().getName(), InfoUtils.getTransactionStatus());
// transaction enlists XAResource #1 with forcing to fail
try {
tm.getTransaction().enlistResource(new MockXAResource(MockXAResource.TestAction.COMMIT_THROW_XAER_RMFAIL));
} catch (SystemException | RollbackException sre) {
throw new IllegalStateException("Cannot enlist a " + MockXAResource.class.getName() + " to the current transaction", sre);
}
// transaction enlists XAResource #2
em.persist(new CalleeUser("Bard", "The Bowman"));
return InfoUtils.getHostInfo();
}
Aggregations