Package org.springframework.beans.factory

Examples of org.springframework.beans.factory.FactoryBean


      }
      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


    synchronized (this.beanDefinitionMap) {
      for (String beanName : this.beanDefinitionNames) {
        RootBeanDefinition bd = getMergedLocalBeanDefinition(beanName);
        if (!bd.isAbstract() && bd.isSingleton() && !bd.isLazyInit()) {
          if (isFactoryBean(beanName)) {
            final FactoryBean factory = (FactoryBean) getBean(FACTORY_BEAN_PREFIX + beanName);
            boolean isEagerInit;
            if (System.getSecurityManager() != null && factory instanceof SmartFactoryBean) {
              isEagerInit = AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
                public Boolean run() {
                  return ((SmartFactoryBean) factory).isEagerInit();
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)) {
        final FactoryBean factoryBean = (FactoryBean) getBean(FACTORY_BEAN_PREFIX + beanName);
        if (System.getSecurityManager() != null) {
          return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
            public Boolean run() {
              return ((factoryBean instanceof SmartFactoryBean && ((SmartFactoryBean) factoryBean).isPrototype()) ||
                  !factoryBean.isSingleton());
            }
          }, getAccessControlContext());
        }
        else {
          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 = doGetBean(FACTORY_BEAN_PREFIX + beanName, FactoryBean.class, null, true);
      return getTypeForFactoryBean(factoryBean);
    }
    catch (BeanCreationException ex) {
      // Can only happen when getting a FactoryBean.
      if (logger.isDebugEnabled()) {
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

    synchronized (this.beanDefinitionMap) {
      for (String beanName : this.beanDefinitionNames) {
        RootBeanDefinition bd = getMergedLocalBeanDefinition(beanName);
        if (!bd.isAbstract() && bd.isSingleton() && !bd.isLazyInit()) {
          if (isFactoryBean(beanName)) {
            final FactoryBean factory = (FactoryBean) getBean(FACTORY_BEAN_PREFIX + beanName);
            boolean isEagerInit;
            if (System.getSecurityManager() != null && factory instanceof SmartFactoryBean) {
              isEagerInit = AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
                public Boolean run() {
                  return ((SmartFactoryBean) factory).isEagerInit();
View Full Code Here

   * FactoryBean. If the FactoryBean instance itself is not kept as singleton,
   * it will be fully created to check the type of its exposed object.
   */
  @Override
  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

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.