Find a ConnectionListener instance
@param mc The associated ManagedConnection
@param c The connection (optional)
@param listeners The listeners
@return The ConnectionListener, or <code>null</code>
483282
protected ConnectionListener findConnectionListener(ManagedConnection mc, Object c,
                                                       Collection<ConnectionListener> listeners)
   {
      for (ConnectionListener cl : listeners)
      {
         if (cl.getManagedConnection().equals(mc) && (c == null || cl.getConnections().contains(c)))
            return cl;
      }

      return null;
   }
1140419
private Object openConnection(ManagedConnection mc, Subject s) throws ResourceException
   {
      if (plugin == null)
         return null;

      log.debugf("Open connection (%s, %s)", mc, s);

      return mc.getConnection(s, null);
   }
1072100
public void addConnectionListener(KNXListener l)
	{
		if (l == null)
			return;
		synchronized (listeners) {
			if (!listeners.contains(l)) {
				listeners.add(l);
				listenersCopy = new ArrayList(listeners);
			}
			else
				logger.warn("event listener already registered");
		}
	}
838166
public Listener<Listeners<T>> getOrCreateListener()
   {
      List<Node> nodeList = childNode.get("listener");
      if (nodeList != null &&  nodeList.size() > 0)
      {
         return new ListenerImpl<Listeners<T>>(this, "listener", childNode, nodeList.get(0));
      }
      return createListener();
   }
706907
void addNetworkReachabilityListener(NetworkReachabilityListener listener) {
        synchronized (listeners) {
            listeners.add(listener);
            if (listeners.size() == 1) { startListening(); }
        }
    }
1049035
protected SQLListenerContextImpl startContext(Connection connection, QueryMetadata metadata) {
        SQLListenerContextImpl context = new SQLListenerContextImpl(metadata, connection);
        if (parentContext != null) {
            context.setData(PARENT_CONTEXT, parentContext);
        }
        listeners.start(context);
        return context;
    }
112421
protected MCWrapper createManagedConnectionWithMCWrapper(
                                                             ManagedConnectionFactory managedConnectionFactory,
                                                             Subject subject,
                                                             ConnectionRequestInfo cri,
                                                             boolean connectionSharing, int hashCode) throws ResourceAllocationException { // This method is called within a synchronize block
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.entry(this, tc, "createManagedConnectionWithMCWrapper");
        }

        ManagedConnection mc = null;
        MCWrapper mcWrapper = null;
        try {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                Tr.debug(this, tc, "raClassLoader", raClassLoader);

            JcaServiceUtilities jcasu = new JcaServiceUtilities();
            if (raClassLoader == null) {
                mc = managedConnectionFactory.createManagedConnection(subject, cri);
            } else {
                ClassLoader previousClassLoader = jcasu.beginContextClassLoader(raClassLoader);
                try {
                    mc = managedConnectionFactory.createManagedConnection(subject, cri);
                } finally {
                    jcasu.endContextClassLoader(raClassLoader, previousClassLoader);
                }
            }
            mcWrapper = new com.ibm.ejs.j2c.MCWrapper(pm, gConfigProps);
            mcWrapper.setManagedConnection(mc);

            /*
             * Many threads can hit the following code at the same time. What I a
             * expect to happen is that several threads will hit the synchronized
             * call until the checkForNoPoolingException is set to false.
             */
            if (pm.gConfigProps.checkManagedConnectionInstanceof) {
                /*
                 * Allow only one thread at a time through the following code
                 */
                /*
                 * Double-checked locking works for 32-bit primitive values. I am
                 * using a boolean primitive value.
                 */
                synchronized (pm.gConfigProps.checkManagedConnectionInstanceofLock) {
                    if (pm.gConfigProps.checkManagedConnectionInstanceof) {
                        /*
                         * Call matchManagedConnections
                         */
                        Set<ManagedConnection> s = new HashSet<ManagedConnection>();
                        s.add(mc);
                        try {
                            int poolState = mcWrapper.getPoolState();
                            mcWrapper.setPoolState(50);
                            managedConnectionFactory.matchManagedConnections(s, subject, cri);
                            mcWrapper.setPoolState(poolState);
                        } catch (NotSupportedException e) {
                            /*
                             * If we catch a the NotSupportedException, we need
                             * to turn off connection pooling.
                             */
                            gConfigProps.setConnectionPoolingEnabled(false);
                        }

                        if (mc instanceof DissociatableManagedConnection) {
                            /*
                             * set smart handle supported
                             */
                            pm.gConfigProps.setSmartHandleSupport(true);
                            pm.createParkedConnection = false;
                            pm.gConfigProps.setInstanceOfDissociatableManagedConnection(true);
                        }

                        if (mc instanceof DissociatableManagedConnection) {
                            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                                Tr.debug(this, tc, "Managed connection is an instance of DissociatableManagedConnection");
                            }
                            pm.gConfigProps.setInstanceOfDissociatableManagedConnection(true);
                        }

                        /*
                         * Deferred enlistment
                         */
                        if (mc instanceof LazyEnlistableManagedConnection) {
                            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                                Tr.debug(this, tc, "Managed connection is an instance of LazyEnlistableManagedConnection");
                            }
                            pm.gConfigProps.setDynamicEnlistmentSupported(true);
                        }

                        /*
                         * Create the writer for the managed connection.
                         */
                        pm.writer = new TraceWriter(mc.getClass().getName());
                        pm.traceWriter = (TraceWriter) pm.writer;
                        pm.printWriter = new PrintWriter(pm.writer);

                        /*
                         * We only want to execute this code once
                         * Set this value last in this synchronized block.
                         */
                        pm.gConfigProps.setCheckManagedConnectionInstanceof(false);

                    } // moved brace to include above call to setCheckManagedConnectionInstanceof
                } // end synchronize
            }

            if (tc.isDebugEnabled()) {
                ++freePoolCreateManagedConnection;
            }

            mcWrapper.setFatalErrorValue(fatalErrorNotificationTime + 1);
            mcWrapper.setSubjectCRIHashCode(hashCode);
            mcWrapper.setSubject(subject);
            ((com.ibm.ejs.j2c.MCWrapper) mcWrapper).set_managedConnectionFactory(managedConnectionFactory);
            mcWrapper.setCRI(cri);
            mcWrapper.setSupportsReAuth(gConfigProps.raSupportsReauthentication);
            mcWrapper.setConnectionSynchronizationProvider(gConfigProps.connectionSynchronizationProvider);

            /*
             * Check to see if trace has been turned on for
             * the managed connection.
             */
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(this, tc, "pm = ", pm);
                Tr.debug(this, tc, "traceWriter = ", pm.traceWriter);
            }
            if (pm.traceWriter.isTraceEnabled()) {
                /*
                 * Set the log writer on mc
                 */
                mc.setLogWriter(pm.printWriter);
                mcWrapper.setLogWriterSet(true);
            }

            /*
             * Make sure conneciton pooling is enabled. The reaper is not needed for
             * non poolable resource adapters.
             *
             * First check to see if reaper time is set. We will not be starting the reaper thread unless
             * its set.
             *
             * Next, check to see if its already running.
             */
            if (gConfigProps.isConnectionPoolingEnabled()) {
                if ((pm.reapTime > 0)) {
                    if (pm.alarmThreadCounter.get() == 0) {
                        synchronized (pm.amLockObject) {
                            if (pm.alarmThreadCounter.get() == 0) {
                                /*
                                 * If totalConnectionCount is > minConnections and agedTimeout is not set, start
                                 * the reaper thread.
                                 *
                                 * If agedTimeout is set and totalConnectionCount is > 0 start the reaper
                                 * thread.
                                 */
                                if (pm.agedTimeout < 1) {
                                    if ((pm.totalConnectionCount.get() > pm.minConnections)) {
                                        if (pm.nonDeferredReaperAlarm) {
                                            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                                                Tr.debug(this, tc, "Creating non-deferrable alarm for reaper");
                                            }
                                            pm.alarmThreadCounter.incrementAndGet();
                                            try {
                                                pm.am = pm.connectorSvc.nonDeferrableSchedXSvcRef.getServiceWithException().schedule(pm, pm.reapTime, TimeUnit.SECONDS);
                                            } catch (Exception e) {
                                                pm.alarmThreadCounter.decrementAndGet();
                                                throw e;
                                            }
                                        } else {
                                            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                                                Tr.debug(this, tc, "Creating deferrable alarm for reaper");
                                            }
                                            pm.alarmThreadCounter.incrementAndGet();
                                            try {
                                                pm.am = pm.connectorSvc.deferrableSchedXSvcRef.getServiceWithException().schedule(pm, pm.reapTime, TimeUnit.SECONDS);
                                            } catch (Exception e) {
                                                pm.alarmThreadCounter.decrementAndGet();
                                                throw e;
                                            }
                                        }
                                    }
                                } else {
                                    if (pm.totalConnectionCount.get() > 0) {
                                        if (pm.nonDeferredReaperAlarm) {
                                            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                                                Tr.debug(this, tc, "Creating non-deferrable alarm for reaper");
                                            }
                                            pm.alarmThreadCounter.incrementAndGet();
                                            try {
                                                pm.am = pm.connectorSvc.nonDeferrableSchedXSvcRef.getServiceWithException().schedule(pm, pm.reapTime, TimeUnit.SECONDS);
                                            } catch (Exception e) {
                                                pm.alarmThreadCounter.decrementAndGet();
                                                throw e;
                                            }
                                        } else {
                                            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                                                Tr.debug(this, tc, "Creating deferrable alarm for reaper");
                                            }
                                            pm.alarmThreadCounter.incrementAndGet();
                                            try {
                                                pm.am = pm.connectorSvc.deferrableSchedXSvcRef.getServiceWithException().schedule(pm, pm.reapTime, TimeUnit.SECONDS);
                                            } catch (Exception e) {
                                                pm.alarmThreadCounter.decrementAndGet();
                                                throw e;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        } catch (ResourceException exn) {
            com.ibm.ws.ffdc.FFDCFilter.processException(
                                                        exn,
                                                        "com.ibm.ejs.j2c.poolmanager.FreePool.createManagedConnectionWithMCWrapper",
                                                        "199",
                                                        this);
            // call exceptionList method to print stack traces of current and linked exceptions
            Object[] parms = new Object[] { "createManagedConnectionWithMCWrapper", CommonFunction.exceptionList(exn), "ResourceAllocationException", gConfigProps.cfName };
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(this, tc, "POOL_MANAGER_EXCP_CCF2_0002_J2CA0046", parms);
            }
            ResourceAllocationException throwMe = new ResourceAllocationException(exn.getMessage(), exn.getErrorCode());
            throwMe.initCause(exn.getCause());
            pm.activeRequest.decrementAndGet();
            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                Tr.exit(this, tc, "createManagedConnectionWithMCWrapper", throwMe);
            throw (throwMe);

        } catch (Exception e) {
            com.ibm.ws.ffdc.FFDCFilter.processException(
                                                        e,
                                                        "com.ibm.ejs.j2c.poolmanager.FreePool.createManagedConnectionWithMCWrapper",
                                                        "545",
                                                        this);
            // call exceptionList method to print stack traces of current and linked exceptions
            Object[] parms = new Object[] { "createManagedConnectionWithMCWrapper", CommonFunction.exceptionList(e), "ResourceAllocationException", gConfigProps.cfName };
            Tr.error(tc, "POOL_MANAGER_EXCP_CCF2_0002_J2CA0046", parms);
            ResourceAllocationException throwMe = new ResourceAllocationException(e.getMessage());
            throwMe.initCause(e);
            pm.activeRequest.decrementAndGet();
            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                Tr.exit(this, tc, "createManagedConnectionWithMCWrapper", throwMe);
            throw (throwMe);
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.exit(this, tc, "createManagedConnectionWithMCWrapper", mcWrapper);
        }
        return mcWrapper;

    }
731445
@Override
  public void addListener(INetworkConnectionListener listener) {
    if (!this.listeners.contains(listener)) {
      this.listeners.add(listener);
    }
  }
747327
public static synchronized void clearConnectionListener(String poolName, Object mcp, Object cl)
   {
      log.tracef("%s", new TraceEvent(poolName,
                                      Integer.toHexString(System.identityHashCode(mcp)),
                                      TraceEvent.CLEAR_CONNECTION_LISTENER,
                                      Integer.toHexString(System.identityHashCode(cl))));
   }
540063
private void createSingleListener(final SibRaMessagingEngineConnection connection) throws ResourceException
    {
        final String methodName = "createSingleListener";
        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled())
        {
            SibTr.entry(this, TRACE, methodName, connection);
        }

        final SIDestinationAddress destination = _endpointConfiguration.getDestination();

        if (TraceComponent.isAnyTracingEnabled() && TRACE.isDebugEnabled())
        {
            SibTr.debug(TRACE, "Creating a consumer to consume from destination "
                               + destination + " on ME " + connection.getConnection().getMeName());
        }

        try
        {
            connection.createListener(destination, _messageEndpointFactory);
            SibTr.info(TRACE, "CONNECTED_CWSIV0777", new Object[] {
                                                                   connection.getConnection().getMeName(),
                                                                   _endpointConfiguration.getDestination()
                                                                                   .getDestinationName(),
                                                                   _endpointConfiguration.getBusName() });
        } catch (final IllegalStateException exception)
        {
            // No FFDC code needed
            if (TraceComponent.isAnyTracingEnabled() && TRACE.isDebugEnabled())
            {
                SibTr.debug(TRACE, "Failed to create a session - blowing away the connection - rethrow the exception");
            }

            _connections.remove(connection.getConnection().getMeUuid());
            connection.close();
            if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled())
            {
                SibTr.exit(this, TRACE, methodName);
            }
            throw exception;
        } catch (final ResourceException exception)
        {
            // No FFDC code needed

            // Failed to create a consumer so blow away the connection and try
            // again
            if (TraceComponent.isAnyTracingEnabled() && TRACE.isDebugEnabled())
            {
                SibTr.debug(TRACE, "Failed to create a session - blowing away the connection - a retry should occur");
                SibTr.debug(TRACE, "Exception cause was " + exception.getCause());
            }

            _connections.remove(connection.getConnection().getMeUuid());
            connection.close();
            throw exception;
        }

        if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
            SibTr.exit(this, TRACE, methodName);
        }
    }
1240944
public void connect(Connection c) {

        schemaFilter = null;

        if (c == null) {
            return;
        }

        if (cConn != null) {
            try {
                cConn.close();
            } catch (SQLException e) {

                //  Added: (weconsultants@users)
                CommonSwing.errorMessage(e);
            }
        }

        cConn = c;

        // Added: (weconsultants@users) Need to barrow to get the table rowcounts
        rowConn = c;

        try {
            dMeta      = cConn.getMetaData();
            isOracle = (dMeta.getDatabaseProductName().indexOf("Oracle") >= 0);
            sStatement = cConn.createStatement();

            updateAutoCommitBox();

            // Workaround for EXTREME SLOWNESS getting this info from O.
            showIndexDetails = !isOracle;

            Driver driver = DriverManager.getDriver(dMeta.getURL());
            ConnectionSetting newSetting = new ConnectionSetting(
                dMeta.getDatabaseProductName(), driver.getClass().getName(),
                dMeta.getURL(),
                dMeta.getUserName().replaceAll("@localhost", ""), "");
            Hashtable settings =
                ConnectionDialogCommon.loadRecentConnectionSettings();

            ConnectionDialogCommon.addToRecentConnectionSettings(settings,
                    newSetting);
            ConnectionDialogSwing.setConnectionSetting(newSetting);
            refreshTree();
            clearResultPanel();

            if (fMain instanceof JApplet) {
                getAppletContext().showStatus(
                    "JDBC Connection established to a "
                    + dMeta.getDatabaseProductName() + " v. "
                    + dMeta.getDatabaseProductVersion() + " database as '"
                    + dMeta.getUserName() + "'.");
            }
        } catch (SQLException e) {

            //  Added: (weconsultants@users)
            CommonSwing.errorMessage(e);
        } catch (IOException e) {

            //  Added: (weconsultants@users)
            CommonSwing.errorMessage(e);
        } catch (Exception e) {
            CommonSwing.errorMessage(e);
        }
    }
925574
public VaadinForHeroku withApplicationListener(final String... listeners){
        checkVarArgsArguments(listeners);
        this.applicationListeners.addAll(Arrays.asList(listeners));
        return self();
    }
898776
protected void destroyAndRemoveConnectionListener(ConnectionListener cl, Collection<ConnectionListener> listeners)
   {
      try
      {
         pool.destroyConnectionListener(cl);
      }
      catch (ResourceException e)
      {
         // TODO:
         cl.setState(ZOMBIE);
      }
      finally
      {
         listeners.remove(cl);
      }
   }
108219
public List<ConnectionListener> getConnectionListeners() {
        if (changes == null) {
            return (List<ConnectionListener>)Collections.EMPTY_LIST;
        }

        List<EventListener> listeners = changes.getListenerList(AMQP);
        if ((listeners == null) || listeners.isEmpty()) {
            return (List<ConnectionListener>)Collections.EMPTY_LIST;
        }

        ArrayList<ConnectionListener> list = new ArrayList<ConnectionListener>();
        for (EventListener listener : listeners) {
            list.add((ConnectionListener)listener);
        }

        return list;
    }
554362
def lookupListener(self, listenID):
        
        if listenID in self.inboundConnections:
            # Make the connection?
            cwait, call = self.inboundConnections.pop(listenID)
            # _ConnectionWaiter instance
            call.cancel()
            return cwait
1321284
@Override
    public void addConnectionListener(SICoreConnectionListener listener)
                    throws SIConnectionDroppedException,
                    SIConnectionUnavailableException {

        checkValid();

        _delegateConnection.addConnectionListener(listener);

    }
342458
protected SQLListenerContextImpl startContext(Connection connection, QueryMetadata metadata, RelationalPath<?> entity) {
        SQLListenerContextImpl context = new SQLListenerContextImpl(metadata, connection, entity);
        listeners.start(context);
        return context;
    }