javax.resource.spi.ConnectionEventListener Java Examples
The following examples show how to use
javax.resource.spi.ConnectionEventListener.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JCAManagedConnection.java From gemfirexd-oss with Apache License 2.0 | 7 votes |
public void onClose(GFConnectionImpl conn) throws ResourceException { conn.invalidate(); this.connections.remove(conn); synchronized (this.listeners) { Iterator<ConnectionEventListener> itr = this.listeners.iterator(); ConnectionEvent ce = new ConnectionEvent(this, ConnectionEvent.CONNECTION_CLOSED); ce.setConnectionHandle(conn); while (itr.hasNext()) { itr.next().connectionClosed(ce); } } if (this.connections.isEmpty()) { // safe to dissociate this managedconnection so that it can go to pool if (this.initDone && !this.cache.isClosed()) { this.localTran = new JCALocalTransaction(this.cache, this.gfTxMgr); } else { this.localTran = new JCALocalTransaction(); } } }
Example #2
Source File: PerfManagedConnection.java From ironjacamar with Eclipse Public License 1.0 | 6 votes |
/** * {@inheritDoc} */ public void commit() throws ResourceException { if (txCommitDuration > 0) { try { Thread.sleep(txCommitDuration); } catch (Exception e) { // Ignore } } ConnectionEvent ce = new ConnectionEvent(this, ConnectionEvent.LOCAL_TRANSACTION_COMMITTED); for (ConnectionEventListener cel : listeners) { cel.localTransactionCommitted(ce); } }
Example #3
Source File: ManagedPoolCacheImpl.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
/** * Destroys the underline physical connection to EIS. * * @param connectionObject connection Object. */ @Override void destroyPooledConnection(Object connectionObject) { try { ((ManagedConnection) connectionObject) .removeConnectionEventListener((ConnectionEventListener) connEventListner); ((ManagedConnection) connectionObject).destroy(); connectionObject = null; } catch (ResourceException rex) { LogWriterI18n writer = TransactionUtils.getLogWriterI18n(); if (writer.finerEnabled()) writer .finer( "ManagedPoolcacheImpl::destroyPooledConnection:Exception in closing the connection.Ignoring it. The exeption is " + rex.toString(), rex); } }
Example #4
Source File: AbstractManagedConnectionImpl.java From cxf with Apache License 2.0 | 6 votes |
protected void sendEventToListener(ConnectionEvent coEvent, ConnectionEventListener listener) { if (coEvent.getId() == ConnectionEvent.CONNECTION_CLOSED) { listener.connectionClosed(coEvent); LOG.log(Level.FINE, "CONNECTION_CLOSED_EVENT_FIRED", new Object[] {listener}); } if (coEvent.getId() == ConnectionEvent.LOCAL_TRANSACTION_COMMITTED) { listener.localTransactionCommitted(coEvent); LOG.log(Level.FINE, "LOCAL_TX_COMMITTED_EVENT_FIRED", new Object[] {listener}); } if (coEvent.getId() == ConnectionEvent.LOCAL_TRANSACTION_ROLLEDBACK) { listener.localTransactionRolledback(coEvent); LOG.log(Level.FINE, "LOCAL_TX_ROLLEDBACK_EVENT_FIRED", new Object[] {listener}); } if (coEvent.getId() == ConnectionEvent.LOCAL_TRANSACTION_STARTED) { listener.localTransactionStarted(coEvent); LOG.log(Level.FINE, "LOCAL_TX_STARTED_EVENT_FIRED", new Object[] {listener}); } if (coEvent.getId() == ConnectionEvent.CONNECTION_ERROR_OCCURRED) { listener.connectionErrorOccurred(coEvent); LOG.log(Level.FINE, "CTX_ERROR_OCURRED_EVENT_FIRED", new Object[] {listener}); } }
Example #5
Source File: ManagedConnectionImplTest.java From cxf with Apache License 2.0 | 6 votes |
@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); }
Example #6
Source File: PerfManagedConnection.java From ironjacamar with Eclipse Public License 1.0 | 6 votes |
/** * {@inheritDoc} */ public void rollback() throws ResourceException { if (txCommitDuration > 0) { try { Thread.sleep(txCommitDuration); } catch (Exception e) { // Ignore } } ConnectionEvent ce = new ConnectionEvent(this, ConnectionEvent.LOCAL_TRANSACTION_ROLLEDBACK); for (ConnectionEventListener cel : listeners) { cel.localTransactionRolledback(ce); } }
Example #7
Source File: JCAManagedConnection.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
private void onError(Exception e) { this.localTran = null; synchronized (this.connections) { Iterator<GFConnectionImpl> connsItr = this.connections.iterator(); while (connsItr.hasNext()) { GFConnectionImpl conn = connsItr.next(); conn.invalidate(); synchronized (this.listeners) { Iterator<ConnectionEventListener> itr = this.listeners.iterator(); ConnectionEvent ce = new ConnectionEvent(this, ConnectionEvent.CONNECTION_ERROR_OCCURRED, e); ce.setConnectionHandle(conn); while (itr.hasNext()) { itr.next().connectionErrorOccurred(ce); } } connsItr.remove(); } } }
Example #8
Source File: JCAManagedConnection.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
private void onError(Exception e) { this.localTran = null; synchronized (this.connections) { Iterator<GFConnectionImpl> connsItr = this.connections.iterator(); while (connsItr.hasNext()) { GFConnectionImpl conn = connsItr.next(); conn.invalidate(); synchronized (this.listeners) { Iterator<ConnectionEventListener> itr = this.listeners.iterator(); ConnectionEvent ce = new ConnectionEvent(this, ConnectionEvent.CONNECTION_ERROR_OCCURRED, e); ce.setConnectionHandle(conn); while (itr.hasNext()) { itr.next().connectionErrorOccurred(ce); } } connsItr.remove(); } } }
Example #9
Source File: ManagedConnectionImpl.java From cxf with Apache License 2.0 | 6 votes |
private void sendEventToListener(ConnectionEventListener listener, ConnectionEvent coEvent) { if (coEvent.getId() == ConnectionEvent.CONNECTION_CLOSED) { listener.connectionClosed(coEvent); } if (coEvent.getId() == ConnectionEvent.LOCAL_TRANSACTION_COMMITTED) { listener.localTransactionCommitted(coEvent); } if (coEvent.getId() == ConnectionEvent.LOCAL_TRANSACTION_ROLLEDBACK) { listener.localTransactionRolledback(coEvent); } if (coEvent.getId() == ConnectionEvent.LOCAL_TRANSACTION_STARTED) { listener.localTransactionStarted(coEvent); } if (coEvent.getId() == ConnectionEvent.CONNECTION_ERROR_OCCURRED) { listener.connectionErrorOccurred(coEvent); } }
Example #10
Source File: ManagedPoolCacheImpl.java From gemfirexd-oss with Apache License 2.0 | 6 votes |
/** * Destroys the underline physical connection to EIS. * * @param connectionObject connection Object. */ @Override void destroyPooledConnection(Object connectionObject) { try { ((ManagedConnection) connectionObject) .removeConnectionEventListener((ConnectionEventListener) connEventListner); ((ManagedConnection) connectionObject).destroy(); connectionObject = null; } catch (ResourceException rex) { LogWriterI18n writer = TransactionUtils.getLogWriterI18n(); if (writer.finerEnabled()) writer .finer( "ManagedPoolcacheImpl::destroyPooledConnection:Exception in closing the connection.Ignoring it. The exeption is " + rex.toString(), rex); } }
Example #11
Source File: HelloWorldManagedConnection.java From ironjacamar with Eclipse Public License 1.0 | 5 votes |
/** * default constructor * @param mcf mcf */ public HelloWorldManagedConnection(HelloWorldManagedConnectionFactory mcf) { this.mcf = mcf; this.logWriter = null; this.listeners = Collections.synchronizedList(new ArrayList<ConnectionEventListener>(1)); this.connections = new HashSet<HelloWorldConnectionImpl>(); }
Example #12
Source File: TxLogManagedConnection.java From ironjacamar with Eclipse Public License 1.0 | 5 votes |
/** * Default constructor * @param mcf mcf */ public TxLogManagedConnection(TxLogManagedConnectionFactory mcf) { this.mcf = mcf; this.id = Integer.toHexString(System.identityHashCode(this)); this.logwriter = null; this.listeners = Collections.synchronizedList(new ArrayList<ConnectionEventListener>(1)); this.connections = new HashSet<TxLogConnectionImpl>(); this.inPool = true; }
Example #13
Source File: SampleManagedConnection.java From tomee with Apache License 2.0 | 5 votes |
public void addConnectionEventListener(ConnectionEventListener listener) { log.finest("addConnectionEventListener()"); if (listener == null) { throw new IllegalArgumentException("Listener is null"); } listeners.add(listener); }
Example #14
Source File: PerfManagedConnection.java From ironjacamar with Eclipse Public License 1.0 | 5 votes |
/** * Close handle */ void closeHandle() { ConnectionEvent closeEvent = new ConnectionEvent(this, ConnectionEvent.CONNECTION_CLOSED); closeEvent.setConnectionHandle(connection); List<ConnectionEventListener> copy = new ArrayList<ConnectionEventListener>(listeners); for (ConnectionEventListener cel : copy) { cel.connectionClosed(closeEvent); } }
Example #15
Source File: HelloWorldManagedConnection.java From ironjacamar with Eclipse Public License 1.0 | 5 votes |
/** * Adds a connection event listener to the ManagedConnection instance. * * @param listener A new ConnectionEventListener to be registered */ public void addConnectionEventListener(ConnectionEventListener listener) { if (listener == null) throw new IllegalArgumentException("Listener is null"); listeners.add(listener); }
Example #16
Source File: HelloWorldManagedConnection.java From ironjacamar with Eclipse Public License 1.0 | 5 votes |
/** * Removes an already registered connection event listener * from the ManagedConnection instance. * * @param listener Already registered connection event listener to be removed */ public void removeConnectionEventListener(ConnectionEventListener listener) { if (listener == null) throw new IllegalArgumentException("Listener is null"); listeners.remove(listener); }
Example #17
Source File: HelloWorldManagedConnection.java From ironjacamar with Eclipse Public License 1.0 | 5 votes |
/** * Close handle * @param handle The handle */ void closeHandle(HelloWorldConnection handle) { connections.remove((HelloWorldConnectionImpl)handle); ConnectionEvent event = new ConnectionEvent(this, ConnectionEvent.CONNECTION_CLOSED); event.setConnectionHandle(handle); for (ConnectionEventListener cel : listeners) { cel.connectionClosed(event); } }
Example #18
Source File: JcaExecutorServiceManagedConnection.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
void closeHandle(JcaExecutorServiceConnection handle) { ConnectionEvent event = new ConnectionEvent(this, ConnectionEvent.CONNECTION_CLOSED); event.setConnectionHandle(handle); for (ConnectionEventListener cel : listeners) { cel.connectionClosed(event); } }
Example #19
Source File: HelloWorldManagedConnection.java From ironjacamar with Eclipse Public License 1.0 | 5 votes |
/** * Constructor * @param mcf mcf */ public HelloWorldManagedConnection(HelloWorldManagedConnectionFactory mcf) { this.mcf = mcf; this.logWriter = null; this.listeners = Collections.synchronizedList(new ArrayList<ConnectionEventListener>(1)); this.connections = new HashSet<HelloWorldConnectionImpl>(); }
Example #20
Source File: PerfManagedConnection.java From ironjacamar with Eclipse Public License 1.0 | 5 votes |
/** * Error handle */ void errorHandle() { ConnectionEvent errorEvent = new ConnectionEvent(this, ConnectionEvent.CONNECTION_ERROR_OCCURRED, new Exception()); errorEvent.setConnectionHandle(connection); List<ConnectionEventListener> copy = new ArrayList<ConnectionEventListener>(listeners); for (ConnectionEventListener cel : copy) { cel.connectionErrorOccurred(errorEvent); } }
Example #21
Source File: TxLogManagedConnection.java From ironjacamar with Eclipse Public License 1.0 | 5 votes |
/** * Error handle * * @param handle The handle * @param exception The exception */ void errorHandle(TxLogConnection handle, Exception exception) { connections.remove((TxLogConnectionImpl)handle); ConnectionEvent event = new ConnectionEvent(this, ConnectionEvent.CONNECTION_ERROR_OCCURRED, exception); event.setConnectionHandle(handle); List<ConnectionEventListener> copy = new ArrayList<ConnectionEventListener>(listeners); for (ConnectionEventListener cel : copy) { cel.connectionErrorOccurred(event); } }
Example #22
Source File: PerfManagedConnection.java From ironjacamar with Eclipse Public License 1.0 | 5 votes |
/** * Removes an already registered connection event listener from the ManagedConnection instance. * * @param listener already registered connection event listener to be removed */ public void removeConnectionEventListener(ConnectionEventListener listener) { if (listener == null) throw new IllegalArgumentException("Listener is null"); listeners.remove(listener); }
Example #23
Source File: SampleManagedConnection.java From tomee with Apache License 2.0 | 5 votes |
public void addConnectionEventListener(ConnectionEventListener listener) { log.finest("addConnectionEventListener()"); if (listener == null) { throw new IllegalArgumentException("Listener is null"); } listeners.add(listener); }
Example #24
Source File: PerfManagedConnection.java From ironjacamar with Eclipse Public License 1.0 | 5 votes |
/** * Default constructor * @param mcf mcf * @param tb Transaction begin duration * @param tc Transaction commit duration */ public PerfManagedConnection(PerfManagedConnectionFactory mcf, long tb, long tc) { this.mcf = mcf; this.txBeginDuration = tb; this.txCommitDuration = tc; this.logwriter = null; this.listeners = Collections.synchronizedList(new ArrayList<ConnectionEventListener>(1)); this.connection = new PerfConnectionImpl(this); }
Example #25
Source File: AutoConnectionTrackerTest.java From tomee with Apache License 2.0 | 5 votes |
@Override public void removeConnectionEventListener(final ConnectionEventListener listener) { if (listener == null) { throw new IllegalArgumentException("Listener is null"); } listeners.remove(listener); }
Example #26
Source File: HelloWorldManagedConnection.java From ironjacamar with Eclipse Public License 1.0 | 5 votes |
/** * Close handle * @param handle The handle */ void closeHandle(HelloWorldConnection handle) { connections.remove((HelloWorldConnectionImpl)handle); ConnectionEvent event = new ConnectionEvent(this, ConnectionEvent.CONNECTION_CLOSED); event.setConnectionHandle(handle); for (ConnectionEventListener cel : listeners) { cel.connectionClosed(event); } }
Example #27
Source File: LazyManagedConnection.java From ironjacamar with Eclipse Public License 1.0 | 5 votes |
/** * Adds a connection event listener to the ManagedConnection instance. * * @param listener A new ConnectionEventListener to be registered */ public void addConnectionEventListener(ConnectionEventListener listener) { log.trace("addConnectionEventListener()"); if (listener == null) throw new IllegalArgumentException("Listener is null"); listeners.add(listener); }
Example #28
Source File: WorkManagedConnection.java From ironjacamar with Eclipse Public License 1.0 | 5 votes |
/** * Close handle * * @param handle The handle */ void closeHandle(WorkConnection handle) { ConnectionEvent event = new ConnectionEvent(this, ConnectionEvent.CONNECTION_CLOSED); event.setConnectionHandle(handle); for (ConnectionEventListener cel : listeners) { cel.connectionClosed(event); } }
Example #29
Source File: WorkManagedConnection.java From ironjacamar with Eclipse Public License 1.0 | 5 votes |
/** * Removes an already registered connection event listener from the ManagedConnection instance. * * @param listener already registered connection event listener to be removed */ public void removeConnectionEventListener(ConnectionEventListener listener) { if (listener == null) throw new IllegalArgumentException("Listener is null"); listeners.remove(listener); }
Example #30
Source File: HelloWorldManagedConnectionImpl.java From ci.maven with Apache License 2.0 | 5 votes |
public void close() { Enumeration list = listeners.elements(); ConnectionEvent event = new ConnectionEvent(this, ConnectionEvent.CONNECTION_CLOSED); event.setConnectionHandle(connection); while (list.hasMoreElements()) { ((ConnectionEventListener) list.nextElement()).connectionClosed(event); } }