config/src/main/java/org/springframework/security/config/http/UserDetailsServiceFactoryBean.java
private UserDetailsService getUserDetailsService() {
		Map<String, ?> beans = getBeansOfType(CachingUserDetailsService.class);

		if (beans.size() == 0) {
			beans = getBeansOfType(UserDetailsService.class);
		}

		if (beans.size() == 0) {
			throw new ApplicationContextException("No UserDetailsService registered.");

		}
		else if (beans.size() > 1) {
			throw new ApplicationContextException(
					"More than one UserDetailsService registered. Please "
							+ "use a specific Id reference in <remember-me/> <openid-login/> or <x509 /> elements.");
		}

		return (UserDetailsService) beans.values().toArray()[0];
	}
private UserDetailsService getUserDetailsService() {
		Map<String, ?> beans = getBeansOfType(CachingUserDetailsService.class);

		if (beans.size() == 0) {
			beans = getBeansOfType(UserDetailsService.class);
		}

		if (beans.size() == 0) {
			throw new ApplicationContextException("No UserDetailsService registered.");

		}
		else if (beans.size() > 1) {
			throw new ApplicationContextException(
					"More than one UserDetailsService registered. Please "
							+ "use a specific Id reference in <remember-me/> <openid-login/> or <x509 /> elements.");
		}

		return (UserDetailsService) beans.values().toArray()[0];
	}
Obtains a user details service for use in RememberMeServices etc. Will return a
caching version if available so should not be used for beans which need to separate
the two.