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);
}
}
}
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);
}
}
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;
}
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);
}
}
}
}
}
}
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);
}
}
Aggregations