Example usage for org.springframework.context.support ClassPathXmlApplicationContext ClassPathXmlApplicationContext

List of usage examples for org.springframework.context.support ClassPathXmlApplicationContext ClassPathXmlApplicationContext

Introduction

In this page you can find the example usage for org.springframework.context.support ClassPathXmlApplicationContext ClassPathXmlApplicationContext.

Prototype

public ClassPathXmlApplicationContext(String... configLocations) throws BeansException 

Source Link

Document

Create a new ClassPathXmlApplicationContext, loading the definitions from the given XML files and automatically refreshing the context.

Usage

From source file:com.apress.prospringintegration.messagestore.jdbc.JdbcTest.java

public static void main(String[] args) throws Throwable {

    ClassPathXmlApplicationContext classPathXmlApplicationContext = new ClassPathXmlApplicationContext(
            "classpath:spring/jdbc/spring-context.xml");

    MessageProducer messageProducer = classPathXmlApplicationContext.getBean(MessageProducer.class);

    for (int i = 0; i < 10; i++)
        messageProducer.sendMessages(i,//from   www .ja v a  2 s. co  m
                Arrays.asList(new String[] { "apple", "banana", "carrot", "date", "egg" }));

    Thread.sleep(1000 * 10);
}

From source file:edu.berkeley.path.next.modelEngine.modeEngineApp.java

public static void main(String[] args) {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("modelEngine-subscribe.xml");
    context.start();//from  w  w  w. j a  v  a  2s . co  m

}

From source file:com.alibaba.dubbo.examples.heartbeat.HeartbeatConsumer.java

public static void main(String[] args) throws Exception {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
            HeartbeatConsumer.class.getPackage().getName().replace('.', '/') + "/heartbeat-consumer.xml");
    context.start();/*from   ww w  .ja v  a2s  .  c o m*/
    HelloService hello = (HelloService) context.getBean("helloService");
    for (int i = 0; i < Integer.MAX_VALUE; i++) {
        System.out.println(hello.sayHello("kimi-" + i));
        Thread.sleep(10000);
    }
}

From source file:com.apress.prospringintegration.messagestore.gemfire.GemfireTest.java

public static void main(String[] args) throws Throwable {

    ClassPathXmlApplicationContext classPathXmlApplicationContext = new ClassPathXmlApplicationContext(
            "classpath:spring/gemfire/spring-context.xml");

    MessageProducer messageProducer = classPathXmlApplicationContext.getBean(MessageProducer.class);

    for (int i = 0; i < 10; i++)
        messageProducer.sendMessages(i,/*  w ww .  ja  v  a 2s . c  om*/
                Arrays.asList(new String[] { "apple", "banana", "carrot", "date", "egg" }));

    Thread.sleep(1000 * 10);
}

From source file:com.dianping.dpsf.other.echo.SimpleEchoClient.java

/**
 * @param args//from w  ww  .j  a v a 2  s.c o  m
 * @throws Exception 
 */
public static void main(String[] args) throws Exception {

    ConfigCache.getInstance("192.168.7.41:2182");
    ApplicationContext ctx = new ClassPathXmlApplicationContext("echo-client.xml");
    IEcho s = (IEcho) ctx.getBean("echo");

    while (true) {
        try {
            System.out.println(s.echo("aa"));
            Thread.sleep(500);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}

From source file:com.alibaba.dubbo.examples.async.AsyncProvider.java

public static void main(String[] args) throws Exception {
    String config = AsyncProvider.class.getPackage().getName().replace('.', '/') + "/async-provider.xml";
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(config);
    context.start();//from w w w.  j a  va  2s  . c om
    System.in.read();
}

From source file:com.alibaba.dubbo.examples.cache.CacheProvider.java

public static void main(String[] args) throws Exception {
    String config = CacheProvider.class.getPackage().getName().replace('.', '/') + "/cache-provider.xml";
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(config);
    context.start();//from  ww  w  .  j av a  2s  .  c om
    System.in.read();
}

From source file:com.alibaba.dubbo.examples.merge.MergeProvider.java

public static void main(String[] args) throws Exception {
    String config = MergeProvider.class.getPackage().getName().replace('.', '/') + "/merge-provider.xml";
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(config);
    context.start();/*w ww  . j a v a 2 s  .c o m*/
    System.in.read();
}

From source file:edu.berkeley.path.next.persistService.persistServiceApp.java

public static void main(String[] args) {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("persist-service.xml");
    context.start();/*w  w w . j  av  a2s.  c  om*/

}

From source file:com.stoxa.SpringXML.TestClass.TestClass.java

public static void main(String[] args) throws Exception {
    ApplicationContext context = new ClassPathXmlApplicationContext("config2.xml");
    FactoryBean factory = context.getBean("contactFactory", ContactBeanFactory.class);

    Contact c1 = (Contact) factory.getObject();
    Contact c2 = (Contact) factory.getObject();
    Contact c3 = (Contact) factory.getObject();
    Contact c4 = (Contact) factory.getObject();
    Contact c5 = (Contact) factory.getObject();

    ContactService contactService = context.getBean("ContactService", ContactService.class);

    System.out.println("ADD CONTACT ==============");
    contactService.addContact(c1);//  ww w. j  a  va 2  s.c  om
    contactService.addContact(c2);
    contactService.addContact(c3);
    contactService.addContact(c4);
    contactService.addContact(c5);
    List<Contact> result1 = contactService.getAllContacts();
    for (Contact c : result1) {
        System.out.println(c);
    }
    System.out.println("******************************************");

    System.out.println("UPDATE CONTACT ==============");
    Contact change = new Contact("??", "", "+380955019248", "sokolov@yandex.ru");
    contactService.updateContact(change);
    List<Contact> result2 = contactService.getAllContacts();
    for (Contact c : result2) {
        System.out.println(c);
    }
    System.out.println("******************************************");

    System.out.println("DELETE CONTACT ==============");
    contactService.deleteContact(c3);
    List<Contact> result3 = contactService.getAllContacts();
    for (Contact c : result3) {
        System.out.println(c);
    }
    System.out.println("******************************************");

    System.out.println("GET CONTACT ==============");
    Contact contact = contactService.getContact("+380674560901");
    System.out.println(contact);

    System.out.println("******************************************");

    System.out.println("CLEAR ALL CONTACTS ==============");
    contactService.clearAll();
    List<Contact> result4 = contactService.getAllContacts();
    for (Contact c : result4) {
        System.out.println(c);
    }
}