Search in sources :

Example 1 with GFConnectionImpl

use of org.apache.geode.internal.ra.GFConnectionImpl in project geode by apache.

the class JCAManagedConnection method cleanup.

@Override
public void cleanup() throws ResourceException {
    synchronized (this.connections) {
        Iterator<GFConnectionImpl> iterator = this.connections.iterator();
        while (iterator.hasNext()) {
            GFConnectionImpl connection = iterator.next();
            connection.invalidate();
            iterator.remove();
        }
    }
    if (this.localTransaction == null || this.localTransaction.transactionInProgress()) {
        if (this.initialized && !this.cache.isClosed()) {
            this.localTransaction = new JCALocalTransaction(this.cache, this.transactionManager);
        } else {
            this.localTransaction = new JCALocalTransaction();
        }
    }
}
Also used : GFConnectionImpl(org.apache.geode.internal.ra.GFConnectionImpl)

Example 2 with GFConnectionImpl

use of org.apache.geode.internal.ra.GFConnectionImpl in project geode by apache.

the class JCAManagedConnection method destroy.

@Override
public void destroy() throws ResourceException {
    synchronized (this.connections) {
        Iterator<GFConnectionImpl> iterator = this.connections.iterator();
        while (iterator.hasNext()) {
            GFConnectionImpl connection = iterator.next();
            connection.invalidate();
            iterator.remove();
        }
    }
    this.transactionManager = null;
    this.cache = null;
    this.localTransaction = null;
    this.listeners.clear();
}
Also used : GFConnectionImpl(org.apache.geode.internal.ra.GFConnectionImpl)

Example 3 with GFConnectionImpl

use of org.apache.geode.internal.ra.GFConnectionImpl in project geode by apache.

the class JCAManagedConnection method getConnection.

@Override
public Object getConnection(Subject arg0, ConnectionRequestInfo arg1) throws ResourceException {
    if (!this.initialized || this.cache.isClosed()) {
        init();
    }
    LogWriter logger = this.cache.getLogger();
    if (logger.fineEnabled()) {
        logger.fine("JCAManagedConnection:getConnection. Returning new Connection");
    }
    GFConnectionImpl connection = new GFConnectionImpl(this);
    this.connections.add(connection);
    return connection;
}
Also used : LogWriter(org.apache.geode.LogWriter) GFConnectionImpl(org.apache.geode.internal.ra.GFConnectionImpl)

Example 4 with GFConnectionImpl

use of org.apache.geode.internal.ra.GFConnectionImpl in project geode by apache.

the class JCAManagedConnection method onError.

private void onError(Exception e) {
    // TODO: currently unused
    this.localTransaction = null;
    synchronized (this.connections) {
        Iterator<GFConnectionImpl> iterator = this.connections.iterator();
        while (iterator.hasNext()) {
            GFConnectionImpl connection = iterator.next();
            connection.invalidate();
            synchronized (this.listeners) {
                ConnectionEvent event = new ConnectionEvent(this, ConnectionEvent.CONNECTION_ERROR_OCCURRED, e);
                event.setConnectionHandle(connection);
                for (ConnectionEventListener listener : this.listeners) {
                    listener.connectionErrorOccurred(event);
                }
            }
            iterator.remove();
        }
    }
}
Also used : GFConnectionImpl(org.apache.geode.internal.ra.GFConnectionImpl) ConnectionEvent(javax.resource.spi.ConnectionEvent) ConnectionEventListener(javax.resource.spi.ConnectionEventListener)

Aggregations

GFConnectionImpl (org.apache.geode.internal.ra.GFConnectionImpl)4 ConnectionEvent (javax.resource.spi.ConnectionEvent)1 ConnectionEventListener (javax.resource.spi.ConnectionEventListener)1 LogWriter (org.apache.geode.LogWriter)1