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:edu.berkeley.path.next.trafficMonitor.trafficMonitorApp.java

public static void main(String[] args) throws InterruptedException {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("jms-publish.xml");
    context.start();/*w  w w  .ja  v  a  2 s .  co m*/

    final Logger logger = LogManager.getLogger(trafficMonitorApp.class.getName());

    logger.info("trafficMonitorApp initialized ");

    JmsPublish jmsPublish = context.getBean(JmsPublish.class);

    int x = 0;
    String msg = "status";
    while (x < 7) {
        //use SLF interface which provides for parameterized logging
        logger.info("trafficMonitorApp sendTrafficUpdate {} ", x);
        jmsPublish.sendTrafficUpdate(msg);
        Thread.sleep(3000);
        x++;
    }
}

From source file:org.apache.isis.example.wrj.todoitem.ToDoItemSpringClient.java

public static void main(String args[]) throws Exception {
    // Initialize the spring context and fetch our test client
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
            new String[] { "classpath:client-applicationContext.xml" });
    ToDoItemTester client = (ToDoItemTester) context.getBean("tester");

    client.testService();//from  w w  w . j a  v a  2  s.c  om
    System.exit(0);
}

From source file:com.github.liyp.rabbitmq.demo.Main.java

public static void main(String[] args) throws IOException, InterruptedException {
    // start spring context
    @SuppressWarnings({ "resource" })
    ApplicationContext context = new ClassPathXmlApplicationContext(
            "com/github/liyp/rabbitmq/demo/applicationContext.xml");

    RabbitTemplate rabbitTemplate = (RabbitTemplate) context.getBean("rabbitTemplate");
    for (int i = 0; i < 200; i++) {
        rabbitTemplate.convertAndSend("queue_one", "test queue 1 " + i);
        rabbitTemplate.convertAndSend("queue_two", new MsgBean("test queue 2 " + i));
    }// w  w  w .ja  va2  s.c om
    Thread.sleep(5000);
    ThreadPoolTaskExecutor threadExe = (ThreadPoolTaskExecutor) context.getBean("taskExecutor");
    System.out.println(threadExe.getActiveCount());
    System.out.println(threadExe.getCorePoolSize());
    System.out.println(threadExe.getMaxPoolSize());
    System.out.println(threadExe.getPoolSize());
    System.out.println(threadExe.getThreadPoolExecutor().getCorePoolSize());

    // System.out.println("rsv: " +
    // rabbitTemplate.receiveAndConvert("queue_two"));
}

From source file:org.powertac.logtool.Logtool.java

/**
 * Sets up the logtool, delegates everything to a LogtoolCore instance.
 *//*  w  w w  . j a  v  a2  s.co  m*/
public static void main(String[] args) {
    AbstractApplicationContext context = new ClassPathXmlApplicationContext("logtool.xml");
    context.registerShutdownHook();

    // find the LogtoolCore bean
    LogtoolCore lc = (LogtoolCore) context.getBeansOfType(LogtoolCore.class).values().toArray()[0];
    lc.processCmdLine(args);

    // if we get here, it's time to exit
    System.exit(0);
}

From source file:com.apress.prospringintegration.channels.directchannel.Main.java

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

    String contextName = "direct-channel.xml";

    ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(contextName);
    applicationContext.start();//from   w  ww.j  av  a2 s  .c om

    ProblemReporter problemReporter = applicationContext.getBean(ProblemReporter.class);
    TicketGenerator ticketGenerator = applicationContext.getBean(TicketGenerator.class);
    TicketMessageHandler ticketMessageHandler = applicationContext.getBean(TicketMessageHandler.class);

    DirectChannel channel = applicationContext.getBean("ticketChannel", DirectChannel.class);
    channel.subscribe(ticketMessageHandler);

    List<Ticket> tickets = ticketGenerator.createTickets();
    for (Ticket ticket : tickets) {
        problemReporter.openTicket(ticket);
    }
}

From source file:com.shopzilla.api.driver.ProductClientDriver.java

public static void main(String[] args) {
    ApplicationContext applicationContext = new ClassPathXmlApplicationContext(
            "classpath:applicationContext.xml");
    ProductClient client = applicationContext.getBean("productClient", ProductClient.class);
    credentialFactory = applicationContext.getBean("credentialFactory", CredentialFactory.class);
    apiKey = credentialFactory.getPublisherApiKey();
    publisherId = credentialFactory.getPublisherId();
    client.doProductSearch(apiKey, publisherId, keyword, 10);
}

From source file:com.example.customerservice.client.CustomerServiceSpringClient.java

public static void main(String args[]) throws Exception {
    // Initialize the spring context and fetch our test client
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
            new String[] { "classpath:client-applicationContext.xml" });
    CustomerServiceTester client = (CustomerServiceTester) context.getBean("tester");

    client.testCustomerService();//w  w  w  .j a  va2  s  . c om
    System.exit(0);
}

From source file:com.apress.prospringintegration.endpoints.consumerendpointfactory.Main.java

public static void main(String[] args) {
    ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(
            "consumer-endpoint-factory.xml");
    applicationContext.start();/* ww w  .ja  v a  2s. c o m*/

    ProblemReporter problemReporter = applicationContext.getBean(ProblemReporter.class);
    TicketGenerator ticketGenerator = applicationContext.getBean(TicketGenerator.class);

    List<Ticket> tickets = ticketGenerator.createTickets();

    int count = 0;
    while (count++ < 5) {
        for (Ticket ticket : tickets) {
            problemReporter.openTicket(ticket);
        }
    }
}

From source file:com.apress.prospringintegration.messageflow.filter.MainItemFilter.java

public static void main(String[] args) throws Exception {
    ApplicationContext context = new ClassPathXmlApplicationContext("filter-item.xml");

    MessageChannel channel = context.getBean("marketItemChannel", MessageChannel.class);
    MarketItemCreator marketItemCreator = context.getBean("marketItemCreator", MarketItemCreator.class);

    for (MarketItem marketItem : marketItemCreator.getMarketItems()) {
        channel.send(//from   w  w  w  .j  av  a  2  s . c om
                MessageBuilder.withPayload(marketItem).setHeader("ITEM_TYPE", marketItem.getType()).build());
    }
}

From source file:com.soluvas.samples.eventfx.camel.MainRouteBuilder.java

/**
 * A main() so we can easily run these routing rules in our IDE
 *///from  ww w  .  ja v  a  2 s. c o m
public static void main(String... args) {
    new ClassPathXmlApplicationContext("META-INF/spring/*.xml");
}