Examples of ConnectionEventListener


Examples of javax.resource.spi.ConnectionEventListener

    public void localTransactionStartedEvent(MockConnection mockConnection) {
        ConnectionEvent connectionEvent = new ConnectionEvent(this, ConnectionEvent.LOCAL_TRANSACTION_STARTED);
        connectionEvent.setConnectionHandle(mockConnection);
        for (Iterator iterator = new ArrayList(connectionEventListeners).iterator(); iterator.hasNext();) {
            ConnectionEventListener connectionEventListener = (ConnectionEventListener) iterator.next();
            connectionEventListener.localTransactionStarted(connectionEvent);
        }
    }
View Full Code Here

Examples of javax.resource.spi.ConnectionEventListener

    public void localTransactionCommittedEvent(MockConnection mockConnection) {
        ConnectionEvent connectionEvent = new ConnectionEvent(this, ConnectionEvent.LOCAL_TRANSACTION_COMMITTED);
        connectionEvent.setConnectionHandle(mockConnection);
        for (Iterator iterator = new ArrayList(connectionEventListeners).iterator(); iterator.hasNext();) {
            ConnectionEventListener connectionEventListener = (ConnectionEventListener) iterator.next();
            connectionEventListener.localTransactionCommitted(connectionEvent);
        }
    }
View Full Code Here

Examples of javax.resource.spi.ConnectionEventListener

    public void localTransactionRolledBackEvent(MockConnection mockConnection) {
        ConnectionEvent connectionEvent = new ConnectionEvent(this, ConnectionEvent.LOCAL_TRANSACTION_ROLLEDBACK);
        connectionEvent.setConnectionHandle(mockConnection);
        for (Iterator iterator = new ArrayList(connectionEventListeners).iterator(); iterator.hasNext();) {
            ConnectionEventListener connectionEventListener = (ConnectionEventListener) iterator.next();
            connectionEventListener.localTransactionRolledback(connectionEvent);
        }
    }
View Full Code Here

Examples of javax.resource.spi.ConnectionEventListener

        sendConnectionEvent(connEvent);
    }

    protected void sendConnectionEvent(ConnectionEvent connEvent) {
        for (int i = listeners.size() - 1; i >= 0; i--) {
            ConnectionEventListener listener =
                listeners.get(i);
            if (connEvent.getId() == ConnectionEvent.CONNECTION_CLOSED) {
                listener.connectionClosed(connEvent);
            } else if (connEvent.getId() ==
                       ConnectionEvent.CONNECTION_ERROR_OCCURRED) {
                listener.connectionErrorOccurred(connEvent);
            } else if (connEvent.getId() ==
                       ConnectionEvent.LOCAL_TRANSACTION_STARTED) {
                listener.localTransactionStarted(connEvent);
            } else if (connEvent.getId() ==
                       ConnectionEvent.LOCAL_TRANSACTION_COMMITTED) {
                listener.localTransactionCommitted(connEvent);
            } else if (connEvent.getId() ==
                       ConnectionEvent.LOCAL_TRANSACTION_ROLLEDBACK) {
                listener.localTransactionRolledback(connEvent);
            }
        }
    }
View Full Code Here

Examples of javax.resource.spi.ConnectionEventListener

     * Send event.
     */
    private void sendEvent(ConnectionEvent event) {
        synchronized (listeners) {
            for (Iterator<ConnectionEventListener> i = listeners.iterator(); i.hasNext();) {
                ConnectionEventListener listener = i.next();

                switch (event.getId()) {
                    case ConnectionEvent.CONNECTION_CLOSED:
                        listener.connectionClosed(event);
                        break;
                    case ConnectionEvent.CONNECTION_ERROR_OCCURRED:
                        listener.connectionErrorOccurred(event);
                        break;
                    case ConnectionEvent.LOCAL_TRANSACTION_COMMITTED:
                        listener.localTransactionCommitted(event);
                        break;
                    case ConnectionEvent.LOCAL_TRANSACTION_ROLLEDBACK:
                        listener.localTransactionRolledback(event);
                        break;
                    case ConnectionEvent.LOCAL_TRANSACTION_STARTED:
                        listener.localTransactionStarted(event);
                        break;
                    default:
                        // Unknown event, skip
                }
            }
View Full Code Here

Examples of javax.resource.spi.ConnectionEventListener

     * Send event.
     */
    private void sendEvent(ConnectionEvent event) {
        synchronized (listeners) {
            for (Iterator<ConnectionEventListener> i = listeners.iterator(); i.hasNext();) {
                ConnectionEventListener listener = i.next();

                switch (event.getId()) {
                    case ConnectionEvent.CONNECTION_CLOSED:
                        listener.connectionClosed(event);
                        break;
                    case ConnectionEvent.CONNECTION_ERROR_OCCURRED:
                        listener.connectionErrorOccurred(event);
                        break;
                    case ConnectionEvent.LOCAL_TRANSACTION_COMMITTED:
                        listener.localTransactionCommitted(event);
                        break;
                    case ConnectionEvent.LOCAL_TRANSACTION_ROLLEDBACK:
                        listener.localTransactionRolledback(event);
                        break;
                    case ConnectionEvent.LOCAL_TRANSACTION_STARTED:
                        listener.localTransactionStarted(event);
                        break;
                    default:
                        // Unknown event, skip
                }
            }
View Full Code Here

Examples of javax.sql.ConnectionEventListener

   */
  protected synchronized void notifyListener(SQLException e){
    if(listeners != null && !listeners.isEmpty()){
      Iterator iter = listeners.iterator();
      while(iter.hasNext()){
        ConnectionEventListener listener = (ConnectionEventListener)iter.next();
        if(e == null){
          //no exception
          listener.connectionClosed(new ConnectionEvent(this));
        }else{
          //exception occurred
          listener.connectionErrorOccurred(new ConnectionEvent(this, e))
        }
      }
    } 
  }
View Full Code Here

Examples of javax.sql.ConnectionEventListener

        }

        int traceId = ((JdbcXAConnection) xaConn).getTraceId();
        assertTrue(xaConn.toString().startsWith("xads" + traceId + ": conn"));

        xaConn.addConnectionEventListener(new ConnectionEventListener() {
            public void connectionClosed(ConnectionEvent event) {
                // nothing to do
            }

            public void connectionErrorOccurred(ConnectionEvent event) {
View Full Code Here

Examples of javax.sql.ConnectionEventListener

        ConnectionImpl c = Mockito.mock(ConnectionImpl.class);
        Mockito.doThrow(new SQLException(new InvalidSessionException())).when(c).commit();
        return c;
      }
    });
    ConnectionEventListener cel = Mockito.mock(ConnectionEventListener.class);
    xaConn.addConnectionEventListener(cel);
    Connection c = xaConn.getConnection();
    try {
      c.commit();
    } catch (SQLException e) {
View Full Code Here

Examples of javax.sql.ConnectionEventListener

        debugCode("closedHandle();");
        ConnectionEvent event = new ConnectionEvent(this);
        // go backward so that a listener can remove itself
        // (otherwise we need to clone the list)
        for (int i = listeners.size() - 1; i >= 0; i--) {
            ConnectionEventListener listener = listeners.get(i);
            listener.connectionClosed(event);
        }
        handleConn = null;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.