use of com.sun.enterprise.resource.ResourceHandle in project Payara by payara.
the class ConnectionPool method internalGetResource.
protected ResourceHandle internalGetResource(ResourceSpec spec, ResourceAllocator alloc, Transaction tran) throws PoolingException {
if (!poolInitialized) {
initPool(alloc);
}
ResourceHandle result;
result = getResourceFromTransaction(tran, alloc, spec);
if (result != null) {
return result;
}
result = prefetch(spec, alloc, tran);
if (result != null) {
return result;
}
// We didnt get a connection that is already enlisted in the current transaction (if any).
result = getUnenlistedResource(spec, alloc, tran);
if (result != null) {
if (maxConnectionUsage_ > 0) {
result.incrementUsageCount();
}
if (poolLifeCycleListener != null) {
poolLifeCycleListener.connectionUsed(result.getId());
// Decrement numConnFree
poolLifeCycleListener.decrementNumConnFree();
}
}
return result;
}
use of com.sun.enterprise.resource.ResourceHandle 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.resource.ResourceHandle in project Payara by payara.
the class PoolManagerImpl method unregisterResource.
public void unregisterResource(com.sun.appserv.connectors.internal.api.ResourceHandle resource, int xaresFlag) {
ResourceHandle h = (ResourceHandle) resource;
ResourceManager rm = getResourceManager(h.getResourceSpec());
rm.unregisterResource(h, xaresFlag);
}
use of com.sun.enterprise.resource.ResourceHandle in project Payara by payara.
the class UnpooledResource method getUnenlistedResource.
@Override
protected ResourceHandle getUnenlistedResource(ResourceSpec spec, ResourceAllocator alloc, Transaction tran) throws PoolingException {
ResourceHandle handle = null;
if (incrementPoolSize()) {
try {
handle = createSingleResource(alloc);
} catch (PoolingException ex) {
decrementPoolSize();
throw ex;
}
ResourceState state = new ResourceState();
handle.setResourceState(state);
state.setEnlisted(false);
setResourceStateToBusy(handle);
return handle;
}
String msg = localStrings.getStringWithDefault("poolmgr.max.pool.size.reached", "In-use connections equal max-pool-size therefore cannot allocate any more connections.");
throw new PoolingException(msg);
}
use of com.sun.enterprise.resource.ResourceHandle in project Payara by payara.
the class RWLockDataStructure method getResource.
/**
* {@inheritDoc}
*/
public ResourceHandle getResource() {
readLock.lock();
for (int i = 0; i < resources.size(); i++) {
ResourceHandle h = resources.get(i);
if (!h.isBusy()) {
readLock.unlock();
writeLock.lock();
try {
if (!h.isBusy()) {
h.setBusy(true);
return h;
} else {
readLock.lock();
continue;
}
} finally {
writeLock.unlock();
}
} else {
continue;
}
}
readLock.unlock();
return null;
}
Aggregations