Search in sources :

Example 6 with JavaEETransaction

use of com.sun.enterprise.transaction.api.JavaEETransaction in project Payara by payara.

the class PoolManagerImpl method resourceEnlisted.

public void resourceEnlisted(Transaction tran, com.sun.appserv.connectors.internal.api.ResourceHandle h) throws IllegalStateException {
    ResourceHandle res = (ResourceHandle) h;
    PoolInfo poolInfo = res.getResourceSpec().getPoolInfo();
    try {
        JavaEETransaction j2eeTran = (JavaEETransaction) tran;
        if (poolInfo != null && j2eeTran.getResources(poolInfo) == null) {
            addSyncListener(tran);
        }
    } catch (ClassCastException e) {
        addSyncListener(tran);
    }
    if (poolInfo != null) {
        ResourcePool pool = getPool(poolInfo);
        if (pool != null) {
            pool.resourceEnlisted(tran, res);
        }
    }
}
Also used : JavaEETransaction(com.sun.enterprise.transaction.api.JavaEETransaction) ResourceHandle(com.sun.enterprise.resource.ResourceHandle) PoolInfo(org.glassfish.resourcebase.resources.api.PoolInfo)

Example 7 with JavaEETransaction

use of com.sun.enterprise.transaction.api.JavaEETransaction in project Payara by payara.

the class PoolTxHelper method resourceEnlisted.

/**
 * this method is called when a resource is enlisted in
 * transation tran
 * @param tran Transaction to which the resource need to be enlisted
 * @param resource Resource to be enlisted in the transaction
 */
public void resourceEnlisted(Transaction tran, ResourceHandle resource) {
    try {
        JavaEETransaction j2eetran = (JavaEETransaction) tran;
        Set set = j2eetran.getResources(poolInfo);
        if (set == null) {
            set = new HashSet();
            j2eetran.setResources(set, poolInfo);
        }
        set.add(resource);
    } catch (ClassCastException e) {
        if (_logger.isLoggable(Level.FINE)) {
            _logger.log(Level.FINE, "Pool [ " + poolInfo + " ]: resourceEnlisted:" + "transaction is not J2EETransaction but a " + tran.getClass().getName(), e);
        }
    }
    ResourceState state = resource.getResourceState();
    state.setEnlisted(true);
    if (_logger.isLoggable(Level.FINE)) {
        _logger.log(Level.FINE, "Pool [ " + poolInfo + " ]: resourceEnlisted: " + resource);
    }
}
Also used : JavaEETransaction(com.sun.enterprise.transaction.api.JavaEETransaction) ResourceState(com.sun.enterprise.resource.ResourceState)

Example 8 with JavaEETransaction

use of com.sun.enterprise.transaction.api.JavaEETransaction in project Payara by payara.

the class PoolTxHelper method transactionCompleted.

/**
 * this method is called when transaction tran is completed
 * @param tran transaction which has completed
 * @param status transaction status
 * @param poolInfo Pool name
 * @return delisted resources
 */
public List<ResourceHandle> transactionCompleted(Transaction tran, int status, PoolInfo poolInfo) {
    JavaEETransaction j2eetran;
    List<ResourceHandle> delistedResources = new ArrayList<ResourceHandle>();
    try {
        j2eetran = (JavaEETransaction) tran;
    } catch (ClassCastException e) {
        if (_logger.isLoggable(Level.FINE)) {
            _logger.log(Level.FINE, "Pool: transactionCompleted: " + "transaction is not J2EETransaction but a " + tran.getClass().getName(), e);
        }
        return delistedResources;
    }
    Set set = j2eetran.getResources(poolInfo);
    if (set == null)
        return delistedResources;
    Iterator iter = set.iterator();
    while (iter.hasNext()) {
        ResourceHandle resource = (ResourceHandle) iter.next();
        ResourceState state = resource.getResourceState();
        state.setEnlisted(false);
        delistedResources.add(resource);
        iter.remove();
        if (_logger.isLoggable(Level.FINE)) {
            _logger.log(Level.FINE, "Pool: transactionCompleted: " + resource);
        }
    }
    return delistedResources;
}
Also used : JavaEETransaction(com.sun.enterprise.transaction.api.JavaEETransaction) ResourceHandle(com.sun.enterprise.resource.ResourceHandle) ResourceState(com.sun.enterprise.resource.ResourceState)

Example 9 with JavaEETransaction

use of com.sun.enterprise.transaction.api.JavaEETransaction in project Payara by payara.

the class LocalTxConnectorAllocator method forceTransactionCompletion.

private void forceTransactionCompletion(XAResource xares) throws SystemException {
    if (transactionCompletionMode != null) {
        if (xares instanceof ConnectorXAResource) {
            ConnectorXAResource connectorXARes = (ConnectorXAResource) xares;
            JavaEETransaction j2eetran = connectorXARes.getAssociatedTransaction();
            if (j2eetran != null && j2eetran.isLocalTx()) {
                if (j2eetran.getStatus() == (Status.STATUS_ACTIVE)) {
                    try {
                        if (transactionCompletionMode.equalsIgnoreCase(COMMIT)) {
                            if (_logger.isLoggable(Level.FINEST)) {
                                _logger.log(Level.FINEST, "Transaction Completion Mode for LocalTx resource is " + "set as COMMIT, committing transaction");
                            }
                            j2eetran.commit();
                        } else if (transactionCompletionMode.equalsIgnoreCase(ROLLBACK)) {
                            if (_logger.isLoggable(Level.FINEST)) {
                                _logger.log(Level.FINEST, "Transaction Completion Mode for LocalTx resource is " + "set as ROLLBACK, rolling back transaction");
                            }
                            j2eetran.rollback();
                        } else {
                            _logger.log(Level.WARNING, "Unknown transaction completion mode, no action made");
                        }
                    } catch (Exception e) {
                        _logger.log(Level.WARNING, "Failure while forcibily completing an incomplete, " + "local transaction ", e);
                    }
                }
            }
        }
    }
}
Also used : JavaEETransaction(com.sun.enterprise.transaction.api.JavaEETransaction) PoolingException(com.sun.appserv.connectors.internal.api.PoolingException) ResourceException(javax.resource.ResourceException) SystemException(javax.transaction.SystemException)

Example 10 with JavaEETransaction

use of com.sun.enterprise.transaction.api.JavaEETransaction in project Payara by payara.

the class JavaEETransactionManagerSimplified method enlistComponentResources.

public void enlistComponentResources() throws RemoteException {
    if (_logger.isLoggable(Level.FINE))
        _logger.log(Level.FINE, "TM: enlistComponentResources");
    ComponentInvocation inv = invMgr.getCurrentInvocation();
    if (inv == null)
        return;
    try {
        Transaction tran = getTransaction();
        inv.setTransaction((JavaEETransaction) tran);
        enlistComponentResources(inv);
    } catch (InvocationException ex) {
        _logger.log(Level.SEVERE, "enterprise_distributedtx.excep_in_enlist", ex);
        throw new RemoteException(ex.getMessage(), ex.getNestedException());
    } catch (Exception ex) {
        _logger.log(Level.SEVERE, "enterprise_distributedtx.excep_in_enlist", ex);
        throw new RemoteException(ex.getMessage(), ex);
    }
}
Also used : JavaEETransaction(com.sun.enterprise.transaction.api.JavaEETransaction) ComponentInvocation(org.glassfish.api.invocation.ComponentInvocation) InvocationException(org.glassfish.api.invocation.InvocationException) RemoteException(java.rmi.RemoteException) InvocationException(org.glassfish.api.invocation.InvocationException) WorkException(javax.resource.spi.work.WorkException) RemoteException(java.rmi.RemoteException) XAException(javax.transaction.xa.XAException)

Aggregations

JavaEETransaction (com.sun.enterprise.transaction.api.JavaEETransaction)29 SystemException (javax.transaction.SystemException)5 ResourceHandle (com.sun.enterprise.resource.ResourceHandle)4 XAException (javax.transaction.xa.XAException)4 PoolingException (com.sun.appserv.connectors.internal.api.PoolingException)3 ResourceState (com.sun.enterprise.resource.ResourceState)3 RemoteException (java.rmi.RemoteException)3 Vector (java.util.Vector)3 EJBException (javax.ejb.EJBException)3 WorkException (javax.resource.spi.work.WorkException)3 InvocationException (org.glassfish.api.invocation.InvocationException)3 PhysicalEntityManagerWrapper (com.sun.enterprise.container.common.impl.PhysicalEntityManagerWrapper)2 JavaEETransactionManager (com.sun.enterprise.transaction.api.JavaEETransactionManager)2 RequestTraceSpanLog (fish.payara.notification.requesttracing.RequestTraceSpanLog)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 EntityManagerFactory (javax.persistence.EntityManagerFactory)2 ComponentInvocation (org.glassfish.api.invocation.ComponentInvocation)2 EJBLocalObjectImpl (com.sun.ejb.containers.EJBLocalObjectImpl)1 JavaEEContainer (com.sun.enterprise.container.common.spi.JavaEEContainer)1