Package org.springframework.beans.factory.support

Examples of org.springframework.beans.factory.support.DefaultListableBeanFactory


    GenericBeanDefinition definition = new GenericBeanDefinition();
    definition.setBeanClass(SqlSessionFactoryBean.class);
    definition.getPropertyValues().add("dataSource", new MockDataSource());

    DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
    factory.registerBeanDefinition("sqlSessionFactory", definition);

    genericApplicationContext.registerBeanDefinition("sqlSessionFactory", definition);

    genericApplicationContext.refresh();
View Full Code Here


          .getBeanFactory().getBeanDefinition(beanName);

      // PropertyResourceConfigurer does not expose any methods to explicitly perform
      // property placeholder substitution. Instead, create a BeanFactory that just
      // contains this mapper scanner and post process the factory.
      DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
      factory.registerBeanDefinition(beanName, mapperScannerBean);

      for (PropertyResourceConfigurer prc : prcs.values()) {
        prc.postProcessBeanFactory(factory);
      }
View Full Code Here

* @author Tom Baeyens
*/
public class BeansConfigurationHelper {

  public static ProcessEngineConfiguration parseProcessEngineConfiguration(Resource springResource, String beanName) {
    DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
    XmlBeanDefinitionReader xmlBeanDefinitionReader = new XmlBeanDefinitionReader(beanFactory);
    xmlBeanDefinitionReader.setValidationMode(XmlBeanDefinitionReader.VALIDATION_XSD);
    xmlBeanDefinitionReader.loadBeanDefinitions(springResource);
    ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) beanFactory.getBean(beanName);
    processEngineConfiguration.setBeans(new SpringBeanFactoryProxyMap(beanFactory));
    return processEngineConfiguration;
  }
View Full Code Here

        if (DynamicDeployUtil.isReload() && DynamicDeployUtil.isReloadResource(_SPRING_CONFIG_NAME)) {
            try {
//                ClassLoader loader = LoaderUtil.getCurrentLoaderParentLoader();
//                Thread.currentThread().setContextClassLoader(loader);
                XmlWebApplicationContext xmlWebApplicationContext = (XmlWebApplicationContext) ContextLoader.getCurrentWebApplicationContext();
                DefaultListableBeanFactory defaultListableBeanFactory = (DefaultListableBeanFactory) xmlWebApplicationContext.getBeanFactory();
                Properties pros = new Properties();
                defaultListableBeanFactory.setBeanClassLoader(LoaderUtil.getClassLoader());
                pros.load(new ByteArrayInputStream(DynamicDeployUtil.findResource(_SPRING_CONFIG_NAME)));
                for (String key : pros.stringPropertyNames()) {
                    BeanDefinition beanDefinition = defaultListableBeanFactory.getBeanDefinition(key);
                    beanDefinition.setBeanClassName(pros.getProperty(key));
                    defaultListableBeanFactory.registerBeanDefinition(key, beanDefinition);
                }
            } catch (IOException ex) {
                Logger.getLogger(SpringDynamicBeanLoader.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
View Full Code Here

        mr.render();
    }

    private static BeanFactory getBeanFactory() throws Exception {
        // get the bean factory
        DefaultListableBeanFactory factory = new DefaultListableBeanFactory();

        // create a definition reader
        PropertiesBeanDefinitionReader rdr = new PropertiesBeanDefinitionReader(
                factory);
View Full Code Here

        mr.render();
    }

    private static BeanFactory getBeanFactory() throws Exception {
        // get the bean factory
        DefaultListableBeanFactory factory = new DefaultListableBeanFactory();

        // create a definition reader
        PropertiesBeanDefinitionReader rdr = new PropertiesBeanDefinitionReader(
                factory);
View Full Code Here

    if (logger.isDebugEnabled()) {
      logger.debug("Configuring AbstractBeanFactoryBasedTargetSource: " + targetSource);
    }

    DefaultListableBeanFactory internalBeanFactory = getInternalBeanFactoryForBean(beanName);

    // We need to override just this bean definition, as it may reference other beans
    // and we're happy to take the parent's definition for those.
    // Always use prototype scope if demanded.
    BeanDefinition bd = this.beanFactory.getMergedBeanDefinition(beanName);
    GenericBeanDefinition bdCopy = new GenericBeanDefinition(bd);
    if (isPrototypeBased()) {
      bdCopy.setScope(BeanDefinition.SCOPE_PROTOTYPE);
    }
    internalBeanFactory.registerBeanDefinition(beanName, bdCopy);

    // Complete configuring the PrototypeTargetSource.
    targetSource.setTargetBeanName(beanName);
    targetSource.setBeanFactory(internalBeanFactory);
View Full Code Here

   * Return the internal BeanFactory to be used for the specified bean.
   * @param beanName the name of the target bean
   * @return the internal BeanFactory to be used
   */
  protected DefaultListableBeanFactory getInternalBeanFactoryForBean(String beanName) {
    DefaultListableBeanFactory internalBeanFactory = null;
    synchronized (this.internalBeanFactories) {
      internalBeanFactory = (DefaultListableBeanFactory) this.internalBeanFactories.get(beanName);
      if (internalBeanFactory == null) {
        internalBeanFactory = buildInternalBeanFactory(this.beanFactory);
        this.internalBeanFactories.put(beanName, internalBeanFactory);
View Full Code Here

   * @param containingFactory the containing BeanFactory that originally defines the beans
   * @return an independent internal BeanFactory to hold copies of some target beans
   */
  protected DefaultListableBeanFactory buildInternalBeanFactory(ConfigurableBeanFactory containingFactory) {
    // Set parent so that references (up container hierarchies) are correctly resolved.
    DefaultListableBeanFactory internalBeanFactory = new DefaultListableBeanFactory(containingFactory);

    // Required so that all BeanPostProcessors, Scopes, etc become available.
    internalBeanFactory.copyConfigurationFrom(containingFactory);

    // Filter out BeanPostProcessors that are part of the AOP infrastructure,
    // since those are only meant to apply to beans defined in the original factory.
    for (Iterator it = internalBeanFactory.getBeanPostProcessors().iterator(); it.hasNext();) {
      BeanPostProcessor postProcessor = (BeanPostProcessor) it.next();
      if (postProcessor instanceof AopInfrastructureBean) {
        it.remove();
      }
    }
View Full Code Here

  private XmlBeanDefinitionReader reader;


  protected void setUp() throws Exception {
    this.problemReporter = new CollatingProblemReporter();
    this.beanFactory = new DefaultListableBeanFactory();
    this.reader = new XmlBeanDefinitionReader(this.beanFactory);
    this.reader.setProblemReporter(this.problemReporter);
  }
View Full Code Here

TOP

Related Classes of org.springframework.beans.factory.support.DefaultListableBeanFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.