if (beanName != null && !SpringCoreUtils.hasPlaceHolder(beanName) && !ignorableBeans.contains(beanName)) {
try {
BeanDefinition refBd = context.getCompleteRegistry().getBeanDefinition(beanName);
if (refBd.isAbstract() || (refBd.getBeanClassName() == null && refBd.getFactoryBeanName() == null)) {
context.error(element, "INVALID_REFERENCED_BEAN", "Referenced bean '" + beanName + "' is invalid "
+ "(abstract or no bean class and " + "no factory bean)", new ValidationProblemAttribute(
"BEAN", beanName), new ValidationProblemAttribute("BEAN_NAME", ValidationRuleUtils.getBeanName(element)));
}
}
catch (NoSuchBeanDefinitionException e) {
// Handle factory bean references
if (ValidationRuleUtils.isFactoryBeanReference(beanName)) {
String tempBeanName = beanName.replaceFirst(ValidationRuleUtils.FACTORY_BEAN_REFERENCE_REGEXP, "");
try {
BeanDefinition def = context.getCompleteRegistry().getBeanDefinition(tempBeanName);
String beanClassName = def.getBeanClassName();
if (beanClassName != null) {
IType type = JdtUtils.getJavaType(BeansModelUtils.getProject(element).getProject(),
beanClassName);
if (type != null) {
if (!JdtUtils.doesImplement(context.getRootElementResource(), type, FactoryBean.class
.getName())) {
context.error(element, "INVALID_FACTORY_BEAN", "Referenced factory bean '"
+ tempBeanName + "' does not implement the " + "interface 'FactoryBean'",
new ValidationProblemAttribute("BEAN", tempBeanName),
new ValidationProblemAttribute("BEAN_NAME", ValidationRuleUtils.getBeanName(element)));
}
}
else {
context.warning(element, "INVALID_REFERENCED_BEAN", "Referenced factory bean '"
+ tempBeanName + "' implementation class not found",
new ValidationProblemAttribute("BEAN", tempBeanName),
new ValidationProblemAttribute("BEAN_NAME", ValidationRuleUtils.getBeanName(element)));
}
}
}
catch (NoSuchBeanDefinitionException be) {
context.warning(element, "UNDEFINED_FACTORY_BEAN", "Referenced factory bean '" + tempBeanName
+ "' not found", new ValidationProblemAttribute("BEAN", tempBeanName),
new ValidationProblemAttribute("BEAN_NAME", ValidationRuleUtils.getBeanName(element)));
}
catch (BeanDefinitionStoreException be) {
// ignore unresolvable parent bean exceptions
}
}
else {
if (element instanceof BeanProperty) {
context.warning(element, "UNDEFINED_REFERENCED_BEAN", "Referenced bean '" + beanName
+ "' not found", new ValidationProblemAttribute("BEAN", beanName),
new ValidationProblemAttribute("BEAN_NAME", ValidationRuleUtils.getBeanName(element)));
} else {
context.warning(element, "UNDEFINED_REFERENCED_BEAN", "Referenced bean '" + beanName
+ "' not found", new ValidationProblemAttribute("BEAN", beanName),
new ValidationProblemAttribute("BEAN_NAME", ValidationRuleUtils.getBeanName(element)));
}
}
}
catch (BeanDefinitionStoreException e) {