use of org.springframework.beans.factory.BeanDefinitionStoreException in project aries by apache.
the class BlueprintBeanFactory method registerBeanDefinition.
@Override
public void registerBeanDefinition(String beanName, BeanDefinition beanDefinition) throws BeanDefinitionStoreException {
ComponentDefinitionRegistry registry = container.getComponentDefinitionRegistry();
ComponentMetadata metadata = registry.getComponentDefinition(beanName);
if (metadata != null && !(metadata instanceof SpringMetadata)) {
throw new BeanDefinitionStoreException(beanDefinition.getResourceDescription(), beanName, "Cannot register bean definition [" + beanDefinition + "] for bean '" + beanName + "': There is already bound.");
}
super.registerBeanDefinition(beanName, beanDefinition);
if (!beanDefinition.isAbstract()) {
registry.registerComponentDefinition(new SpringMetadata(beanName));
}
}
use of org.springframework.beans.factory.BeanDefinitionStoreException in project grails-core by grails.
the class GrailsPlaceholderConfigurer method doProcessProperties.
@Override
protected void doProcessProperties(ConfigurableListableBeanFactory beanFactoryToProcess, StringValueResolver valueResolver) {
BeanDefinitionVisitor visitor = new BeanDefinitionVisitor(valueResolver) {
@Override
protected void visitMap(Map<?, ?> mapVal) {
if (mapVal instanceof Config)
return;
super.visitMap(mapVal);
}
};
String[] beanNames = beanFactoryToProcess.getBeanDefinitionNames();
for (String curName : beanNames) {
// to avoid failing on unresolvable placeholders in properties file locations.
if (!(curName.equals(this.beanName) && beanFactoryToProcess.equals(this.beanFactory))) {
BeanDefinition bd = beanFactoryToProcess.getBeanDefinition(curName);
try {
visitor.visitBeanDefinition(bd);
} catch (Exception ex) {
throw new BeanDefinitionStoreException(bd.getResourceDescription(), curName, ex.getMessage(), ex);
}
}
}
// New in Spring 2.5: resolve placeholders in alias target names and aliases as well.
beanFactoryToProcess.resolveAliases(valueResolver);
// New in Spring 3.0: resolve placeholders in embedded values such as annotation attributes.
beanFactoryToProcess.addEmbeddedValueResolver(valueResolver);
}
use of org.springframework.beans.factory.BeanDefinitionStoreException in project cas by apereo.
the class BeanDefinitionStoreFailureAnalyzerTests method createFailure.
private BeanDefinitionStoreException createFailure() {
val bf = new DefaultListableBeanFactory();
bf.registerBeanDefinition("testBean", genericBeanDefinition(CasServerProperties.class).addPropertyValue("name", "${not.defined}").getBeanDefinition());
val ppc = new PropertySourcesPlaceholderConfigurer();
try {
ppc.postProcessBeanFactory(bf);
} catch (final BeanDefinitionStoreException e) {
return e;
}
return null;
}
use of org.springframework.beans.factory.BeanDefinitionStoreException in project cxf by apache.
the class SpringServiceBuilderFactory method getApplicationContext.
/**
* This is factored out to permit use in a unit test.
*
* @param additionalFilePathnames
* @return
*/
public static ApplicationContext getApplicationContext(List<String> additionalFilePathnames) {
BusApplicationContext busApplicationContext = BusFactory.getDefaultBus().getExtension(BusApplicationContext.class);
GenericApplicationContext appContext = new GenericApplicationContext(busApplicationContext);
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(appContext);
List<URL> urls = ClassLoaderUtils.getResources("META-INF/cxf/java2wsbeans.xml", SpringServiceBuilderFactory.class);
for (URL url : urls) {
reader.loadBeanDefinitions(new UrlResource(url));
}
for (String pathname : additionalFilePathnames) {
try {
reader.loadBeanDefinitions(new FileSystemResource(pathname));
} catch (BeanDefinitionStoreException bdse) {
throw new ToolException("Unable to open bean definition file " + pathname, bdse.getCause());
}
}
appContext.refresh();
return appContext;
}
Aggregations