List of usage examples for org.springframework.context.support ClassPathXmlApplicationContext start
@Override public void start()
From source file:com.alibaba.dubbo.examples.merge.MergeConsumer2.java
public static void main(String[] args) throws Exception { String config = MergeConsumer2.class.getPackage().getName().replace('.', '/') + "/merge-consumer2.xml"; ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(config); context.start(); MergeService mergeService = (MergeService) context.getBean("mergeService"); for (int i = 0; i < Integer.MAX_VALUE; i++) { try {/* ww w . ja va 2 s. com*/ List<String> result = mergeService.mergeResult(); System.out.println("(" + i + ") " + result); Thread.sleep(1000); } catch (Exception e) { e.printStackTrace(); } } }
From source file:com.github.ffremont.SpringBatchApplication.java
/** * @param args the command line arguments *///from w w w.j a v a2s . c o m public static void main(String[] args) { ClassPathXmlApplicationContext cpt = new ClassPathXmlApplicationContext("simple-job.xml"); cpt.start(); JobLauncher jobLauncher = (JobLauncher) cpt.getBean("jobLauncher"); Job job = (Job) cpt.getBean("partitionSimpleStepJob"); JobParameters parameter = new JobParametersBuilder().addDate("date", new Date()).toJobParameters(); try { jobLauncher.run(job, parameter); } catch (JobExecutionException ex) { LOG.error("Oups", ex); } }
From source file:org.gflogger.perftest.SpringTest.java
public static void main(String[] args) throws Throwable { final SpringTest springTest = new SpringTest(); final ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("classpath:app-context.xml"); ctx.start(); springTest.test();//from ww w . j av a 2 s. com ctx.stop(); }
From source file:com.alibaba.dubbo.examples.redis.RedisConsumer.java
@SuppressWarnings("unchecked") public static void main(String[] args) throws Exception { String config = RedisConsumer.class.getPackage().getName().replace('.', '/') + "/redis-consumer.xml"; ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(config); context.start(); Map<String, Object> cache = (Map<String, Object>) context.getBean("cache"); cache.remove("hello"); Object value = cache.get("hello"); System.out.println(value);//from w w w. j a va 2 s.com if (value != null) { throw new IllegalStateException(value + " != null"); } cache.put("hello", "world"); value = cache.get("hello"); System.out.println(value); if (!"world".equals(value)) { throw new IllegalStateException(value + " != world"); } }
From source file:edu.berkeley.path.next.ResultsProcessor.ResultsProcessorApp.java
public static void main(String[] args) throws Exception { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("results-processor.xml"); context.start(); final Logger logger = LogManager.getLogger(ResultsProcessorApp.class.getName()); logger.info("ResultsProcessorApp initialized "); }
From source file:com.apress.prospringintegration.App.java
public static void main(String[] args) { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("classpath:spring-context.xml"); context.start(); MessageChannel input = (MessageChannel) context.getBean("input"); PollableChannel output = (PollableChannel) context.getBean("output"); input.send(MessageBuilder.withPayload("Pro Spring Integration Example").build()); Message<?> reply = output.receive(); System.out.println("received: " + reply); }
From source file:com.alibaba.dubbo.examples.memcached.MemcachedConsumer.java
@SuppressWarnings("unchecked") public static void main(String[] args) throws Exception { String config = MemcachedConsumer.class.getPackage().getName().replace('.', '/') + "/memcached-consumer.xml"; ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(config); context.start(); Map<String, Object> cache = (Map<String, Object>) context.getBean("cache"); cache.remove("hello"); Object value = cache.get("hello"); System.out.println(value);//w w w . ja va2s . c om if (value != null) { throw new IllegalStateException(value + " != null"); } cache.put("hello", "world"); value = cache.get("hello"); System.out.println(value); if (!"world".equals(value)) { throw new IllegalStateException(value + " != world"); } System.in.read(); }
From source file:com.hm.SSI.dubbo.DubboConsumer.java
public static void main(String[] args) throws Exception { String config = "classpath:/dubbo-consumer.xml"; //AnnotationConsumer.class.getPackage().getName().replace('.', '/') + "/annotation-consumer.xml"; ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(config); context.start(); final AnnotationAction annotationAction = (AnnotationAction) context.getBean("annotationAction"); String hello = annotationAction.doSayHello("world"); System.out.println("result :" + hello); System.in.read();/*w w w. j av a 2 s .c o m*/ }
From source file:com.apress.prospringintegration.messaging.activemq.jms.adapter.TicketReporterMain.java
public static void main(String[] args) throws Throwable { String contextName = "ticket-reporter.xml"; ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(contextName); applicationContext.start(); ProblemReporter problemReporter = applicationContext.getBean(ProblemReporter.class); TicketGenerator ticketGenerator = applicationContext.getBean(TicketGenerator.class); while (true) { List<Ticket> tickets = ticketGenerator.createTickets(); for (Ticket ticket : tickets) { problemReporter.openTicket(ticket); }/* ww w .ja va 2s . c om*/ Thread.sleep(5000); } }
From source file:com.apress.prospringintegration.serviceactivator.Main.java
public static void main(String[] args) throws Exception { String contextName = "service-activator.xml"; ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(contextName); applicationContext.start(); ProblemReporter problemReporter = applicationContext.getBean(ProblemReporter.class); TicketGenerator ticketGenerator = applicationContext.getBean(TicketGenerator.class); while (true) { List<Ticket> tickets = ticketGenerator.createTickets(); for (Ticket ticket : tickets) { problemReporter.openTicket(ticket); }//from w w w . j av a2 s . c om Thread.sleep(500); } }