Examples of BeanFactory


Examples of org.springframework.beans.factory.BeanFactory

  }

  @Test
  public void doesNotResolveTypeForPlainBeanFactory() throws Exception {

    BeanFactory beanFactory = mock(BeanFactory.class);
    processor.setBeanFactory(beanFactory);

    assertNotTypeDetected(FACTORY_CLASS);
  }
View Full Code Here

Examples of org.springframework.beans.factory.BeanFactory

   * @throws BuildException if the BeanFactory cannot be initialized.
   */
  public static BeanFactory getBeanFactory(String contextRef, String factoryKey) throws BuildException {

    String cacheKey = contextRef + factoryKey;
    BeanFactory beanFactory = (BeanFactory)factoryCache.get(cacheKey);
   
    // Try to cache factories as we load them...
    if (beanFactory!=null) return beanFactory;

    try {
View Full Code Here

Examples of org.springframework.beans.factory.BeanFactory

   * @return the bean identified by the parameters.
   * @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);
    return value;
  }
View Full Code Here

Examples of org.springframework.beans.factory.BeanFactory

  /*
   * 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"));
  }
View Full Code Here

Examples of org.springframework.beans.factory.BeanFactory

  /*
   * 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"));
  }
View Full Code Here

Examples of org.springframework.beans.factory.BeanFactory

  /*
   * 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"));
  }
View Full Code Here

Examples of org.springframework.beans.factory.BeanFactory

  /*
   * Test method for 'org.springmodules.ant.util.BeanFactoryLoader'
   */
  public void testBeanFactoryCache() throws Exception {
    BeanFactory factory1 = BeanFactoryLoader.getBeanFactory("test.bootstrap");
    BeanFactory factory2 = BeanFactoryLoader.getBeanFactory("test.bootstrap");
    assertEquals("Bean factory not cached", factory1, factory2);
  }
View Full Code Here

Examples of org.springframework.beans.factory.BeanFactory

  /**
   * Test that autowiring can be done on a DefaultListableBeanFactory.
   * @throws Exception
   */
  public void testAutowireDefaultListableBeanFactory() throws Exception {
    BeanFactory parent = BeanFactoryLoader.getBeanFactory("test.bootstrap");
    DefaultListableBeanFactory context = new DefaultListableBeanFactory();
    context.setParentBeanFactory(parent);
    context.registerSingleton("this", this);
    SpringDependencyInjectorTaskTest test = (SpringDependencyInjectorTaskTest) context.getBean("this");
    context.autowireBeanProperties(test, AutowireCapableBeanFactory.AUTOWIRE_BY_NAME, false);
View Full Code Here

Examples of org.springframework.beans.factory.BeanFactory

    if (this.expression == null) {
      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 + "]");
    }

    Object target = beanFactory.getBean(name);

    // TODO: set properties on the bean first (or just use OGNL)
    try {
      Map context = Ognl.createDefaultContext(target);
      context.put("project", getProject());
View Full Code Here

Examples of org.springframework.beans.factory.BeanFactory

   *
   * @see org.apache.tools.ant.Task#execute()
   */
  public void execute() throws BuildException {

    BeanFactory parentBeanFactory = getBeanFactory();
    Project project = getProject();

    if ((taskref == null) || !project.getReferences().containsKey(taskref)) {
      throw new BuildException(
          "The project does not contain the required reference: ["
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.