use of com.sun.enterprise.resource.listener.LocalTxConnectionEventListener in project Payara by payara.
the class ConnectorXAResource method end.
public void end(Xid xid, int flags) throws XAException {
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "connection_sharing_end");
}
try {
ResourceHandle handleInTransaction = getResourceHandleAndBeginTxIfNeeded();
if (!localHandle_.equals(handleInTransaction)) {
LocalTxConnectionEventListener l = (LocalTxConnectionEventListener) handleInTransaction.getListener();
ResourceHandle handle = l.removeAssociation(userHandle);
if (handle != null) {
// not needed, just to be sure.
ManagedConnection associatedConnection = (ManagedConnection) handle.getResource();
associatedConnection.associateConnection(userHandle);
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "connection_sharing_reset_association", userHandle);
}
}
}
} catch (Exception e) {
handleResourceException(e);
}
}
use of com.sun.enterprise.resource.listener.LocalTxConnectionEventListener in project Payara by payara.
the class ConnectorXAResource method resetAssociation.
private void resetAssociation() throws XAException {
try {
ResourceHandle handle = getResourceHandleForFinalize();
LocalTxConnectionEventListener l = (LocalTxConnectionEventListener) handle.getListener();
// Get all associated Handles and reset their ManagedConnection association.
Map associatedHandles = l.getAssociatedHandles();
if (associatedHandles != null) {
Set<Map.Entry> userHandles = associatedHandles.entrySet();
for (Map.Entry userHandleEntry : userHandles) {
ResourceHandle associatedHandle = (ResourceHandle) userHandleEntry.getValue();
ManagedConnection associatedConnection = (ManagedConnection) associatedHandle.getResource();
associatedConnection.associateConnection(userHandleEntry.getKey());
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "connection_sharing_reset_association", userHandleEntry.getKey());
}
}
// all associated handles are mapped back to their actual Managed Connection. Clear the associations.
associatedHandles.clear();
}
} catch (Exception ex) {
handleResourceException(ex);
}
}
use of com.sun.enterprise.resource.listener.LocalTxConnectionEventListener 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 com.sun.enterprise.resource.listener.LocalTxConnectionEventListener in project Payara by payara.
the class LocalTxConnectorAllocator method createResource.
public ResourceHandle createResource() throws PoolingException {
try {
ManagedConnection mc = mcf.createManagedConnection(subject, reqInfo);
ResourceHandle resource = createResourceHandle(mc, spec, this, info);
ConnectionEventListener l = new LocalTxConnectionEventListener(resource);
mc.addConnectionEventListener(l);
resource.setListener(l);
XAResource xares = new ConnectorXAResource(resource, spec, this, info);
resource.fillInResourceObjects(null, xares);
return resource;
} catch (ResourceException ex) {
Object[] params = new Object[] { spec.getPoolInfo(), ex.toString() };
_logger.log(Level.WARNING, "poolmgr.create_resource_error", params);
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "Resource Exception while creating resource", ex);
}
if (ex.getLinkedException() != null) {
_logger.log(Level.WARNING, "poolmgr.create_resource_linked_error", ex.getLinkedException().toString());
}
throw new PoolingException(ex);
}
}
Aggregations