List of usage examples for org.springframework.context.support ClassPathXmlApplicationContext ClassPathXmlApplicationContext
public ClassPathXmlApplicationContext(String... configLocations) throws BeansException
From source file:com.apress.prospringintegration.messageflow.aggregator.MainMarketDataAggregator.java
public static void main(String[] args) throws Exception { ApplicationContext context = new ClassPathXmlApplicationContext("aggregator.xml"); MessageChannel channel = context.getBean("marketDataInputChannel", MessageChannel.class); MarketItemCreator marketItemCreator = context.getBean("marketItemCreator", MarketItemCreator.class); for (MarketItem marketItem : marketItemCreator.getMarketItems()) { channel.send(MessageBuilder.withPayload(marketItem).build()); }//w w w.java 2s .c om }
From source file:org.pikax.log.generator.Main.java
/** * @param args/*from w w w . j ava2s . c o m*/ */ public static void main(final String[] args) { int variant = getVariant(args); applicationContext = new ClassPathXmlApplicationContext("spring/application-context.xml"); final LogGeneratorFactory logGeneratorFactory = getBean(LogGeneratorFactory.class); final LogGenerator logGenerator = logGeneratorFactory.newInstance(variant); logGenerator.generate(1); }
From source file:com.apress.prospringintegration.messageflow.filter.MainMessageSelectorItemFilter.java
public static void main(String[] args) throws Exception { ApplicationContext context = new ClassPathXmlApplicationContext("filter-selector.xml"); MessageChannel channel = context.getBean("marketItemChannel", MessageChannel.class); MarketItemCreator marketItemCreator = context.getBean("marketItemCreator", MarketItemCreator.class); for (MarketItem marketItem : marketItemCreator.getMarketItems()) { channel.send(MessageBuilder.withPayload(marketItem).build()); }/*w w w .ja va 2s .c o m*/ }
From source file:net.bafeimao.umbrella.servers.world.WorldServer.java
public static void main(String[] args) { new ClassPathXmlApplicationContext("world/context.xml"); }
From source file:koper.reactor.demo.CustomerApp.java
public static void main(String[] args) { ApplicationContext context = new ClassPathXmlApplicationContext( "classpath:kafka/context-data-consumer.xml"); ConsumerLauncher consumerLauncher = context.getBean(ConsumerLauncher.class); // we have close the switch in context-data-consumer.xml profile(autoStart) temporary consumerLauncher.start();//from w ww . j a v a 2 s. c o m }
From source file:com.github.liyp.dubbo.consumer.Consumer.java
public static void main(String[] args) throws Exception { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( new String[] { "com/github/liyp/dubbo/consumer/consumer.xml" }); context.start();/*from w ww . j a v a 2s .c om*/ NotifyImpl notify = (NotifyImpl) context.getBean("callback"); HelloService service = (HelloService) context.getBean("service"); System.out.println("dubbo consumer running..."); int i = 0; while (true) { String res = service.sayHello(new HelloBean(i, "lee")); // service.sayHello(i); System.out.println(ai.incrementAndGet()); if (ai.get() >= limit) { locked = true; cdl = new CountDownLatch(limit); cdl.await(); locked = false; } // Thread.sleep(1000); i++; } }
From source file:com.alibaba.dubbo.examples.generic.GenericConsumer.java
public static void main(String[] args) throws Exception { String config = GenericConsumer.class.getPackage().getName().replace('.', '/') + "/generic-consumer.xml"; ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(config); context.start();// ww w. j av a2 s . c o m IUserService userservice = (IUserService) context.getBean("userservice"); User user = userservice.get(new Params("a=b")); System.out.println(user); System.in.read(); }
From source file:com.apress.prospringintegration.jdbc.JdbcGateway.java
public static void main(String[] args) throws Exception { ApplicationContext context = new ClassPathXmlApplicationContext("/spring/jdbc/jdbc-gateway-context.xml"); MessageChannel input = context.getBean("input", MessageChannel.class); PollableChannel output = context.getBean("output", PollableChannel.class); Map<String, Object> rowMessage = new HashMap<String, Object>(); rowMessage.put("id", 3); rowMessage.put("firstname", "Mr"); rowMessage.put("lastname", "Bill"); rowMessage.put("status", 0); Message<Map<String, Object>> message = MessageBuilder.withPayload(rowMessage).build(); input.send(message);//from w w w . j a va2s. c o m Message<?> reply = output.receive(); System.out.println("Reply message: " + reply); Map<String, Object> rowMap = (Map<String, Object>) reply.getPayload(); for (String column : rowMap.keySet()) { System.out.println("column: " + column + " value: " + rowMap.get(column)); } }
From source file:edu.berkeley.path.next.CTMEngine.CTMEngineApp.java
public static void main(String[] args) throws InterruptedException { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("ctm-engine.xml"); context.start();// w w w.ja v a2s . com final Logger logger = LogManager.getLogger(CTMEngineApp.class.getName()); logger.info("trafficMonitorApp initialized "); JmsPublish jmsPublish = context.getBean(JmsPublish.class); // linkManager creates the data to publish representing ccFramework output LinkManager linkManager = context.getBean(LinkManager.class); logger.info("trafficMonitorApp initialized "); //get a list of output links that we will publish over and over java.util.List<LinkDataRaw> links = new ArrayList<LinkDataRaw>(); links = linkManager.getLinkList(); logger.info("trafficMonitorApp links to publish: " + links.size()); //counters int x = 0; int oneHour = 216000; int oneMinute = 3600; while (x < oneMinute) { //use SLF interface which provides for parameterized logging logger.info("CTMEngineApp sendLinkList counter: " + x); jmsPublish.sendLinkList(links); //sleep for a third of a second //Thread.sleep(10); x++; } }
From source file:demo.order.client.Client.java
public static void main(String args[]) throws Exception { // START SNIPPET: client ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( new String[] { "demo/order/client/client-beans.xml" }); OrderProcess client = (OrderProcess) context.getBean("orderClient"); OrderProcessClientHandler clientInterceptor = new OrderProcessClientHandler(); clientInterceptor.setUserName("John"); clientInterceptor.setPassword("password"); org.apache.cxf.endpoint.Client cxfClient = ClientProxy.getClient(client); cxfClient.getOutInterceptors().add(clientInterceptor); Order order = new Order(); order.setCustomerID("C001"); order.setItemID("I001"); order.setQty(100);/* ww w . j a v a2 s . c o m*/ order.setPrice(200.00); String orderID = client.processOrder(order); String message = (orderID == null) ? "Order not approved" : "Order approved; order ID is " + orderID; System.out.println(message); System.exit(0); }