use of javax.ejb.TransactionAttribute 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 javax.ejb.TransactionAttribute 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();
}
use of javax.ejb.TransactionAttribute in project quickstart by wildfly.
the class CustomerManagerEJB method createCustomer.
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public void createCustomer(String name) throws RemoteException, JMSException {
Customer c1 = new Customer();
c1.setName(name);
entityManager.persist(c1);
final InvoiceManagerEJB invoiceManager = invoiceManagerHome.create();
invoiceManager.createInvoice(name);
}
use of javax.ejb.TransactionAttribute in project quickstart by wildfly.
the class MemberRegistration method initNewMember.
@PostConstruct
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public void initNewMember() {
newMember = new Member();
log.info("@PostConstruct:initNewMember called");
}
use of javax.ejb.TransactionAttribute in project quickstart by wildfly.
the class LogMessageManagerEJB method logCreateCustomer.
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public void logCreateCustomer(String name) throws RemoteException, JMSException {
LogMessage lm = new LogMessage();
lm.setMessage("Attempt to create record for customer: '" + name + "'");
entityManager.persist(lm);
}
Aggregations