FileDocCategorySizeDatePackage
UnpooledResource.javaAPI DocGlassfish v2 API4761Fri May 04 22:35:16 BST 2007com.sun.enterprise.resource

UnpooledResource

public class UnpooledResource extends AbstractResourcePool
This resource pool is created when connection pooling is switched off Hence no pooling happens in this resource pool
author
Kshitiz Saxena
since
9.1

Fields Summary
private int
poolSize
Constructors Summary
public UnpooledResource(String poolName)
Creates a new instance of UnpooledResourcePool

        super(poolName);
        
        //No monitoring data for this pool as pooling is switched off
        monitoringEnabled = false;
        //No pool is being maintained, hence no pool cleanup is needed 
        //in case of failure
        failAllConnections = false;
    
Methods Summary
private synchronized voiddecrementPoolSize()

        poolSize--;
    
protected voidfreeResource(ResourceHandle resourceHandle)

        decrementPoolSize();
        destroyResource(resourceHandle);
    
protected ResourceHandlegetUnenlistedResource(ResourceSpec spec, ResourceAllocator alloc, javax.transaction.Transaction tran)

        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;
        }
        _logger.info("Fail as poolSize : " + poolSize);
        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);
    
private synchronized booleanincrementPoolSize()

        if(poolSize >= maxPoolSize)
            return false;
        poolSize++;
        return true;
    
protected synchronized voidinitPool(ResourceSpec resourceSpec, ResourceAllocator allocator)

        
        if (poolInitialized) {
            return;
        }
        
        //nothing needs to be done as pooling is disabled
        poolSize = 0;
        
        poolInitialized = true;
    
protected ResourceHandleprefetch(ResourceSpec spec, ResourceAllocator alloc, javax.transaction.Transaction tran)

        return null;
    
public voidresourceErrorOccurred(ResourceHandle resourceHandle)

        freeResource(resourceHandle);