|
|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2009 the original author or authors. |
|
|
|
* Copyright 2002-2012 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -20,23 +20,24 @@ import org.springframework.beans.BeansException; |
|
|
|
import org.springframework.util.StringUtils; |
|
|
|
import org.springframework.util.StringUtils; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Exception thrown when a BeanFactory is asked for a bean |
|
|
|
* Exception thrown when a {@code BeanFactory} is asked for a bean |
|
|
|
* instance name for which it cannot find a definition. |
|
|
|
* instance for which it cannot find a definition. |
|
|
|
* |
|
|
|
* |
|
|
|
* @author Rod Johnson |
|
|
|
* @author Rod Johnson |
|
|
|
* @author Juergen Hoeller |
|
|
|
* @author Juergen Hoeller |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
@SuppressWarnings("serial") |
|
|
|
public class NoSuchBeanDefinitionException extends BeansException { |
|
|
|
public class NoSuchBeanDefinitionException extends BeansException { |
|
|
|
|
|
|
|
|
|
|
|
/** Name of the missing bean */ |
|
|
|
/** Name of the missing bean. */ |
|
|
|
private String beanName; |
|
|
|
private String beanName; |
|
|
|
|
|
|
|
|
|
|
|
/** Required bean type */ |
|
|
|
/** Required type of the missing bean. */ |
|
|
|
private Class beanType; |
|
|
|
private Class<?> beanType; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Create a new NoSuchBeanDefinitionException. |
|
|
|
* Create a new {@code NoSuchBeanDefinitionException}. |
|
|
|
* @param name the name of the missing bean |
|
|
|
* @param name the name of the missing bean |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public NoSuchBeanDefinitionException(String name) { |
|
|
|
public NoSuchBeanDefinitionException(String name) { |
|
|
|
@ -45,7 +46,7 @@ public class NoSuchBeanDefinitionException extends BeansException { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Create a new NoSuchBeanDefinitionException. |
|
|
|
* Create a new {@code NoSuchBeanDefinitionException}. |
|
|
|
* @param name the name of the missing bean |
|
|
|
* @param name the name of the missing bean |
|
|
|
* @param message detailed message describing the problem |
|
|
|
* @param message detailed message describing the problem |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@ -55,31 +56,31 @@ public class NoSuchBeanDefinitionException extends BeansException { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Create a new NoSuchBeanDefinitionException. |
|
|
|
* Create a new {@code NoSuchBeanDefinitionException}. |
|
|
|
* @param type required type of bean |
|
|
|
* @param type required type of the missing bean |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public NoSuchBeanDefinitionException(Class type) { |
|
|
|
public NoSuchBeanDefinitionException(Class<?> type) { |
|
|
|
super("No unique bean of type [" + type.getName() + "] is defined"); |
|
|
|
super("No unique bean of type [" + type.getName() + "] is defined"); |
|
|
|
this.beanType = type; |
|
|
|
this.beanType = type; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Create a new NoSuchBeanDefinitionException. |
|
|
|
* Create a new {@code NoSuchBeanDefinitionException}. |
|
|
|
* @param type required type of bean |
|
|
|
* @param type required type of the missing bean |
|
|
|
* @param message detailed message describing the problem |
|
|
|
* @param message detailed message describing the problem |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public NoSuchBeanDefinitionException(Class type, String message) { |
|
|
|
public NoSuchBeanDefinitionException(Class<?> type, String message) { |
|
|
|
super("No unique bean of type [" + type.getName() + "] is defined: " + message); |
|
|
|
super("No unique bean of type [" + type.getName() + "] is defined: " + message); |
|
|
|
this.beanType = type; |
|
|
|
this.beanType = type; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Create a new NoSuchBeanDefinitionException. |
|
|
|
* Create a new {@code NoSuchBeanDefinitionException}. |
|
|
|
* @param type required type of bean |
|
|
|
* @param type required type of the missing bean |
|
|
|
* @param dependencyDescription a description of the originating dependency |
|
|
|
* @param dependencyDescription a description of the originating dependency |
|
|
|
* @param message detailed message describing the problem |
|
|
|
* @param message detailed message describing the problem |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public NoSuchBeanDefinitionException(Class type, String dependencyDescription, String message) { |
|
|
|
public NoSuchBeanDefinitionException(Class<?> type, String dependencyDescription, String message) { |
|
|
|
super("No matching bean of type [" + type.getName() + "] found for dependency" + |
|
|
|
super("No matching bean of type [" + type.getName() + "] found for dependency" + |
|
|
|
(StringUtils.hasLength(dependencyDescription) ? " [" + dependencyDescription + "]" : "") + |
|
|
|
(StringUtils.hasLength(dependencyDescription) ? " [" + dependencyDescription + "]" : "") + |
|
|
|
": " + message); |
|
|
|
": " + message); |
|
|
|
@ -88,18 +89,18 @@ public class NoSuchBeanDefinitionException extends BeansException { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Return the name of the missing bean, |
|
|
|
* Return the name of the missing bean, if it was a lookup <em>by name</em> |
|
|
|
* if it was a lookup by name that failed. |
|
|
|
* that failed. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public String getBeanName() { |
|
|
|
public String getBeanName() { |
|
|
|
return this.beanName; |
|
|
|
return this.beanName; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Return the required type of bean, |
|
|
|
* Return the required type of the missing bean, if it was a lookup |
|
|
|
* if it was a lookup by type that failed. |
|
|
|
* <em>by type</em> that failed. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public Class getBeanType() { |
|
|
|
public Class<?> getBeanType() { |
|
|
|
return this.beanType; |
|
|
|
return this.beanType; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|