/**
* Creates a <code>DefaultListableBeanFactory</code> with some default
* settings, i.e.
* <ul>
* <li>support of auto-wiring annotation</li>
* <li>disabled bean-overriding</li>
* </ul>
*
* @param enableAutoWiring
* <code>true</code> if auto-wiring for the factory should be
* enabled, otherwise <code>false</code>
* @param allowBeanOverriding
* <code>true</code> if a bean can override another bean with the
* same id, otherwise <code>false</code>
*
* @return a <code>DefaultListableBeanFactory</code> with some default
* settings
*
* @see AutowiredAnnotationBeanPostProcessor
* @see DefaultListableBeanFactory#setAllowBeanDefinitionOverriding
*/
public static DefaultListableBeanFactory createBeanFactory(
final boolean enableAutoWiring, final boolean allowBeanOverriding) {
// create the factory
final DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
factory.setAllowBeanDefinitionOverriding(allowBeanOverriding);
// enable auto-wiring
if (enableAutoWiring) {
// get the resolver used for autowiring, we want the qualifier to be
// used
// when resolving
final AutowireCandidateResolver resolver = new QualifierAnnotationAutowireCandidateResolver();
factory.setAutowireCandidateResolver(resolver);
// now create the post processor and set the factory and the
// resolver
final AutowiredAnnotationBeanPostProcessor autowiredPostProcessor = new AutowiredAnnotationBeanPostProcessor();
autowiredPostProcessor.setBeanFactory(factory);
factory.addBeanPostProcessor(autowiredPostProcessor);
}
factory.addPropertyEditorRegistrar(new ConfiguratorPropertyEditorRegistrar());
return factory;
}
SpringHelper.java 文件源码
java
阅读 27
收藏 0
点赞 0
评论 0
项目:gen-sbconfigurator
作者:
评论列表
文章目录