use of javax.resource.spi.ManagedConnection in project Payara by payara.
the class ConnectorConnectionPoolAdminServiceImpl method getManagedConnection.
/**
* Utility method to get Managed connection from the supplied mcf and
* default subject.
* @param mcf
* @param defaultSubject
* @return
* @throws javax.resource.ResourceException
*/
protected ManagedConnection getManagedConnection(ManagedConnectionFactory mcf, Subject defaultSubject, ConnectionRequestInfo cReqInfo) throws ResourceException {
ManagedConnection mc = null;
// Create the ManagedConnection
mc = mcf.createManagedConnection(defaultSubject, cReqInfo);
return mc;
}
use of javax.resource.spi.ManagedConnection 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 javax.resource.spi.ManagedConnection in project Payara by payara.
the class ConnectorXAResource method commit.
public void commit(Xid xid, boolean onePhase) throws XAException {
try {
ResourceHandle handle = getResourceHandleAndBeginTxIfNeeded();
ManagedConnection mc = (ManagedConnection) handle.getResource();
mc.getLocalTransaction().commit();
} catch (Exception ex) {
handleResourceException(ex);
} finally {
resetAssociation();
resetAssociatedTransaction();
}
}
use of javax.resource.spi.ManagedConnection in project Payara by payara.
the class NoTxConnectorAllocator method createResource.
public ResourceHandle createResource() throws PoolingException {
try {
ManagedConnection mc = mcf.createManagedConnection(subject, reqInfo);
ResourceHandle resource = createResourceHandle(mc, spec, this, info);
ConnectionEventListener l = new ConnectionListenerImpl(resource);
mc.addConnectionEventListener(l);
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);
}
}
use of javax.resource.spi.ManagedConnection in project Payara by payara.
the class AbstractConnectorAllocator method closeUserConnection.
public void closeUserConnection(ResourceHandle resource) throws PoolingException {
try {
ManagedConnection mc = (ManagedConnection) resource.getResource();
mc.cleanup();
} catch (ResourceException ex) {
throw new PoolingException(ex);
}
}
Aggregations