use of javax.resource.spi.ManagedConnection in project Payara by payara.
the class ConnectorXAResource method rollback.
public void rollback(Xid xid) throws XAException {
try {
ResourceHandle handle = getResourceHandleAndBeginTxIfNeeded();
ManagedConnection mc = (ManagedConnection) handle.getResource();
mc.getLocalTransaction().rollback();
} catch (Exception ex) {
handleResourceException(ex);
} finally {
resetAssociation();
resetAssociatedTransaction();
}
}
use of javax.resource.spi.ManagedConnection in project Payara by payara.
the class ConnectorXAResource method getResourceHandle.
private ResourceHandle getResourceHandle(boolean beginTxIfNeeded) throws PoolingException {
ResourceHandle h;
try {
JavaEETransaction j2eetran = getCurrentTransaction();
if (j2eetran == null || j2eetran.getNonXAResource() == null) {
// Only if some thing is wrong with tx manager.
// Just return the local handle.
h = localHandle_;
} else {
h = (ResourceHandle) j2eetran.getNonXAResource();
// can be acquired. If the resource in question is not the one in transaction, fail
if (!localHandle_.isShareable()) {
if (h != localHandle_) {
throw new ResourceAllocationException("Cannot use more than one local-tx resource in unshareable scope");
}
}
}
if (beginTxIfNeeded && h.getResourceState().isUnenlisted()) {
ManagedConnection mc = (ManagedConnection) h.getResource();
// begin the local transaction if first time
// this ManagedConnection is used in this JTA transaction
mc.getLocalTransaction().begin();
}
return h;
} catch (Exception ex) {
_logger.log(Level.SEVERE, "poolmgr.system_exception", ex);
throw new PoolingException(ex.toString(), ex);
}
}
use of javax.resource.spi.ManagedConnection in project Payara by payara.
the class ConnectorXAResource method start.
public void start(Xid xid, int flags) throws XAException {
try {
ResourceHandle handle = getResourceHandleAndBeginTxIfNeeded();
if (!localHandle_.equals(handle)) {
ManagedConnection mc = (ManagedConnection) handle.getResource();
mc.associateConnection(userHandle);
LocalTxConnectionEventListener l = (com.sun.enterprise.resource.listener.LocalTxConnectionEventListener) handle.getListener();
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "connection_sharing_start", userHandle);
}
l.associateHandle(userHandle, localHandle_);
} else {
associatedTransaction = getCurrentTransaction();
}
} catch (Exception ex) {
handleResourceException(ex);
}
}
use of javax.resource.spi.ManagedConnection in project Payara by payara.
the class AbstractConnectorAllocator method cleanup.
public void cleanup(ResourceHandle h) throws PoolingException {
try {
ManagedConnection mc = (ManagedConnection) h.getResource();
mc.cleanup();
} catch (Exception ex) {
_logger.log(Level.WARNING, "managed_con.cleanup-failed", ex);
throw new PoolingException(ex.toString(), ex);
}
}
use of javax.resource.spi.ManagedConnection in project Payara by payara.
the class AbstractConnectorAllocator method matchConnection.
public boolean matchConnection(ResourceHandle h) {
Set set = new HashSet();
set.add(h.getResource());
try {
ManagedConnection mc = mcf.matchManagedConnections(set, subject, reqInfo);
return (mc != null);
} catch (ResourceException ex) {
return false;
}
}
Aggregations