Package org.springframework.beans.factory

Examples of org.springframework.beans.factory.BeanFactory


    File file = QAUtil.createTempfile();
    FileWriter fw = new FileWriter(file);
    fw.write(SPRING_XML2);
    fw.close();

    BeanFactory beanFactory = new XmlBeanFactory(new FileSystemResource(file));
    IServer server = (IServer) beanFactory.getBean("server");
   
    if (!server.isOpen()) {
      System.out.println("server should be open");
      Assert.fail("server should be open");
    }
View Full Code Here


    fw.write(SPRING_XML3);
    fw.close();


   
    BeanFactory beanFactory = new XmlBeanFactory(new FileSystemResource(file));
    IServer server = (IServer) beanFactory.getBean("server");

    if (!server.isOpen()) {
      System.out.println("server should be open");
      Assert.fail("server should be open");
    }
View Full Code Here

    fw.write(SPRING_XML4);
    fw.close();


   
    BeanFactory beanFactory = new XmlBeanFactory(new FileSystemResource(file));
    HttpClient httpClient = (HttpClient) beanFactory.getBean("httpClient");
    Assert.assertEquals(30, httpClient.getMaxIdle());
    Assert.assertEquals(60000, httpClient.getResponseTimeoutMillis());


    IHttpResponse response = httpClient.call(new GetRequest("http://localhost:" + server.getLocalPort() + "/test?parm1=1"));
View Full Code Here

   
    // append random suffix for requested service id
    String rndString = RandomStringUtils.random(8, false, true);
    id = (id != null) ? new StringBuffer(id).append(rndString).toString() : rndString;
   
    BeanFactory factory = (BeanFactory) getEnvironment().getEntry(BeanFactory.class);
    // TODO:: some better way in framework?
    Service service = (Service) factory.getBean("servletServiceAdapterComponent");
   
    currentThreadCtx.addService(id, service);
   
    if (startMessage != null)
      startMessage.send(null, service);
View Full Code Here

  //
 
  public void testSerialization() throws Exception {
    adapter = (ServletServiceAdapterComponent)initAdapter("serializationTestsConf.xml");
   
    BeanFactory factory = servlet.getFactory();
    MockViewPortWidget widget = (MockViewPortWidget)factory.getBean("rootWidget");
    widget.setChild(new MockStandardWidget());
    adapter.service(req, resp);
    //success if no exception thrown
  }
View Full Code Here

    String widgetKey =StandardViewPortWidget.CHILD_KEY;
   
    adapter = (ServletServiceAdapterComponent)initAdapter("repeatedRequest.xml");
    // lets get reference to the bean doing the heavy-lifting
    // its a singleton, so we're cool
    BeanFactory factory = servlet.getFactory();
    MockViewPortWidget widget = (MockViewPortWidget)factory.getBean("rootWidget");
   
    req.addParameter(StandardWidget.EVENT_HANDLER_ID_KEY, event);
    req.addParameter(StandardWidgetContainerWidget.EVENT_PATH_KEY, widgetKey);
   
    // first request, transactionId will get intialized
View Full Code Here

  }

  @Test
  public void doesNotResolveTypeForPlainBeanFactory() throws Exception {

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

    assertNotTypeDetected(FACTORY_CLASS);
  }
View Full Code Here

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

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

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

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.