use of org.springframework.beans.factory.BeanDefinitionStoreException in project spring-security by spring-projects.
the class AbstractUserDetailsServiceBeanDefinitionParser method resolveId.
private String resolveId(Element element, AbstractBeanDefinition definition, ParserContext pc) throws BeanDefinitionStoreException {
String id = element.getAttribute("id");
if (pc.isNested()) {
// We're inside an <authentication-provider> element
if (!StringUtils.hasText(id)) {
id = pc.getReaderContext().generateBeanName(definition);
}
BeanDefinition container = pc.getContainingBeanDefinition();
container.getPropertyValues().add("userDetailsService", new RuntimeBeanReference(id));
}
if (StringUtils.hasText(id)) {
return id;
}
// If top level, use the default name or throw an exception if already used
if (pc.getRegistry().containsBeanDefinition(BeanIds.USER_DETAILS_SERVICE)) {
throw new BeanDefinitionStoreException("No id supplied and another " + "bean is already registered as " + BeanIds.USER_DETAILS_SERVICE);
}
return BeanIds.USER_DETAILS_SERVICE;
}
use of org.springframework.beans.factory.BeanDefinitionStoreException in project spring-framework by spring-projects.
the class AopNamespaceHandlerPointcutErrorTests method testDuplicatePointcutConfig.
@Test
public void testDuplicatePointcutConfig() {
try {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(qualifiedResource(getClass(), "pointcutDuplication.xml"));
fail("parsing should have caused a BeanDefinitionStoreException");
} catch (BeanDefinitionStoreException ex) {
assertTrue(ex.contains(BeanDefinitionParsingException.class));
}
}
use of org.springframework.beans.factory.BeanDefinitionStoreException in project spring-framework by spring-projects.
the class AopNamespaceHandlerPointcutErrorTests method testMissingPointcutConfig.
@Test
public void testMissingPointcutConfig() {
try {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(qualifiedResource(getClass(), "pointcutMissing.xml"));
fail("parsing should have caused a BeanDefinitionStoreException");
} catch (BeanDefinitionStoreException ex) {
assertTrue(ex.contains(BeanDefinitionParsingException.class));
}
}
use of org.springframework.beans.factory.BeanDefinitionStoreException in project spring-boot by spring-projects.
the class BeanTypeRegistry method addBeanTypeForNonAliasDefinition.
private void addBeanTypeForNonAliasDefinition(String name) {
try {
String factoryName = BeanFactory.FACTORY_BEAN_PREFIX + name;
RootBeanDefinition beanDefinition = (RootBeanDefinition) this.beanFactory.getMergedBeanDefinition(name);
if (!beanDefinition.isAbstract() && !requiresEagerInit(beanDefinition.getFactoryBeanName())) {
if (this.beanFactory.isFactoryBean(factoryName)) {
Class<?> factoryBeanGeneric = getFactoryBeanGeneric(this.beanFactory, beanDefinition, name);
this.beanTypes.put(name, factoryBeanGeneric);
this.beanTypes.put(factoryName, this.beanFactory.getType(factoryName));
} else {
this.beanTypes.put(name, this.beanFactory.getType(name));
}
}
} catch (CannotLoadBeanClassException ex) {
// Probably contains a placeholder
logIgnoredError("bean class loading failure for bean", name, ex);
} catch (BeanDefinitionStoreException ex) {
// Probably contains a placeholder
logIgnoredError("unresolvable metadata in bean definition", name, ex);
}
}
use of org.springframework.beans.factory.BeanDefinitionStoreException in project spring-framework by spring-projects.
the class PropertyResourceConfigurerTests method testPropertyPlaceholderConfigurerWithCircularReference.
@Test
public void testPropertyPlaceholderConfigurerWithCircularReference() {
factory.registerBeanDefinition("tb", genericBeanDefinition(TestBean.class).addPropertyValue("age", "${age}").addPropertyValue("name", "name${var}").getBeanDefinition());
PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
Properties props = new Properties();
props.setProperty("age", "99");
props.setProperty("var", "${m}");
props.setProperty("m", "${var}");
ppc.setProperties(props);
try {
ppc.postProcessBeanFactory(factory);
fail("Should have thrown BeanDefinitionStoreException");
} catch (BeanDefinitionStoreException ex) {
// expected
}
}
Aggregations