Package org.springframework.beans.factory

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


  /*
   * 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

  /*
   * 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

  /**
   * 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

    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

   *
   * @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

    }
  }

  public void testCleanBeanFactoryReferences() throws Exception {
    // invoke a reference
    BeanFactory factory = proxy.retrieveBeanFactory();
    assertSame(bf, factory);
  }
View Full Code Here

    MockControl factoryControl = MockControl.createControl(ObjectFactory.class);
    ObjectFactory mockFactory = (ObjectFactory) factoryControl.getMock();
    configuration.setObjectFactory(mockFactory);

    MockControl beanFactoryControl = MockControl.createNiceControl(BeanFactory.class);
    BeanFactory beanFactory = (BeanFactory) beanFactoryControl.getMock();

    JbpmContext context = new JbpmContext(null, mockFactory);
    factoryControl.expectAndReturn(mockFactory.createObject(JbpmContext.DEFAULT_JBPM_CONTEXT_NAME), context, 3);
    beanFactoryControl.replay();
    factoryControl.replay();
View Full Code Here

    sCtrl.verify();
    queryCtrl.verify();
  }

  public void testBeanFactoryRelease() throws Exception {
    BeanFactory beanFactory = new DefaultListableBeanFactory();
   
    configuration.setConfiguration(configurationResource);
    configuration.setBeanFactory(beanFactory);
    configuration.afterPropertiesSet();
   
    // make sure we have some sort of configuration
    assertNotNull(configuration.getObject());
   
    JbpmFactoryLocator locator = configuration.getFactoryLocator();
    JbpmHandlerProxy proxy = new JbpmHandlerProxy();
    BeanFactory bf = proxy.retrieveBeanFactory();
    assertSame(beanFactory, bf);
 
    // the reference to the bean factory locator should be removed
    configuration.destroy();
   
View Full Code Here

    BeanFactoryReference reference2 = locator2.useBeanFactory(INSTANCE_2);
    BeanFactoryReference aliasRef1 = locator1.useBeanFactory("alias1");
    BeanFactoryReference aliasRef2 = locator1.useBeanFactory("alias2");

    // verify the static map
    BeanFactory factory1 = reference1.getFactory();
    BeanFactory factory2 = reference2.getFactory();
    BeanFactory factory3 = reference2.getFactory();
    // get the alias from different factories
    BeanFactory alias1 = aliasRef1.getFactory();
    BeanFactory alias2 = aliasRef2.getFactory();

    assertSame(factory1, factory2);
    assertSame(factory1, factory3);
    // verify it's the same bean factory as the application context
    assertSame(factory1, applicationContext.getBeanFactory());
View Full Code Here

TOP

Related Classes of org.springframework.beans.factory.BeanFactory

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.