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


      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

      for (Iterator it = this.beanDefinitionNames.iterator(); it.hasNext();) {
        String beanName = (String) it.next();
        RootBeanDefinition bd = getMergedLocalBeanDefinition(beanName);
        if (!bd.isAbstract() && bd.isSingleton() && !bd.isLazyInit()) {
          if (isFactoryBean(beanName)) {
            FactoryBean factory = (FactoryBean) getBean(FACTORY_BEAN_PREFIX + beanName);
            if (factory instanceof SmartFactoryBean && ((SmartFactoryBean) factory).isEagerInit()) {
              getBean(beanName);
            }
          }
          else {
View Full Code Here

    ItemProcessor<String, String> itemProcessor = (ItemProcessor<String, String>) TestUtils.getPropertyValue(chunkProcessor, "itemProcessor");
    assertNotNull("ChunkProcessor ItemWriter must not be null", itemProcessor);
    assertTrue("Got wrong instance of ItemProcessor", itemProcessor instanceof Processor);

    FactoryBean serviceActivatorFactoryBean = applicationContext.getBean(ServiceActivatorFactoryBean.class);
    assertNotNull("ServiceActivatorFactoryBean must not be null", serviceActivatorFactoryBean);
    assertNotNull("Output channel must not be null", TestUtils.getPropertyValue(serviceActivatorFactoryBean, "outputChannel"));

    MessageChannel inputChannel = applicationContext.getBean("requests", MessageChannel.class);
    assertNotNull("Input channel must not be null", inputChannel);
View Full Code Here

    ItemWriter itemWriter = applicationContext.getBean("itemWriter", ChunkMessageChannelItemWriter.class);
    assertNotNull("Messaging template must not be null", TestUtils.getPropertyValue(itemWriter, "messagingGateway"));
    assertNotNull("Reply channel must not be null", TestUtils.getPropertyValue(itemWriter, "replyChannel"));

    FactoryBean remoteChunkingHandlerFactoryBean = applicationContext.getBean(RemoteChunkHandlerFactoryBean.class);
    assertNotNull("Chunk writer must not be null", TestUtils.getPropertyValue(remoteChunkingHandlerFactoryBean, "chunkWriter"));
    assertNotNull("Step must not be null", TestUtils.getPropertyValue(remoteChunkingHandlerFactoryBean, "step"));
  }
View Full Code Here

            A s = hasAnnotatedProperty(pd);
            if (s != null && !pvs.contains(pd.getName())) {
                try {
                    if (logger.isDebugEnabled())
                        logger.debug("Processing annotation [" + s + "] for [" + beanName + "." + pd.getName() + "]");
                    FactoryBean importer = getServiceImporter(s, pd.getWriteMethod(), beanName);
                    // BPPs are created in stageOne(), even though they are run in stageTwo(). This check means that
                    // the call to getObject() will not fail with ServiceUnavailable. This is safe to do because
                    // ServiceReferenceDependencyBeanFactoryPostProcessor will ensure that mandatory services are
                    // satisfied before stageTwo() is run.
                    if (bean instanceof BeanPostProcessor) {
                        ImporterCallAdapter.setCardinality(importer, Cardinality.C_0__1);
                    }
                    newprops.addPropertyValue(pd.getName(), importer.getObject());
                }
                catch (Exception e) {
                    throw new FatalBeanException("Could not create service reference", e);
                }
            }
View Full Code Here

           
            if (bean != null) {
                final Object fBean = bean;
               
                // Create a new FactoryBean which just return the found beab
                return new FactoryBean() {

                    @Override
                    public Object getObject() throws Exception {
                        return fBean;
                    }
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.