private < V > V autoDetectService ( String serviceName , ConcurrentServiceReferenceMap < String , V > map ) { Iterator < V > services = map . getServices ( ) ; if ( services . hasNext ( ) == false ) { Tr . error ( tc , "SECURITY_SERVICE_NO_SERVICE_AVAILABLE" , serviceName ) ; throw new IllegalStateException ( Tr . formatMessage ( tc , "SECURITY_SERVICE_NO_SERVICE_AVAILABLE" , serviceName ) ) ; } V service = services . next ( ) ; if ( services . hasNext ( ) ) { Tr . error ( tc , "SECURITY_SERVICE_MULTIPLE_SERVICE_AVAILABLE" , serviceName ) ; throw new IllegalStateException ( Tr . formatMessage ( tc , "SECURITY_SERVICE_MULTIPLE_SERVICE_AVAILABLE" , serviceName ) ) ; } return service ; }
When the configuration element is not defined use some auto - detect logic to try and return the single Service of a specified field . If there is no service or multiple services that is considered an error case which auto - detect can not resolve .