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[] paths, Class<?> clazz) 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:org.bakujug.springrental.Main.java

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

    ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml",
            "Spring-DataSource.xml");

    CustomerRepository customerRepository = applicationContext.getBean("customerRepository",
            CustomerRepository.class);

    Customer customer = new Customer();
    customer.setLastname("Ilkin");
    customer.setFirstname("Abdullayev");
    customer.setAge(23);/*from  w  ww. ja va  2s. c om*/
    customerRepository.save(customer);

    //   Customer customer = customerRepository.getCustomerByName("Sunal");
    //  System.out.println(customer);

    // RentalService rentalService = (RentalService) applicationContext.getBean("rentalService");

    //        Rental rental = rentalService.rentACar("Ilkin", new Car("Fiesta"), getRentalBegin(), getRentalEnd());
    //
    //        System.out.println("Rental status: "+ rental.getCustomer());
}

From source file:siia.monitoring.history.HistoryDemo1.java

public static void main(String[] args) {
    new ClassPathXmlApplicationContext("context1.xml", HistoryDemo1.class);
}

From source file:siia.monitoring.history.HistoryDemo2.java

public static void main(String[] args) {
    new ClassPathXmlApplicationContext("context2.xml", HistoryDemo2.class);
}

From source file:olegz.scala.spring.SpringDemo.java

/**
 * @param args/*ww  w  . j av a2  s.co m*/
 */
public static void main(String[] args) {
    ApplicationContext context = new ClassPathXmlApplicationContext("scala-config.xml", SpringDemo.class);
    SimpleSpringBean functionDirect = context.getBean("functionDirect", SimpleSpringBean.class);
    functionDirect.printMessage("Hello Spring-Scala");

    SimpleSpringBean functionViaFactoryBean = context.getBean("functionViaFactoryBean", SimpleSpringBean.class);
    functionViaFactoryBean.printMessage("Hello Spring-Scala");
}

From source file:com.apress.prospringintegration.gateways.client.MainJMSGateway.java

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

    ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(
            "/META-INF/spring/integration/pro-spring-integration/gateway-jms-service.xml",
            "/META-INF/spring/integration/pro-spring-integration/common.xml");

    ClassPathXmlApplicationContext ctx1 = new ClassPathXmlApplicationContext(
            "/META-INF/spring/integration/pro-spring-integration/gateway-jms-client.xml",
            "/META-INF/spring/integration/pro-spring-integration/common.xml");

    TicketIssuer ticketIssuer = ctx1.getBean("ticketIssueGateway", TicketIssuer.class);

    for (int i = 0; i < 20; i++) {
        Ticket ticket = ticketIssuer.issueTicket(i);

        System.out.println("Ticket " + ticket + " was issued on:" + ticket.getIssueDateTime()
                + " with ticket id: " + ticket.getTicketId());

    }//from   ww  w . j  a  v a  2 s .  c om
}

From source file:demo.vmware.app.DB.java

/**
 * @param args//  w w  w.j  av  a2s.  c  o  m
 */
public static void main(String[] args) throws Exception {
    String resource = ("spring-db.xml");
    ClassPathXmlApplicationContext mainContext = new ClassPathXmlApplicationContext(new String[] { resource },
            false);
    mainContext.setValidating(true);
    mainContext.refresh();

    Thread.sleep(Long.MAX_VALUE);
}

From source file:org.springone2gx_2011.integration.error.ErrorDemo.java

public static void main(String[] args) {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("error-config.xml",
            ErrorDemo.class);
    //      ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("error-aggregator-config.xml", ErrorDemo.class);
    ErrorDemoGateway gateway = context.getBean(ErrorDemoGateway.class);
    gateway.process(Arrays.asList("bye", "hello"));
}

From source file:demo.vmware.app.Locator.java

/**
 * @param args/*  w  w  w  .jav  a2s  . c o m*/
 */
public static void main(String[] args) throws Exception {
    String resource[] = { "spring-cache-locator.xml" };
    ClassPathXmlApplicationContext mainContext = new ClassPathXmlApplicationContext(resource, false);
    mainContext.setValidating(true);
    mainContext.refresh();

    Thread.sleep(Long.MAX_VALUE);
}

From source file:siia.monitoring.jmx.JmxDemo.java

public static void main(String[] args) throws InterruptedException {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("context.xml", JmxDemo.class);
    MessageChannel channel = context.getBean("channel", MessageChannel.class);
    for (int i = 0; i < 1000; i++) {
        channel.send(MessageBuilder.withPayload(i + "").build());
        Thread.sleep(3000);// w  w w.  j  a  v a2s .  co  m
    }
}

From source file:org.springone2gx_2011.integration.segmentation.SegmentationDemo.java

/**
 * @param args/* w ww.  j a v a  2s  . c om*/
 */
public static void main(String[] args) {
    ApplicationContext context = new ClassPathXmlApplicationContext("segmentation-config.xml",
            SegmentationDemo.class);
    SegmentOne gateway = context.getBean(SegmentOne.class);
    System.out.println("Result:" + gateway.process(10));

}