use of javax.resource.spi.ConnectionEvent in project geode by apache.
the class JCAManagedConnection method onClose.
public void onClose(GFConnectionImpl connection) {
connection.invalidate();
this.connections.remove(connection);
synchronized (this.listeners) {
Iterator<ConnectionEventListener> iterator = this.listeners.iterator();
ConnectionEvent event = new ConnectionEvent(this, ConnectionEvent.CONNECTION_CLOSED);
event.setConnectionHandle(connection);
while (iterator.hasNext()) {
iterator.next().connectionClosed(event);
}
}
if (this.connections.isEmpty()) {
// safe to dissociate this managed connection so that it can go to pool
if (this.initialized && !this.cache.isClosed()) {
this.localTransaction = new JCALocalTransaction(this.cache, this.transactionManager);
} else {
this.localTransaction = new JCALocalTransaction();
}
}
}
use of javax.resource.spi.ConnectionEvent 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();
}
}
}
use of javax.resource.spi.ConnectionEvent in project cxf by apache.
the class AbstractManagedConnectionImpl method error.
public void error(Exception ex) {
LOG.warning(ex.toString());
sendEvent(new ConnectionEvent(this, ConnectionEvent.CONNECTION_ERROR_OCCURRED, ex));
}
use of javax.resource.spi.ConnectionEvent in project cxf by apache.
the class ManagedConnectionImplTest method testRemoveConnectionEventListener.
@Test
public void testRemoveConnectionEventListener() throws Exception {
ConnectionEvent event = new ConnectionEvent(mc, ConnectionEvent.CONNECTION_ERROR_OCCURRED);
ConnectionEventListener listener = EasyMock.createMock(ConnectionEventListener.class);
mc.addConnectionEventListener(listener);
listener.connectionErrorOccurred(EasyMock.isA(ConnectionEvent.class));
EasyMock.expectLastCall();
EasyMock.replay(listener);
mc.sendEvent(event);
EasyMock.verify(listener);
mc.removeConnectionEventListener(listener);
mc.sendEvent(event);
}
use of javax.resource.spi.ConnectionEvent in project cxf by apache.
the class ManagedConnectionImplTest method testSendEventTxStarted.
@Test
public void testSendEventTxStarted() throws Exception {
ConnectionEvent event = new ConnectionEvent(mc, ConnectionEvent.LOCAL_TRANSACTION_STARTED);
ConnectionEventListener listener = EasyMock.createMock(ConnectionEventListener.class);
mc.addConnectionEventListener(listener);
listener.localTransactionStarted(EasyMock.isA(ConnectionEvent.class));
EasyMock.expectLastCall();
EasyMock.replay(listener);
mc.sendEvent(event);
EasyMock.verify(listener);
}
Aggregations