Search in sources :

Example 1 with DissociatableManagedConnection

use of javax.resource.spi.DissociatableManagedConnection in project tomee by apache.

the class AutoConnectionTracker method proxyConnection.

private void proxyConnection(final ConnectionTrackingInterceptor interceptor, final ConnectionInfo connectionInfo) throws ResourceException {
    // if this connection already has a proxy no need to create another
    if (connectionInfo.getConnectionProxy() != null) {
        return;
    }
    // DissociatableManagedConnection do not need to be proxied
    if (connectionInfo.getManagedConnectionInfo().getManagedConnection() instanceof DissociatableManagedConnection) {
        return;
    }
    try {
        final Object handle = connectionInfo.getConnectionHandle();
        final ConnectionInvocationHandler invocationHandler = new ConnectionInvocationHandler(handle);
        final Object proxy = newProxy(handle, invocationHandler);
        connectionInfo.setConnectionProxy(proxy);
        final ProxyPhantomReference reference = new ProxyPhantomReference(interceptor, connectionInfo.getManagedConnectionInfo(), invocationHandler, referenceQueue);
        references.put(connectionInfo.getManagedConnectionInfo(), reference);
    } catch (final Throwable e) {
        throw new ResourceException("Unable to construct connection proxy", e);
    }
}
Also used : DissociatableManagedConnection(javax.resource.spi.DissociatableManagedConnection) ResourceException(javax.resource.ResourceException)

Aggregations

ResourceException (javax.resource.ResourceException)1 DissociatableManagedConnection (javax.resource.spi.DissociatableManagedConnection)1