protected ConnectionListener validateConnectionListener(Collection<ConnectionListener> listeners,
                                                           ConnectionListener cl,
                                                           int newState)
   {
      ManagedConnectionFactory mcf = pool.getConnectionManager().getManagedConnectionFactory();

      if (mcf instanceof ValidatingManagedConnectionFactory)
      {
         ValidatingManagedConnectionFactory vcf = (ValidatingManagedConnectionFactory)mcf;
         try
         {
            Set candidateSet = Collections.singleton(cl.getManagedConnection());
            candidateSet = vcf.getInvalidConnections(candidateSet);

            if (candidateSet != null && !candidateSet.isEmpty())
            {
               if (Tracer.isEnabled())
                  Tracer.destroyConnectionListener(pool.getConfiguration().getId(), this, cl, false, false, true, false,
                        false, false, false, Tracer.isRecordCallstacks() ? new Throwable("CALLSTACK") : null);

               destroyAndRemoveConnectionListener(cl, listeners);
            }
            else
            {
               cl.validated();
               if (cl.changeState(VALIDATION, newState))
               {
                  return cl;
               }
               else
               {
                  if (Tracer.isEnabled())
                     Tracer.destroyConnectionListener(pool.getConfiguration().getId(), this, cl, false, false, true,
                           false, false, false, false, Tracer.isRecordCallstacks() ? new Throwable("CALLSTACK") : null);

                  destroyAndRemoveConnectionListener(cl, listeners);
               }
            }
         }
         catch (ResourceException re)
         {
            if (Tracer.isEnabled())
               Tracer.destroyConnectionListener(pool.getConfiguration().getId(), this, cl, false, false, true, false,
                     false, false, false, Tracer.isRecordCallstacks() ? new Throwable("CALLSTACK") : null);

            destroyAndRemoveConnectionListener(cl, listeners);
         }
      }
      else
      {
         log.debug("mcf is not instance of ValidatingManagedConnectionFactory");
         if (cl.changeState(VALIDATION, newState))
         {
            return cl;
         }
         else
         {
            if (Tracer.isEnabled())
               Tracer.destroyConnectionListener(pool.getConfiguration().getId(), this, cl, false, false, true, false,
                     false, false, false, Tracer.isRecordCallstacks() ? new Throwable("CALLSTACK") : null);
            destroyAndRemoveConnectionListener(cl, listeners);
         }
      }

      return null;
   }
protected ConnectionListener validateConnectionListener ( Collection < ConnectionListener > listeners , ConnectionListener cl , int newState ) { ManagedConnectionFactory mcf = pool . getConnectionManager ( ) . getManagedConnectionFactory ( ) ; if ( mcf instanceof ValidatingManagedConnectionFactory ) { ValidatingManagedConnectionFactory vcf = ( ValidatingManagedConnectionFactory ) mcf ; try { Set candidateSet = Collections . singleton ( cl . getManagedConnection ( ) ) ; candidateSet = vcf . getInvalidConnections ( candidateSet ) ; if ( candidateSet != null && ! candidateSet . isEmpty ( ) ) { if ( Tracer . isEnabled ( ) ) Tracer . destroyConnectionListener ( pool . getConfiguration ( ) . getId ( ) , this , cl , false , false , true , false , false , false , false , Tracer . isRecordCallstacks ( ) ? new Throwable ( "CALLSTACK" ) : null ) ; destroyAndRemoveConnectionListener ( cl , listeners ) ; } else { cl . validated ( ) ; if ( cl . changeState ( VALIDATION , newState ) ) { return cl ; } else { if ( Tracer . isEnabled ( ) ) Tracer . destroyConnectionListener ( pool . getConfiguration ( ) . getId ( ) , this , cl , false , false , true , false , false , false , false , Tracer . isRecordCallstacks ( ) ? new Throwable ( "CALLSTACK" ) : null ) ; destroyAndRemoveConnectionListener ( cl , listeners ) ; } } } catch ( ResourceException re ) { if ( Tracer . isEnabled ( ) ) Tracer . destroyConnectionListener ( pool . getConfiguration ( ) . getId ( ) , this , cl , false , false , true , false , false , false , false , Tracer . isRecordCallstacks ( ) ? new Throwable ( "CALLSTACK" ) : null ) ; destroyAndRemoveConnectionListener ( cl , listeners ) ; } } else { log . debug ( "mcf is not instance of ValidatingManagedConnectionFactory" ) ; if ( cl . changeState ( VALIDATION , newState ) ) { return cl ; } else { if ( Tracer . isEnabled ( ) ) Tracer . destroyConnectionListener ( pool . getConfiguration ( ) . getId ( ) , this , cl , false , false , true , false , false , false , false , Tracer . isRecordCallstacks ( ) ? new Throwable ( "CALLSTACK" ) : null ) ; destroyAndRemoveConnectionListener ( cl , listeners ) ; } } return null ; }
Validate a connection listener
@param listeners The listeners
@param cl The connection listener
@param newState The new state
@return The validated connection listener, or <code>null</code> if validation failed