@ Override final public ManagedConnection matchManagedConnections ( final Set connectionSet , final Subject subject , final ConnectionRequestInfo requestInfo ) { if ( TraceComponent . isAnyTracingEnabled ( ) && TRACE . isEntryEnabled ( ) ) { SibTr . entry ( TRACE , "matchManagedConnections" , new Object [ ] { connectionSet , JmsJcaManagedConnection . subjectToString ( subject ) , requestInfo } ) ; } final SICoreConnection coreConnection = ( requestInfo instanceof JmsJcaConnectionRequestInfo ) ? ( ( JmsJcaConnectionRequestInfo ) requestInfo ) . getSICoreConnection ( ) : null ; final JmsJcaUserDetails userDetails = getUserDetails ( subject , requestInfo ) ; if ( TraceComponent . isAnyTracingEnabled ( ) && TRACE . isDebugEnabled ( ) ) { if ( userDetails != null ) { SibTr . debug ( TRACE , "Got a username and password" ) ; } else { SibTr . debug ( TRACE , "Using subject" ) ; } } JmsJcaManagedConnection matchedConnection = null ; // Go through the set of managed connections and try and match one for ( final Iterator iterator = connectionSet . iterator ( ) ; iterator . hasNext ( ) ; ) { final Object object = iterator . next ( ) ; // Skip over any non JmsJcaManagedConnections if ( object instanceof JmsJcaManagedConnection ) { final JmsJcaManagedConnection managedConnection = ( JmsJcaManagedConnection ) object ; // If we have a user name and password from either the // requestInfo or subject then we must try and match againgst // those if ( userDetails != null ) { if ( managedConnection . match ( userDetails , coreConnection ) ) { matchedConnection = managedConnection ; if ( TraceComponent . isAnyTracingEnabled ( ) && TRACE . isDebugEnabled ( ) ) { SibTr . debug ( TRACE , "Matched a connection against the subject username and password" ) ; } break ; } } else { // This is a subject where we couldnt get the userName and // password from.. if ( managedConnection . match ( subject , coreConnection ) ) { matchedConnection = managedConnection ; if ( TraceComponent . isAnyTracingEnabled ( ) && TRACE . isDebugEnabled ( ) ) { SibTr . debug ( TRACE , "Matched a connection against the subject" ) ; } break ; } } } } if ( TraceComponent . isAnyTracingEnabled ( ) && TRACE . isEntryEnabled ( ) ) { SibTr . exit ( TRACE , "matchManagedConnections" , matchedConnection ) ; } return matchedConnection ; }
Returns a matching connection from the candidate set of connections .