Package org.springframework.beans.factory

Examples of org.springframework.beans.factory.FactoryBean


    greeter.greet();
    final Factory factory = (Factory)yan.getInstance("myfactory");
    factory.create();
    final Factory factory2 = (Factory)yan.getInstance("myfactory2");
    factory2.create();
    final FactoryBean fb = SpringAdapter.getFactoryBean(yan, "myController");
    assertNotNull(fb);
  }
View Full Code Here


      public void run() throws Exception {
        foo.noop();
      }
    };
    bench.start(true);
    FactoryBean fb = SpringAdapter.getFactoryBean(yan, "fooProxy");
    assertNotNull(fb);
  }
View Full Code Here

      final Component fbc = SpringAdapter.getFactoryBeanComponent(c);
      if(fbc!=null){
        //I am Factory Bean
        if(includeFactoryBeans){
          //attempt to match the FactoryBean result.
          final FactoryBean fb = (FactoryBean)instantiate(fbc);
          if(!includePrototypes && !fb.isSingleton()){
            continue;
          }
          final Class fbt = fb.getObjectType();
          if(type==null || ReflectionUtil.isAssignableFrom(type, fbt)){
            final String beanname = (String)key;
            listener.onFactoryBean(beanname, fb);
            continue;
          }
View Full Code Here

      final Component fbc = SpringAdapter.getFactoryBeanComponent(c);
      if(requiredType==null){
        return instantiate(c);
      }
      if(fbc!=null){
        final FactoryBean fb = (FactoryBean)instantiate(fbc);
        final Class ctype = fb.getObjectType();
        checkBeanType(beanname, requiredType, ctype);
        return instantiate(beanname, fb);
      }
      else{
        final Class ctype = c.getType();
View Full Code Here

  throws NoSuchBeanDefinitionException {
    final Component c = getComponent(name);
    if(!BeanFactoryUtils.isFactoryDereference(name)){
      final Component fbc = SpringAdapter.getFactoryBeanComponent(c);
      if(fbc!=null){
        final FactoryBean fb = (FactoryBean)instantiate(fbc);
        return fb.isSingleton();
      }
    }
    return c.isSingleton();
  }
View Full Code Here

  throws NoSuchBeanDefinitionException {
    final Component c = getComponent(name);
    if(!BeanFactoryUtils.isFactoryDereference(name)){
      final Component fbc = SpringAdapter.getFactoryBeanComponent(c);
      if(fbc!=null){
        final FactoryBean fb = (FactoryBean)instantiate(fbc);
        return fb.getObjectType();
      }
    }
    return c.getType();
  }
View Full Code Here

        Class beanClass = predictBeanType(beanName, mbd, true);
        if (beanClass != null && FactoryBean.class.isAssignableFrom(beanClass)) {
          if (BeanFactoryUtils.isFactoryDereference(name)) {
            return true;
          }
          FactoryBean factoryBean = (FactoryBean) getBean(FACTORY_BEAN_PREFIX + beanName);
          return factoryBean.isSingleton();
        }
        else {
          return !BeanFactoryUtils.isFactoryDereference(name);
        }
      }
View Full Code Here

      if (BeanFactoryUtils.isFactoryDereference(name)) {
        return false;
      }
      Class beanClass = predictBeanType(beanName, mbd, true);
      if (beanClass != null && FactoryBean.class.isAssignableFrom(beanClass)) {
        FactoryBean factoryBean = (FactoryBean) getBean(FACTORY_BEAN_PREFIX + beanName);
        return ((factoryBean instanceof SmartFactoryBean && ((SmartFactoryBean) factoryBean).isPrototype()) ||
            !factoryBean.isSingleton());
      }
      else {
        return false;
      }
    }
View Full Code Here

  protected Class getTypeForFactoryBean(String beanName, RootBeanDefinition mbd) {
    if (!mbd.isSingleton()) {
      return null;
    }
    try {
      FactoryBean factoryBean = (FactoryBean) getBean(FACTORY_BEAN_PREFIX + beanName);
      return getTypeForFactoryBean(factoryBean);
    }
    catch (BeanCreationException ex) {
      // Can only happen when getting a FactoryBean.
      logger.debug("Ignoring bean creation exception on FactoryBean type check", ex);
View Full Code Here

    // If it's a FactoryBean, we use it to create a bean instance, unless the
    // caller actually wants a reference to the factory.
    if (beanInstance instanceof FactoryBean) {
      if (!BeanFactoryUtils.isFactoryDereference(name)) {
        // Return bean instance from factory.
        FactoryBean factory = (FactoryBean) beanInstance;
        // Cache object obtained from FactoryBean if it is a singleton.
        RootBeanDefinition mbd =
            (containsBeanDefinition(beanName) ? getMergedLocalBeanDefinition(beanName) null);
        boolean shared = (mbd == null || mbd.isSingleton());
        if (shared && factory.isSingleton()) {
          synchronized (getSingletonMutex()) {
            object = this.factoryBeanObjectCache.get(beanName);
            if (object == null) {
              object = getObjectFromFactoryBean(factory, beanName, mbd);
              this.factoryBeanObjectCache.put(beanName, object);
View Full Code Here

TOP

Related Classes of org.springframework.beans.factory.FactoryBean

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.