List of usage examples for org.springframework.beans.factory.support DefaultListableBeanFactory DefaultListableBeanFactory
public DefaultListableBeanFactory(@Nullable BeanFactory parentBeanFactory)
From source file:com.technoetic.xplanner.importer.BaseTestCase.java
public static void pushNewFactory() { MainBeanFactory.factory = new DefaultListableBeanFactory(MainBeanFactory.factory); }
From source file:com.gwtplatform.dispatch.rpc.server.spring.utils.SpringUtils.java
@SuppressWarnings("unchecked") public static <B> B instantiate(ApplicationContext applicationContext, Class<B> clazz) throws BeansException { DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory(applicationContext); return (B) beanFactory.createBean(clazz, AbstractBeanDefinition.AUTOWIRE_CONSTRUCTOR, false); }
From source file:gov.nih.nci.cabig.ctms.web.tabs.StaticTabConfigurer.java
@Override protected AutowireCapableBeanFactory getBeanFactory() { return new DefaultListableBeanFactory(staticFactory); }
From source file:com.gwtplatform.dispatch.rpc.server.spring.utils.SpringUtils.java
public static <B> B getInstance(ApplicationContext applicationContext, Class<B> clazz) throws BeansException { DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory(applicationContext); return beanFactory.getBean(clazz); }
From source file:com.mtgi.analytics.aop.config.TemplateBeanDefinitionParser.java
/** * <p>Load the template BeanDefinition and call {@link #transform(ConfigurableListableBeanFactory, BeanDefinition, Element, ParserContext)} * to apply runtime configuration value to it. <code>builder</code> will be configured to instantiate the bean * in the Spring context that we are parsing.</p> * //from w w w. j a v a 2 s .c o m * <p>During parsing, an instance of {@link TemplateBeanDefinitionParser.TemplateComponentDefinition} is pushed onto <code>ParserContext</code> so * that nested tags can access the enclosing template configuration with a call to {@link #findEnclosingTemplateFactory(ParserContext)}. * Subclasses can override {@link #newComponentDefinition(String, Object, DefaultListableBeanFactory)} to provide a * subclass of {@link TemplateBeanDefinitionParser.TemplateComponentDefinition} to the parser context if necessary.</p> */ @Override protected final void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { //if we have multiple nested bean definitions, we only parse the template factory //once. this allows configuration changes made by enclosing bean parsers to be inherited //by contained beans, which is quite useful. DefaultListableBeanFactory templateFactory = findEnclosingTemplateFactory(parserContext); TemplateComponentDefinition tcd = null; if (templateFactory == null) { //no nesting -- load the template XML configuration from the classpath. final BeanFactory parentFactory = (BeanFactory) parserContext.getRegistry(); templateFactory = new DefaultListableBeanFactory(parentFactory); //load template bean definitions DefaultResourceLoader loader = new DefaultResourceLoader(); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(templateFactory); reader.setResourceLoader(loader); reader.setEntityResolver(new ResourceEntityResolver(loader)); reader.loadBeanDefinitions(templateResource); //propagate factory post-processors from the source factory into the template //factory. BeanDefinition ppChain = new RootBeanDefinition(ChainingBeanFactoryPostProcessor.class); ppChain.getPropertyValues().addPropertyValue("targetFactory", templateFactory); parserContext.getReaderContext().registerWithGeneratedName(ppChain); //push component definition onto the parser stack for the benefit of //nested bean definitions. tcd = newComponentDefinition(element.getNodeName(), parserContext.extractSource(element), templateFactory); parserContext.pushContainingComponent(tcd); } try { //allow subclasses to apply overrides to the template bean definition. BeanDefinition def = templateFactory.getBeanDefinition(templateId); transform(templateFactory, def, element, parserContext); //setup our factory bean to instantiate the modified bean definition upon request. builder.addPropertyValue("beanFactory", templateFactory); builder.addPropertyValue("beanName", templateId); builder.getRawBeanDefinition().setAttribute("id", def.getAttribute("id")); } finally { if (tcd != null) parserContext.popContainingComponent(); } }
From source file:org.openvpms.component.business.service.scheduler.JobRunner.java
/** * Creates the job.//from w w w . j a v a 2s . com * * @return a new job * @throws ClassNotFoundException if the job class cannot be found */ private Job createJob() throws ClassNotFoundException { Job result; IMObjectBean bean = new IMObjectBean(configuration, service); Class type = Class.forName(bean.getString("class")); DefaultListableBeanFactory factory = new DefaultListableBeanFactory(context); factory.registerSingleton("jobConfiguration", configuration); Object job = factory.createBean(type, AutowireCapableBeanFactory.AUTOWIRE_CONSTRUCTOR, true); if (job instanceof Runnable) { result = new DelegatingJob((Runnable) job); } else { result = (Job) job; } return result; }
From source file:com.googlecode.ehcache.annotations.impl.CacheAttributeSourceImpl.java
public void setBeanFactory(BeanFactory beanFactory) throws BeansException { this.beanFactory = beanFactory; this.childBeanFactory = new DefaultListableBeanFactory(this.beanFactory); }
From source file:com.googlecode.ehcache.annotations.key.SpELCacheKeyGenerator.java
public void setBeanFactory(BeanFactory beanFactory) throws BeansException { this.beanFactory = beanFactory; this.cacheKeyBeanFactory = new DefaultListableBeanFactory(this.beanFactory); }
From source file:org.eclipse.gemini.blueprint.compendium.internal.cm.ManagedServiceFactoryFactoryBean.java
private void createEmbeddedBeanFactory() { synchronized (monitor) { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(owningBeanFactory); if (owningBeanFactory instanceof ConfigurableBeanFactory) { bf.copyConfigurationFrom((ConfigurableBeanFactory) owningBeanFactory); }/*from w w w . j a v a 2s .c o m*/ // just to be on the safe side bf.setBeanClassLoader(classLoader); // add autowiring processor bf.addBeanPostProcessor(new InitialInjectionProcessor()); beanFactory = bf; } }