List of usage examples for org.springframework.context.support ClassPathXmlApplicationContext start
@Override public void start()
From source file:com.apress.prospringintegration.security.SecurityMain.java
public static void main(String[] args) throws Exception { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("classpath:secure-channel.xml"); context.start(); MessageChannel channel = context.getBean("secureCustomerData", MessageChannel.class); //Secure user with privileges login("secureuser", "password", "ROLE_ADMIN"); try {/*from www .j a va 2 s. co m*/ send(channel, "hello secure world!"); } catch (Exception ex) { System.out.println("Unable to send message for secureuser"); } //Secure user with privileges login("unsecureuser", "password", "ROLE_USER"); try { send(channel, "hello secure world!"); } catch (Exception ex) { System.out.println("Unable to send message for unsecureuser"); ex.printStackTrace(); } }
From source file:com.shopzilla.spring.messaging.hornetq.config.example.HornetQConfigurationExample.java
public static void main(String[] args) throws Throwable { ClassPathXmlApplicationContext classPathXmlApplicationContext = new ClassPathXmlApplicationContext( "hornetqns-example.xml"); classPathXmlApplicationContext.start(); }
From source file:org.fusesource.cloudmix.tests.consumer.Main.java
public static void main(String[] args) { if (args.length > 0 && args[0].equals("-debug")) { Map<Object, Object> properties = new TreeMap<Object, Object>(); properties.putAll(System.getProperties()); for (Map.Entry<Object, Object> entry : properties.entrySet()) { System.out.println(" " + entry.getKey() + " = " + entry.getValue()); }/*www . j a v a 2s . co m*/ } ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext( "META-INF/spring/context.xml"); applicationContext.start(); System.out.println("Enter quit to stop"); try { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); while (true) { String line = reader.readLine(); if (line == null || line.trim().equalsIgnoreCase("quit")) { break; } } } catch (IOException e) { System.err.println("Caught: " + e); e.printStackTrace(System.err); } applicationContext.close(); }
From source file:com.apress.prospringintegration.messageflow.workflow.WorkflowMainClient.java
public static void main(String[] ars) throws Exception { ClassPathXmlApplicationContext classPathXmlApplicationContext = new ClassPathXmlApplicationContext( "workflow-gateway.xml"); classPathXmlApplicationContext.start(); ProcessEngine processEngine = classPathXmlApplicationContext.getBean(ProcessEngine.class); deployProcessDefinitions(processEngine, "processes/hello.bpmn20.xml", "processes/gateway.bpmn20.xml"); Map<String, Object> processVariables = new HashMap<String, Object>(); processVariables.put("customerId", 2); ProcessInstance pi = processEngine.getRuntimeService().startProcessInstanceByKey("sigateway", processVariables);/* w w w. j a v a 2s .com*/ log.debug("the process instance has been started: PI ID # " + pi.getId()); Thread.sleep(1000 * 20); log.debug("waited 20s"); }
From source file:org.fusesource.cloudmix.tests.broker.Main.java
public static void main(String[] args) { if (verbose || (args.length > 0 && args[0].equals("-debug"))) { Map<Object, Object> properties = new TreeMap<Object, Object>(); properties.putAll(System.getProperties()); for (Map.Entry<Object, Object> entry : properties.entrySet()) { System.out.println(" " + entry.getKey() + " = " + entry.getValue()); }/*from w w w. j a v a 2 s. c o m*/ } ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext( "META-INF/spring/activemq.xml"); applicationContext.start(); System.out.println("Enter quit to stop"); try { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); while (true) { String line = reader.readLine(); if (line == null || line.trim().equalsIgnoreCase("quit")) { break; } } } catch (IOException e) { System.err.println("Caught: " + e); e.printStackTrace(System.err); } applicationContext.close(); }
From source file:com.alibaba.dubbo.examples.heartbeat.HeartbeatProvider.java
public static void main(String[] args) throws Exception { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( HeartbeatProvider.class.getPackage().getName().replace('.', '/') + "/heartbeat-provider.xml"); context.start(); System.in.read();/*from w w w .j a v a 2s.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(); NotifyImpl notify = (NotifyImpl) context.getBean("callback"); HelloService service = (HelloService) context.getBean("service"); System.out.println("dubbo consumer running..."); int i = 0;//w w w . j a v a2 s. com 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.heartbeat.HeartbeatConsumer.java
public static void main(String[] args) throws Exception { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( HeartbeatConsumer.class.getPackage().getName().replace('.', '/') + "/heartbeat-consumer.xml"); context.start(); HelloService hello = (HelloService) context.getBean("helloService"); for (int i = 0; i < Integer.MAX_VALUE; i++) { System.out.println(hello.sayHello("kimi-" + i)); Thread.sleep(10000);/*ww w.j a v a 2s . co m*/ } }
From source file:com.apress.prospringintegration.endpoints.pollingconsumer.Main.java
public static void main(String[] args) { ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext( "polling-consumer.xml"); applicationContext.start(); ProblemReporter problemReporter = applicationContext.getBean(ProblemReporter.class); TicketMessageHandler ticketMessageHandler = applicationContext.getBean(TicketMessageHandler.class); TicketGenerator ticketGenerator = applicationContext.getBean(TicketGenerator.class); QueueChannel channel = applicationContext.getBean("ticketChannel", QueueChannel.class); // Define the polling consumer PollingConsumer ticketConsumer = new PollingConsumer(channel, ticketMessageHandler); ticketConsumer.setReceiveTimeout(RECEIVE_TIMEOUT); ticketConsumer.setBeanFactory(applicationContext); // Setup the poller using periodic trigger PeriodicTrigger periodicTrigger = new PeriodicTrigger(1000); periodicTrigger.setInitialDelay(5000); periodicTrigger.setFixedRate(false); PollerMetadata pollerMetadata = new PollerMetadata(); pollerMetadata.setTrigger(periodicTrigger); pollerMetadata.setMaxMessagesPerPoll(3); ticketConsumer.setPollerMetadata(pollerMetadata); // Starts the polling consumer in the other thread ticketConsumer.start();// ww w .java 2s.c o m // Generates messages and sends to the channel List<Ticket> tickets = ticketGenerator.createTickets(); while (true) { for (Ticket ticket : tickets) { problemReporter.openTicket(ticket); } } }
From source file:nl.mindef.c2sc.nbs.olsr.pud.uplink.server.Main.java
public static void main(String[] args) { logger.info("RelayServer starting"); try {/* ww w .j a v a 2 s . com*/ ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "classpath:META-INF/spring/application-context.xml"); logger.info("RelayServer started"); context.start(); UplinkReceiver uplinkReceiver = (UplinkReceiver) context.getBean("UplinkReceiver"); uplinkReceiver.join(); logger.info("RelayServer stopped"); context.stop(); context.close(); context.destroy(); } catch (Exception e) { e.printStackTrace(); } }