Package org.springframework.beans.factory.config

Examples of org.springframework.beans.factory.config.ConfigurableBeanFactory


   {

      if (_evaluationContext == null) {

         // we need a ConfigurableBeanFactory to build the BeanExpressionContext
         ConfigurableBeanFactory beanFactory = null;

         // the WebApplicationContext MAY implement ConfigurableBeanFactory
         if (applicationContext instanceof ConfigurableBeanFactory) {
            beanFactory = (ConfigurableBeanFactory) applicationContext;
         }
View Full Code Here


        }
       
        public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
            if (defaultBus
                && applicationContext.getAutowireCapableBeanFactory() instanceof ConfigurableBeanFactory) {
                ConfigurableBeanFactory bf = (ConfigurableBeanFactory)applicationContext
                    .getAutowireCapableBeanFactory();
                bf.registerSingleton("cxf", bus);
            }
        }
View Full Code Here

        }
       
        public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
            if (defaultBus
                && applicationContext.getAutowireCapableBeanFactory() instanceof ConfigurableBeanFactory) {
                ConfigurableBeanFactory bf = (ConfigurableBeanFactory)applicationContext
                    .getAutowireCapableBeanFactory();
                bf.registerSingleton("cxf", bus);
            }
        }
View Full Code Here

        }
       
        public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
            if (defaultBus
                && applicationContext.getAutowireCapableBeanFactory() instanceof ConfigurableBeanFactory) {
                ConfigurableBeanFactory bf = (ConfigurableBeanFactory)applicationContext
                    .getAutowireCapableBeanFactory();
                bf.registerSingleton("cxf", bus);
            }
        }
View Full Code Here

  /**
   * Resolves the specified interceptor names to Advisor objects.
   * @see #setInterceptorNames
   */
  private Advisor[] resolveInterceptorNames() {
    ConfigurableBeanFactory cbf =
        (this.beanFactory instanceof ConfigurableBeanFactory ? (ConfigurableBeanFactory) this.beanFactory : null);
    List advisors = new ArrayList();
    for (int i = 0; i < this.interceptorNames.length; i++) {
      String beanName = this.interceptorNames[i];
      if (cbf == null || !cbf.isCurrentlyInCreation(beanName)) {
        Object next = this.beanFactory.getBean(beanName);
        advisors.add(this.advisorAdapterRegistry.wrap(next));
      }
    }
    return (Advisor[]) advisors.toArray(new Advisor[advisors.size()]);
View Full Code Here

  public void setBeanFactory(BeanFactory beanFactory) {
    if (!(beanFactory instanceof ConfigurableBeanFactory)) {
      throw new IllegalStateException("Not running in a ConfigurableBeanFactory: " + beanFactory);
    }
    ConfigurableBeanFactory cbf = (ConfigurableBeanFactory) beanFactory;

    this.scopedTargetSource.setBeanFactory(beanFactory);

    ProxyFactory pf = new ProxyFactory();
    pf.copyFrom(this);
    pf.setTargetSource(this.scopedTargetSource);

    Class beanType = beanFactory.getType(this.targetBeanName);
    if (beanType == null) {
      throw new IllegalStateException("Cannot create scoped proxy for bean '" + this.targetBeanName +
          "': Target type could not be determined at the time of proxy creation.");
    }
    if (!isProxyTargetClass() || beanType.isInterface() || Modifier.isPrivate(beanType.getModifiers())) {
      pf.setInterfaces(ClassUtils.getAllInterfacesForClass(beanType, cbf.getBeanClassLoader()));
    }

    // Add an introduction that implements only the methods on ScopedObject.
    ScopedObject scopedObject = new DefaultScopedObject(cbf, this.scopedTargetSource.getTargetBeanName());
    pf.addAdvice(new DelegatingIntroductionInterceptor(scopedObject));

    // Add the AopInfrastructureBean marker to indicate that the scoped proxy
    // itself is not subject to auto-proxying! Only its target bean is.
    pf.addInterface(AopInfrastructureBean.class);

    this.proxy = pf.getProxy(cbf.getBeanClassLoader());
  }
View Full Code Here

  public void testAliasing() {
    BeanFactory bf = getBeanFactory();
    if (!(bf instanceof ConfigurableBeanFactory)) {
      return;
    }
    ConfigurableBeanFactory cbf = (ConfigurableBeanFactory) bf;
   
    String alias = "rods alias";
    try {
      cbf.getBean(alias);
      fail("Shouldn't permit factory get on normal bean");
    }
    catch (NoSuchBeanDefinitionException ex) {
      // Ok
      assertTrue(alias.equals(ex.getBeanName()));
    }
   
    // Create alias
    cbf.registerAlias("rod", alias);
    Object rod = getBeanFactory().getBean("rod");
    Object aliasRod = getBeanFactory().getBean(alias);
    assertTrue(rod == aliasRod);
  }
View Full Code Here

      resource = this.resourceFactory.getBean(name, type);
      autowiredBeanNames = Collections.singleton(name);
    }

    if (this.resourceFactory instanceof ConfigurableBeanFactory) {
      ConfigurableBeanFactory beanFactory = (ConfigurableBeanFactory) this.resourceFactory;
      for (Iterator it = autowiredBeanNames.iterator(); it.hasNext();) {
        String autowiredBeanName = (String) it.next();
        beanFactory.registerDependentBean(autowiredBeanName, requestingBeanName);
      }
    }

    return resource;
  }
View Full Code Here

      resource = factory.getBean(name, element.lookupType);
      autowiredBeanNames = Collections.singleton(name);
    }

    if (factory instanceof ConfigurableBeanFactory) {
      ConfigurableBeanFactory beanFactory = (ConfigurableBeanFactory) factory;
      for (String autowiredBeanName : autowiredBeanNames) {
        if (beanFactory.containsBean(autowiredBeanName)) {
          beanFactory.registerDependentBean(autowiredBeanName, requestingBeanName);
        }
      }
    }

    return resource;
View Full Code Here

      registerService();
  }

  private void addBeanFactoryDependency() {
    if (beanFactory instanceof ConfigurableBeanFactory) {
      ConfigurableBeanFactory cbf = (ConfigurableBeanFactory) beanFactory;
      if (StringUtils.hasText(beanName) && cbf.containsBean(beanName)) {
        // no need to validate targetBeanName (already did)
        cbf.registerDependentBean(targetBeanName, BeanFactory.FACTORY_BEAN_PREFIX + beanName);
        cbf.registerDependentBean(targetBeanName, beanName);
      }
    }
    else {
      log.warn("The running bean factory cannot support dependencies between beans - importer/exporter dependency cannot be enforced");
    }
View Full Code Here

TOP

Related Classes of org.springframework.beans.factory.config.ConfigurableBeanFactory

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.