Search in sources :

Example 51 with TransactionAttribute

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();
}
Also used : CalleeUser(org.jboss.as.quickstarts.ejb.entity.CalleeUser) TransactionAttribute(javax.ejb.TransactionAttribute)

Example 52 with TransactionAttribute

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();
}
Also used : SystemException(javax.transaction.SystemException) MockXAResource(org.jboss.as.quickstarts.ejb.mock.MockXAResource) RollbackException(javax.transaction.RollbackException) CalleeUser(org.jboss.as.quickstarts.ejb.entity.CalleeUser) TransactionAttribute(javax.ejb.TransactionAttribute)

Example 53 with TransactionAttribute

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);
}
Also used : Customer(org.jboss.as.quickstarts.cmt.model.Customer) TransactionAttribute(javax.ejb.TransactionAttribute)

Example 54 with TransactionAttribute

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");
}
Also used : Member(org.jboss.as.quickstarts.kitchensinkjsp.model.Member) TransactionAttribute(javax.ejb.TransactionAttribute) PostConstruct(javax.annotation.PostConstruct)

Example 55 with TransactionAttribute

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);
}
Also used : LogMessage(org.jboss.as.quickstarts.cmt.model.LogMessage) TransactionAttribute(javax.ejb.TransactionAttribute)

Aggregations

TransactionAttribute (javax.ejb.TransactionAttribute)61 JMSException (javax.jms.JMSException)8 IOException (java.io.IOException)7 Connection (javax.jms.Connection)6 Session (javax.jms.Session)6 TextMessage (javax.jms.TextMessage)6 Query (javax.persistence.Query)5 Configuration (org.hibernate.cfg.Configuration)5 Dataset (edu.harvard.iq.dataverse.Dataset)4 ConfigMessageException (eu.europa.ec.fisheries.uvms.config.exception.ConfigMessageException)4 ArrayList (java.util.ArrayList)4 Date (java.util.Date)4 EJBException (javax.ejb.EJBException)4 Message (javax.jms.Message)4 MessageProducer (javax.jms.MessageProducer)4 DataFile (edu.harvard.iq.dataverse.DataFile)3 AuthenticatedUser (edu.harvard.iq.dataverse.authorization.users.AuthenticatedUser)3 ExchangeMessageException (eu.europa.ec.fisheries.uvms.exchange.message.exception.ExchangeMessageException)3 Properties (java.util.Properties)3 EntityManager (javax.persistence.EntityManager)3