Package org.springframework.beans.factory.xml

Examples of org.springframework.beans.factory.xml.XmlBeanFactory


            LOG.info("Using default configuration....");
            server = new FtpServer();
        }
        else if( args.length == 2 ) {
            LOG.info("Using xml configuration file " + args[1] + "...");
            XmlBeanFactory bf = new XmlBeanFactory(new FileSystemResource(args[1]));
            if(bf.containsBean("server")) {
                server = (FtpServer) bf.getBean("server");
            } else {
                String[] beanNames = bf.getBeanNamesForType(FtpServer.class);
                if(beanNames.length == 1) {
                    server = (FtpServer) bf.getBean(beanNames[0]);
                } else if(beanNames.length > 1) {
                    System.out.println("Using the first server defined in the configuration, named " + beanNames[0]);
                    server = (FtpServer) bf.getBean(beanNames[0]);
                } else {
                    System.err.println("XML configuration does not contain a server configuration");
                }
            }
        } else {
View Full Code Here


            usage();
        } else if( (args.length == 1) && args[0].equals("-?") ) {
            usage();
        } else if( args.length == 1 ) {
            System.out.println("Using XML configuration file " + args[0] + "...");
            XmlBeanFactory bf = new XmlBeanFactory(new FileSystemResource(args[0]));
            if(bf.containsBean("server")) {
                server = (FtpServer) bf.getBean("server");
            } else {
                String[] beanNames = bf.getBeanNamesForType(FtpServer.class);
                if(beanNames.length == 1) {
                    server = (FtpServer) bf.getBean(beanNames[0]);
                } else if(beanNames.length > 1) {
                    System.out.println("Using the first server defined in the configuration, named " + beanNames[0]);
                    server = (FtpServer) bf.getBean(beanNames[0]);
                } else {
                    System.err.println("XML configuration does not contain a server configuration");
                }
               
            }
View Full Code Here

import org.springframework.core.io.FileSystemResource;

public class XmlDbUserManagerConfigTest extends TestCase {

    public void test() throws Throwable {
        XmlBeanFactory factory = new XmlBeanFactory(new FileSystemResource(
                "src/test/resources/spring-config/config-spring-db-user-manager.xml"));

        FtpServer server = (FtpServer) factory.getBean("server");

        DbUserManager um = (DbUserManager) server.getServerContext().getUserManager();
       assertTrue(um.getDataSource() instanceof jdbcDataSource);

        assertEquals("INSERT USER", um.getSqlUserInsert());
View Full Code Here

import org.springframework.core.io.FileSystemResource;

public class SpringConfigTest extends TestCase {

    public void test() throws Throwable {
        XmlBeanFactory factory = new XmlBeanFactory(new FileSystemResource("src/test/resources/spring-config/config-spring-1.xml"));

        FtpServer server = (FtpServer) factory.getBean("server");
        server.start();
       
        assertEquals(500, server.getConnectionConfig().getMaxLogins());
        assertEquals(false, server.getConnectionConfig().isAnonymousLoginEnabled());
        assertEquals(123, server.getConnectionConfig().getMaxAnonymousLogins());
View Full Code Here

    public void testSpring() throws Exception {
        // Load the Spring container
        ClassPathResource resource = new ClassPathResource(
                "org/restlet/test/ext/spring/SpringTestCase.xml");
        BeanFactory factory = new XmlBeanFactory(resource);

        // Start the Restlet component
        Component component = (Component) factory.getBean("component");
        component.start();
        Thread.sleep(500);
        component.stop();
    }
View Full Code Here

    }

    public void testSpringServerProperties() {
        ClassPathResource resource = new ClassPathResource(
                "org/restlet/test/ext/spring/SpringTestCase.xml");
        BeanFactory factory = new XmlBeanFactory(resource);

        Server server = (Server) factory.getBean("server");

        assertEquals("value1", server.getContext().getParameters()
                .getFirstValue("key1"));
        assertEquals("value2", server.getContext().getParameters()
                .getFirstValue("key2"));
View Full Code Here

        try {
            System.setProperty("rails.port", port);
            System.setProperty("rails.root", railsRoot);

            FileSystemResource resource = new FileSystemResource(config);
            XmlBeanFactory factory = new XmlBeanFactory(resource);

            PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer();
            configurer.setSystemPropertiesMode(PropertyPlaceholderConfigurer.SYSTEM_PROPERTIES_MODE_FALLBACK);
            configurer.postProcessBeanFactory(factory);

            context = new GenericApplicationContext(factory);
            context.refresh();

            ServiceContainer container = (ServiceContainer) factory.getBean("container");

            container.start();
        } catch (BeansException e) {
            throw new RuntimeException(e);
        } catch (ContainerLifecycleException e) {
View Full Code Here

  private static final long LOOP = 200000;
  private XmlBeanFactory factory = null;
  protected void setUp() throws Exception {
    super.setUp();
    ClassPathResource res = new ClassPathResource("/tests/jfun/yan/benchmark/spring_component_config.xml");
    factory = new XmlBeanFactory(res);
    assertNotNull(factory);
    Thread.sleep(100);
    System.gc();
    Thread.sleep(100);
    System.gc();
View Full Code Here

  }

  public static void setUpClass() throws Exception {
    System.out.println("=========初始化环境开始.....");   
    resource = new ClassPathResource(springConfigFile);
    beanFactory = new XmlBeanFactory(resource);
    transactionTemplate = (TransactionTemplate) beanFactory
        .getBean("transactionTemplate");
    runtimeContext = (RuntimeContext) beanFactory.getBean("runtimeContext");

    // 首先将表中的数据清除
View Full Code Here

import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.FileSystemResource;

public class Aplicacao {
  public static void main(String[] args) {
    XmlBeanFactory factory = new XmlBeanFactory(new FileSystemResource("spring/applicationContext.xml"));
   
    Sistema sistema = (Sistema)factory.getBean("Sistema");
   
    Cliente cliente4 = new Cliente();
   
    cliente4.setId(4);
    cliente4.setNome("Teste4");
View Full Code Here

TOP

Related Classes of org.springframework.beans.factory.xml.XmlBeanFactory

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.