Package org.springframework.beans.factory

Examples of org.springframework.beans.factory.FactoryBean


    sac.refresh();

    TestAutoProxyCreator tapc = (TestAutoProxyCreator) sac.getBean("testAutoProxyCreator");
    tapc.testInterceptor.nrOfInvocations = 0;

    FactoryBean prototypeFactory = (FactoryBean) sac.getBean("&prototypeFactoryToBeProxied");
    assertTrue(AopUtils.isCglibProxy(prototypeFactory));
    TestBean tb = (TestBean) sac.getBean("prototypeFactoryToBeProxied");
    assertFalse(AopUtils.isCglibProxy(tb));

    assertEquals(2, tapc.testInterceptor.nrOfInvocations);
View Full Code Here


      fail();
    }
    catch (UnsupportedOperationException ex) {
      assertEquals("getName", ex.getMessage());
    }
    FactoryBean pfb = (ProxyFactoryBean) bf.getBean("&noTarget");
    assertTrue("Has correct object type", ITestBean.class.isAssignableFrom(pfb.getObjectType()));
  }
View Full Code Here

   * <p>The shortcut check for a FactoryBean is only applied in case of a singleton
   * FactoryBean. If the FactoryBean instance itself is not kept as singleton,
   * it will be fully created to check the type of its exposed object.
   */
  protected Class getTypeForFactoryBean(String beanName, RootBeanDefinition mbd) {
    FactoryBean fb = (mbd.isSingleton() ?
        getSingletonFactoryBeanForTypeCheck(beanName, mbd) :
        getNonSingletonFactoryBeanForTypeCheck(beanName, mbd));

    if (fb != null) {
      // Try to obtain the FactoryBean's object type from this early stage of the instance.
View Full Code Here

      }
      finally {
        // Finished partial creation of this bean.
        afterSingletonCreation(beanName);
      }
      FactoryBean fb = getFactoryBean(beanName, instance);
      if (bw != null) {
        this.factoryBeanInstanceCache.put(beanName, bw);
      }
      return fb;
    }
View Full Code Here

      if (mbd.isSingleton()) {
        if (isFactoryBean(beanName, mbd)) {
          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

      // However, FactoryBean may still produce a prototype object...
      if (BeanFactoryUtils.isFactoryDereference(name)) {
        return false;
      }
      if (isFactoryBean(beanName, mbd)) {
        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) doGetBean(FACTORY_BEAN_PREFIX + beanName, FactoryBean.class, null, true);
      return getTypeForFactoryBean(factoryBean);
    }
    catch (BeanCreationException ex) {
      // Can only happen when getting a FactoryBean.
View Full Code Here

    if (mbd == null) {
      object = getCachedObjectForFactoryBean(beanName);
    }
    if (object == null) {
      // Return bean instance from factory.
      FactoryBean factory = (FactoryBean) beanInstance;
      // Caches object obtained from FactoryBean if it is a singleton.
      if (mbd == null && containsBeanDefinition(beanName)) {
        mbd = getMergedLocalBeanDefinition(beanName);
      }
      boolean synthetic = (mbd != null && mbd.isSynthetic());
View Full Code Here

   * <p>The shortcut check for a FactoryBean is only applied in case of a singleton
   * FactoryBean. If the FactoryBean instance itself is not kept as singleton,
   * it will be fully created to check the type of its exposed object.
   */
  protected Class getTypeForFactoryBean(String beanName, RootBeanDefinition mbd) {
    FactoryBean fb = (mbd.isSingleton() ?
        getSingletonFactoryBeanForTypeCheck(beanName, mbd) :
        getNonSingletonFactoryBeanForTypeCheck(beanName, mbd));

    if (fb != null) {
      // Try to obtain the FactoryBean's object type from this early stage of the instance.
View Full Code Here

      }
      finally {
        // Finished partial creation of this bean.
        afterSingletonCreation(beanName);
      }
      FactoryBean fb = getFactoryBean(beanName, instance);
      if (bw != null) {
        this.factoryBeanInstanceCache.put(beanName, bw);
      }
      return fb;
    }
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.