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.alibaba.akka.AkkaMain.java

public static void main(String[] args) {
    ApplicationContext ctx = new ClassPathXmlApplicationContext("biz-actor.xml");

    DataQueryService dataQueryService = (DataQueryService) ctx.getBean("dataQueryService");
    QueryParam queryParam = new QueryParam();
    List<Item> items = dataQueryService.query(queryParam);
    for (Item item : items) {
        System.out.println(item.getContent());
    }/*from   ww w  .  j a v  a 2  s . c  o  m*/
}

From source file:com.mycompany.integration.NewMain.java

/**
 * @param args the command line arguments
 *///from   w  w  w. ja  v a  2 s .  c o  m
public static void main(String[] args) {
    ApplicationContext context = new ClassPathXmlApplicationContext("spring-integration.xml");

    MessageChannel channel = context.getBean("toRabbit", MessageChannel.class);

    for (int i = 0; i < 10; i++) {
        channel.send(build(UUID.randomUUID().toString()));
    }
}

From source file:edu.eci.arsw.aop.spring.idol.MainProgram.java

/**
 * @param args the command line arguments
 *//*w  ww  .  j a va2s.  c o m*/
public static void main(String[] args) {
    ApplicationContext ac = new ClassPathXmlApplicationContext("spring-simple-idol.xml");
    Performer pf = (Performer) ac.getBean("eddie");
    try {
        pf.perform();
    } catch (PerformanceException ex) {
        Logger.getLogger(MainProgram.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:dev.dposadsky.java.swingteacherdesktop.main.Start.java

public static void main(String[] args) throws SQLException {
    SwingUtilities.invokeLater(new Runnable() {

        @Override/*from   w  w w  .  j  a  v a  2 s .  c  o  m*/
        public void run() {
            ApplicationContext context = new ClassPathXmlApplicationContext("context.xml");
            MainFrameController mainFrameController = (MainFrameController) context
                    .getBean("mainFrameController");
        }
    });
}

From source file:org.seedstack.spring.batch.fixtures.FlatFileBatchDemo.java

public static void main(String[] argv) throws Exception {
    String jobFile = argv[0];/*  w  ww .j ava2 s .c  o  m*/

    ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(
            new String[] { "simple-job-launcher-context.xml", jobFile });

    Job job = applicationContext.getBean(Job.class);

    Map<String, JobParameter> jobParametersMap = new HashMap<>();

    jobParametersMap.put("file", new JobParameter(argv[1]));

    JobParameters jobParameters = new JobParameters(jobParametersMap);

    JobLauncher jobLauncher = applicationContext.getBean(JobLauncher.class);

    JobExecution jobExecution = jobLauncher.run(job, jobParameters);

    printStatistics(jobExecution);
}

From source file:br.com.argonavis.eipcourse.messaging.camel.router.RouterSpringExample.java

public static void main(String[] args) throws Exception {
    new ClassPathXmlApplicationContext("/META-INF/camel/router-example.xml");
}

From source file:edu.eci.cosw.samples.logic.Main.java

public static void main(String[] args) {
    ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml");
    ServiceFacade sf = ac.getBean(ServiceFacade.class);
    List<Cliente> clientes = null;
    try {//from w  w  w. j a  v a2s.c om
        clientes = sf.clientesReportadosPorApellido("var");
    } catch (ClientEvaluationException ex) {
        System.out.println("Fallo consulta por apellido");
        Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
    }
    if (clientes != null) {
        for (Cliente c : clientes) {
            System.out.println(
                    c.getIdcliente() + " " + c.getNombre() + " " + c.getDireccion() + " " + c.getTelefono());
        }
    }
    try {
        //Registrar un nuevo cliente
        sf.registrarCliente(1072672, "Guillermo Alvarez", "Calle 3#3E-116", "1234567");
    } catch (ClientEvaluationException ex) {
        System.out.println("Fallo insercion");
        Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
    }

    //Crear un pedido
    Date d = new Date(2015 - 1900, 8, 23);
    int[] idProductos = { 1 };
    int[] cantidades = { 3 };
    sf.registrarPedido(1072672, idProductos, cantidades, d);
    //Mirar en la base de datos que se creo el pedido de este cliente     
    try {
        //Consulta Fallida
        sf.registrarCliente(333, "Luis Alvarez", "Calle 3E#3-116", "1234567");
    } catch (ClientEvaluationException ex) {
        Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:mk.finki.ranggo.aggregator.Aggregator.java

public static void main(String[] args) {
    ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
            "classpath:spring/application-config.xml");

    //make sure alchemyapi.key hold your license key
    final String alchemyapi_key = context.getBeanFactory().resolveEmbeddedValue("${alchemyapi.key}");

    PersonRepository personRepository = context.getBean(PersonRepository.class);
    ContentRepository contentRepository = context.getBean(ContentRepository.class);

    ContentsAggregator aggregator = new ContentsAggregatorImpl(alchemyapi_key, personRepository,
            contentRepository);/* ww w  .ja va  2s.co  m*/

    //populates the data store with the test dataset
    Aggregator.test(aggregator);

    //executes update method
    Aggregator.update(null, aggregator);

    context.close();
}

From source file:com.anton.dev.tqrbs2.basic.BasicSpring.java

public static void main(String[] args) throws Exception {
    AbstractApplicationContext ctx = new ClassPathXmlApplicationContext("basic-context.xml");
    RabbitTemplate template = ctx.getBean(RabbitTemplate.class);
    String msg = "Hello, world Rabbit!";
    LOGGER.info("Enviando Spring: " + msg);
    template.convertAndSend(msg);// w w  w .  jav a2  s.  c  o  m
    Thread.sleep(1000);
    ctx.destroy();
}

From source file:de.ebf.aopspringdemo.App.java

public static void main(String[] args) {
    appContext = new ClassPathXmlApplicationContext("beans.xml");
    cameraActions_Tutorial_80();/*from www .  ja v  a2  s  .com*/
}