protected < T > boolean tryToWire ( Class < T > type ) { boolean success = false ; String className = type . getName ( ) ; Map < String , T > map = getApplicationConfig ( ) . applicationContext ( ) . getBeansOfType ( type ) ; if ( logger . isDebugEnabled ( ) ) { logger . debug ( "Search for '" + className + "' found: " + map ) ; } if ( map . size ( ) == 1 ) { // Got one - wire it in Map . Entry entry = map . entrySet ( ) . iterator ( ) . next ( ) ; String name = ( String ) entry . getKey ( ) ; AuthenticationManager am = ( AuthenticationManager ) entry . getValue ( ) ; setAuthenticationManager ( am ) ; success = true ; if ( logger . isInfoEnabled ( ) ) { logger . info ( "Auto-configuration using '" + name + "' as authenticationManager" ) ; } } else if ( map . size ( ) > 1 ) { if ( logger . isInfoEnabled ( ) ) { logger . info ( "Need a single '" + className + "', found: " + map . keySet ( ) ) ; } } else { // Size 0, no potentials if ( logger . isInfoEnabled ( ) ) { logger . info ( "Auto-configuration did not find a suitable authenticationManager of type " + type ) ; } } return success ; }
Try to locate and wire in a suitable authentication manager .