org.springframework.jndi.TypeMismatchNamingException Java Examples

The following examples show how to use org.springframework.jndi.TypeMismatchNamingException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SimpleJndiBeanFactory.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@SuppressWarnings("unchecked")
private <T> T doGetSingleton(String name, @Nullable Class<T> requiredType) throws NamingException {
	synchronized (this.singletonObjects) {
		Object singleton = this.singletonObjects.get(name);
		if (singleton != null) {
			if (requiredType != null && !requiredType.isInstance(singleton)) {
				throw new TypeMismatchNamingException(convertJndiName(name), requiredType, singleton.getClass());
			}
			return (T) singleton;
		}
		T jndiObject = lookup(name, requiredType);
		this.singletonObjects.put(name, jndiObject);
		return jndiObject;
	}
}