List of usage examples for org.springframework.beans.factory BeanIsAbstractException BeanIsAbstractException
public BeanIsAbstractException(String beanName)
From source file:org.springframework.beans.factory.support.AbstractBeanFactory.java
/** * Check the given merged bean definition, * potentially throwing validation exceptions. * @param mergedBeanDefinition the bean definition to check * @param beanName the name of the bean/*from ww w. j av a 2 s . com*/ * @param requiredType the required type of the bean * @param args the arguments for bean creation, if any * @throws BeansException in case of validation failure */ protected void checkMergedBeanDefinition(RootBeanDefinition mergedBeanDefinition, String beanName, Class requiredType, Object[] args) throws BeansException { // check if bean definition is not abstract if (mergedBeanDefinition.isAbstract()) { throw new BeanIsAbstractException(beanName); } // Check if required type can match according to the bean definition. // This is only possible at this early stage for conventional beans! if (mergedBeanDefinition.hasBeanClass()) { Class beanClass = mergedBeanDefinition.getBeanClass(); if (requiredType != null && mergedBeanDefinition.getFactoryMethodName() == null && !FactoryBean.class.isAssignableFrom(beanClass) && !requiredType.isAssignableFrom(beanClass)) { throw new BeanNotOfRequiredTypeException(beanName, requiredType, beanClass); } } // Check validity of the usage of the args parameter. This can // only be used for prototypes constructed via a factory method. if (args != null) { if (mergedBeanDefinition.isSingleton()) { throw new BeanDefinitionStoreException( "Cannot specify arguments in the getBean() method when referring to a singleton bean definition"); } else if (mergedBeanDefinition.getFactoryMethodName() == null) { throw new BeanDefinitionStoreException( "Can only specify arguments in the getBean() method in conjunction with a factory method"); } } }