Search in sources :

Example 21 with PoolingException

use of com.sun.appserv.connectors.internal.api.PoolingException 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);
    }
}
Also used : PoolingException(com.sun.appserv.connectors.internal.api.PoolingException) ManagedConnection(javax.resource.spi.ManagedConnection) PoolingException(com.sun.appserv.connectors.internal.api.PoolingException) ResourceException(javax.resource.ResourceException) ConnectorRuntimeException(com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)

Example 22 with PoolingException

use of com.sun.appserv.connectors.internal.api.PoolingException 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);
    }
}
Also used : PoolingException(com.sun.appserv.connectors.internal.api.PoolingException) XAResource(javax.transaction.xa.XAResource) LocalTxConnectionEventListener(com.sun.enterprise.resource.listener.LocalTxConnectionEventListener) ResourceException(javax.resource.ResourceException) LocalTxConnectionEventListener(com.sun.enterprise.resource.listener.LocalTxConnectionEventListener) ConnectionEventListener(com.sun.enterprise.resource.listener.ConnectionEventListener)

Example 23 with PoolingException

use of com.sun.appserv.connectors.internal.api.PoolingException in project Payara by payara.

the class LocalTxConnectorAllocator method destroyResource.

public void destroyResource(ResourceHandle resource) throws PoolingException {
    try {
        ManagedConnection mc = (ManagedConnection) resource.getResource();
        ConnectorXAResource.freeListener(mc);
        XAResource xares = resource.getXAResource();
        forceTransactionCompletion(xares);
        mc.destroy();
        if (_logger.isLoggable(Level.FINEST)) {
            _logger.finest("destroyResource for LocalTxConnectorAllocator done");
        }
    } catch (Exception ex) {
        throw new PoolingException(ex);
    }
}
Also used : PoolingException(com.sun.appserv.connectors.internal.api.PoolingException) XAResource(javax.transaction.xa.XAResource) PoolingException(com.sun.appserv.connectors.internal.api.PoolingException) ResourceException(javax.resource.ResourceException) SystemException(javax.transaction.SystemException)

Example 24 with PoolingException

use of com.sun.appserv.connectors.internal.api.PoolingException in project Payara by payara.

the class LocalTxConnectorAllocator method fillInResourceObjects.

public void fillInResourceObjects(ResourceHandle resource) throws PoolingException {
    try {
        ManagedConnection mc = (ManagedConnection) resource.getResource();
        Object con = mc.getConnection(subject, reqInfo);
        ConnectorXAResource xares = (ConnectorXAResource) resource.getXAResource();
        xares.setUserHandle(con);
        resource.fillInResourceObjects(con, xares);
    } catch (ResourceException ex) {
        throw new PoolingException(ex);
    }
}
Also used : PoolingException(com.sun.appserv.connectors.internal.api.PoolingException) ResourceException(javax.resource.ResourceException)

Example 25 with PoolingException

use of com.sun.appserv.connectors.internal.api.PoolingException in project Payara by payara.

the class ListDataStructure method addResource.

/**
 * creates a new resource and adds to the datastructure.
 *
 * @param allocator ResourceAllocator
 * @param count     Number (units) of resources to create
 * @return int number of resources added
 */
public int addResource(ResourceAllocator allocator, int count) throws PoolingException {
    int numResAdded = 0;
    for (int i = 0; i < count && resources.size() < maxSize; i++) {
        boolean lockAcquired = dynSemaphore.tryAcquire();
        if (lockAcquired) {
            try {
                ResourceHandle handle = handler.createResource(allocator);
                synchronized (resources) {
                    synchronized (free) {
                        free.add(handle);
                        resources.add(handle);
                        numResAdded++;
                    }
                }
            } catch (Exception e) {
                dynSemaphore.release();
                PoolingException pe = new PoolingException(e.getMessage());
                pe.initCause(e);
                throw pe;
            }
        }
    }
    return numResAdded;
}
Also used : PoolingException(com.sun.appserv.connectors.internal.api.PoolingException) ResourceHandle(com.sun.enterprise.resource.ResourceHandle) PoolingException(com.sun.appserv.connectors.internal.api.PoolingException)

Aggregations

PoolingException (com.sun.appserv.connectors.internal.api.PoolingException)32 ResourceException (javax.resource.ResourceException)17 ResourceHandle (com.sun.enterprise.resource.ResourceHandle)9 ManagedConnection (javax.resource.spi.ManagedConnection)7 InvocationException (org.glassfish.api.invocation.InvocationException)5 PrivilegedAction (java.security.PrivilegedAction)4 RetryableUnavailableException (javax.resource.spi.RetryableUnavailableException)4 JavaEETransaction (com.sun.enterprise.transaction.api.JavaEETransaction)3 JavaEETransactionManager (com.sun.enterprise.transaction.api.JavaEETransactionManager)3 NamingException (javax.naming.NamingException)3 SystemException (javax.transaction.SystemException)3 XAResource (javax.transaction.xa.XAResource)3 ComponentInvocation (org.glassfish.api.invocation.ComponentInvocation)3 InvocationManager (org.glassfish.api.invocation.InvocationManager)3 ConnectorRuntimeException (com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)2 ResourceSpec (com.sun.enterprise.resource.ResourceSpec)2 ConnectionEventListener (com.sun.enterprise.resource.listener.ConnectionEventListener)2 PoolManager (com.sun.enterprise.resource.pool.PoolManager)2 ManagedConnectionFactory (javax.resource.spi.ManagedConnectionFactory)2 Transaction (javax.transaction.Transaction)2