List of usage examples for org.springframework.context.support ClassPathXmlApplicationContext getBean
@Override public <T> T getBean(String name, Class<T> requiredType) throws BeansException
From source file:com.apress.prospringintegration.claimcheck.ClaimCheckExample.java
public static void main(String[] args) { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "/spring/claimcheck-context.xml"); MessageChannel input = context.getBean("checkinChannel", MessageChannel.class); PollableChannel output = context.getBean("checkoutChannel", PollableChannel.class); Map<String, String> customerMap = new HashMap<String, String>(); customerMap.put("firstName", "John"); customerMap.put("lastName", "Smith"); customerMap.put("address", "100 State Street"); customerMap.put("city", "Los Angeles"); customerMap.put("state", "CA"); customerMap.put("zip", "90064"); Message<Map<String, String>> message = MessageBuilder.withPayload(customerMap).build(); input.send(message);/*w w w .j a v a 2 s . c o m*/ Message<?> reply = output.receive(); System.out.println("received: " + reply.getPayload()); }
From source file:com.apress.prospringintegration.transform.JsonTransformer.java
public static void main(String[] args) { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "classpath:json-transformer.xml"); MessageChannel input = context.getBean("input", MessageChannel.class); PollableChannel output = context.getBean("output", PollableChannel.class); Customer customer = new Customer(); customer.setFirstName("John"); customer.setLastName("Smith"); customer.setAddress("100 State Street"); customer.setCity("Los Angeles"); customer.setState("CA"); customer.setZip("90064"); System.out.println("toString(): " + customer.toString()); Message<Customer> message = MessageBuilder.withPayload(customer).build(); input.send(message);//from ww w . jav a2 s. c o m Message<?> reply = output.receive(); System.out.println("received: " + reply.getPayload()); }
From source file:com.apress.prospringintegration.monitoring.MonitoringExample.java
public static void main(String[] args) { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "classpath:monitoring/monitoring.xml"); ProcessMessage processMessage = context.getBean("processMessage", ProcessMessage.class); for (int i = 0; i < 10; i++) { processMessage.processMessage("Process"); processMessage.checkMessage("Check"); }/*from w ww . ja v a2 s . co m*/ while (true) { try { Thread.sleep(60000); } catch (InterruptedException e) { //do nothing } context.stop(); } }
From source file:com.apress.prospringintegration.transform.ToStringTransformer.java
public static void main(String[] args) { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "classpath:string-transformer.xml"); MessageChannel input = context.getBean("input", MessageChannel.class); PollableChannel output = context.getBean("output", PollableChannel.class); Map<String, String> customerMap = new HashMap<String, String>(); customerMap.put("firstName", "John"); customerMap.put("lastName", "Smith"); customerMap.put("address", "100 State Street"); customerMap.put("city", "Los Angeles"); customerMap.put("state", "CA"); customerMap.put("zip", "90064"); System.out.println("toString(): " + customerMap.toString()); Message<Map<String, String>> message = MessageBuilder.withPayload(customerMap).build(); input.send(message);// w w w . j a v a2s . c om Message<?> reply = output.receive(); System.out.println("received: " + reply.getPayload()); }
From source file:com.apress.prospringintegration.transform.PayloadTypeTransformer.java
public static void main(String[] args) { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "classpath:payload-type-transformer.xml"); MessageChannel input = context.getBean("input", MessageChannel.class); PollableChannel output = context.getBean("output", PollableChannel.class); Map<String, String> customerMap = new HashMap<String, String>(); customerMap.put("firstName", "John"); customerMap.put("lastName", "Smith"); customerMap.put("address", "100 State Street"); customerMap.put("city", "Los Angeles"); customerMap.put("state", "CA"); customerMap.put("zip", "90064"); Message<Map<String, String>> message = MessageBuilder.withPayload(customerMap).build(); input.send(message);/*from ww w . j a v a 2s . com*/ Message<?> reply = output.receive(); System.out.println("received: " + reply.getPayload()); }
From source file:com.apress.prospringintegration.social.twitter.TwitterDmOutbound.java
public static void main(String[] args) { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "/spring/twitter/twitter-outbound.xml", TwitterOutbound.class); MessageChannel input = context.getBean("twitterOutbound", MessageChannel.class); Message<String> message = MessageBuilder.withPayload("This is a test") .setHeader(TwitterHeaders.DM_TARGET_USER_ID, "@prosibook").build(); input.send(message);// w w w .j ava 2s .c o m context.stop(); }
From source file:com.apress.prospringintegration.social.twitter.TwitterOutbound.java
public static void main(String[] args) { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "/spring/twitter/twitter-outbound.xml", TwitterOutbound.class); MessageChannel input = context.getBean("twitterOutbound", MessageChannel.class); Message<String> message = MessageBuilder .withPayload("Only can send message once " + Calendar.getInstance().getTimeInMillis()).build(); input.send(message);//from w w w . jav a 2 s. c o m context.stop(); }
From source file:com.apress.prospringintegration.transform.SerializerTransformer.java
public static void main(String[] args) { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "classpath:serializer-transformer.xml"); MessageChannel input = context.getBean("input", MessageChannel.class); PollableChannel output = context.getBean("output", PollableChannel.class); Map<String, String> customerMap = new HashMap<String, String>(); customerMap.put("firstName", "John"); customerMap.put("lastName", "Smith"); customerMap.put("address", "100 State Street"); customerMap.put("city", "Los Angeles"); customerMap.put("state", "CA"); customerMap.put("zip", "90064"); System.out.println("toString(): " + customerMap.toString()); Message<Map<String, String>> message = MessageBuilder.withPayload(customerMap).build(); input.send(message);// w ww. java 2 s .co m Message<?> reply = output.receive(); System.out.println("received: " + reply.getPayload()); }
From source file:com.apress.prospringintegration.social.xmpp.XmppPresenceOutbound.java
public static void main(String[] args) throws Exception { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "/spring/xmpp/xmpp-presence-outbound.xml", XmppOutbound.class); MessageChannel input = context.getBean("xmppOutbound", MessageChannel.class); Presence presence = new Presence(Presence.Type.available, "Out to lunch", 0, Presence.Mode.away); Message<Presence> message = MessageBuilder.withPayload(presence).build(); input.send(message);//ww w. ja v a 2 s. c o m Thread.sleep(10 * 60 * 1000); }
From source file:com.apress.prospringintegration.transform.ProgrammaticHeaderEnricher.java
public static void main(String[] args) { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "classpath:programmatic-header-enricher.xml"); MessageChannel input = context.getBean("input", MessageChannel.class); PollableChannel output = context.getBean("output", PollableChannel.class); Map<String, String> customerMap = new HashMap<String, String>(); customerMap.put("firstName", "John"); customerMap.put("lastName", "Smith"); customerMap.put("address", "100 State Street"); customerMap.put("city", "Los Angeles"); customerMap.put("state", "CA"); customerMap.put("zip", "90064"); Message<Map<String, String>> message = MessageBuilder.withPayload(customerMap).build(); input.send(message);//from ww w. ja va 2 s.co m Message<?> reply = output.receive(); System.out.println("received: " + reply); }