Package org.springframework.beans.factory

Examples of org.springframework.beans.factory.BeanFactory.containsBean()


   * @throws BuildException if the bean cannot be located
   */
  public Object getValue() throws BuildException {
    if (value!=null) return value;
    BeanFactory beanFactory = BeanFactoryLoader.getBeanFactory(contextRef, factoryKey);
    if ((name == null) || !beanFactory.containsBean(name)) {
      throw new BuildException(
          "The BeanFactory does not contain the required bean: ["
              + name + "]");
    }
    value = beanFactory.getBean(name);
View Full Code Here


   * Test method for 'org.springmodules.ant.util.BeanFactoryLoader'
   */
  public void testBeanFactoryWithContext() throws Exception {
    BeanFactory factory = BeanFactoryLoader.getBeanFactory("classpath:beanRefContext.xml", "test.bootstrap");
    assertNotNull("Null bean factory test.child", factory);
    assertTrue("Factory does not contain bean", factory.containsBean("properties"));
  }

  /*
   * Test method for 'org.springmodules.ant.util.BeanFactoryLoader'
   */
 
View Full Code Here

   * Test method for 'org.springmodules.ant.util.BeanFactoryLoader'
   */
  public void testBeanFactoryDefaultContext() throws Exception {
    BeanFactory factory = BeanFactoryLoader.getBeanFactory("test.bootstrap");
    assertNotNull("Null bean factory test.child", factory);
    assertTrue("Factory does not contain bean", factory.containsBean("properties"));
  }

  /*
   * Test method for 'org.springmodules.ant.util.BeanFactoryLoader'
   */
 
View Full Code Here

   * Test method for 'org.springmodules.ant.util.BeanFactoryLoader'
   */
  public void testParentBeanFactory() throws Exception {
    BeanFactory factory = BeanFactoryLoader.getBeanFactory("test.child");
    assertNotNull("Null bean factory test.child", factory);
    assertTrue("Factory does not contain bean", factory.containsBean("properties"));
  }

  /*
   * Test method for 'org.springmodules.ant.util.BeanFactoryLoader'
   */
 
View Full Code Here

      throw new BuildException("Cannot execute a null expression");
    }

    BeanFactory beanFactory = getBeanFactory();

    if ((name == null) || !beanFactory.containsBean(name)) {
      throw new BuildException(
          "The BeanFactory does not contain the required bean: ["
              + name + "]");
    }
View Full Code Here

                }

                //
                // Check absolute ID first, then relative ID for a match
                //
                if (fullID != null && beanFactory.containsBean(fullID))
                    bean = (T)beanFactory.getBean(fullID, beanClass);
                else if (beanFactory.containsBean(id))
                    bean = (T)beanFactory.getBean(id, beanClass);
            }
View Full Code Here

                //
                // Check absolute ID first, then relative ID for a match
                //
                if (fullID != null && beanFactory.containsBean(fullID))
                    bean = (T)beanFactory.getBean(fullID, beanClass);
                else if (beanFactory.containsBean(id))
                    bean = (T)beanFactory.getBean(id, beanClass);
            }

            //
            // Look for a match based upon bean class name
View Full Code Here

            //
            // Look for a match based upon bean class name
            //
            String beanClassName = beanClass.getName();
            if (bean == null && beanFactory.containsBean(beanClassName))
                bean = (T)beanFactory.getBean(beanClassName, beanClass);

            if (bean != null)
            {
                //
View Full Code Here

    DependenciesBean rod5 = (DependenciesBean) xbf.getBean("rod5");
    // Should not have been autowired
    assertNull(rod5.getSpouse());

    BeanFactory appCtx = (BeanFactory) xbf.getBean("childAppCtx");
    assertTrue(appCtx.containsBean("rod1"));
    assertTrue(appCtx.containsBean("jenny"));
  }

  public void testAutowireWithDefault() throws Exception {
    XmlBeanFactory xbf = new XmlBeanFactory(new ClassPathResource("default-autowire.xml", getClass()));
View Full Code Here

    // Should not have been autowired
    assertNull(rod5.getSpouse());

    BeanFactory appCtx = (BeanFactory) xbf.getBean("childAppCtx");
    assertTrue(appCtx.containsBean("rod1"));
    assertTrue(appCtx.containsBean("jenny"));
  }

  public void testAutowireWithDefault() throws Exception {
    XmlBeanFactory xbf = new XmlBeanFactory(new ClassPathResource("default-autowire.xml", getClass()));
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.