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:de.extra.client.crypto.ExtraPasswordEncryptor.java
public static void main(final String[] args) { final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring-encryption.xml"); final StringEncryptor stringEncryptor = context.getBean("configurationEncryptor", StringEncryptor.class); if (args == null || args.length != 1) { System.err.println("Argument fehlt. Aufruf mit\nencrypt-password.bat <Passwort>"); System.exit(ReturnCode.TECHNICAL.getCode()); }//w w w . j av a2s. c o m System.out.println("ENC(" + stringEncryptor.encrypt(args[0]) + ")"); System.exit(ReturnCode.SUCCESS.getCode()); }
From source file:siia.monitoring.wiretap.WireTapDemo.java
public static void main(String[] args) { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("context.xml", WireTapDemo.class); MessageChannel debitChannel = context.getBean("debitChannel", MessageChannel.class); Message<Debit> message1 = MessageBuilder.withPayload(new Debit(new BigDecimal(5000), "SMALL")).build(); Message<Debit> message2 = MessageBuilder.withPayload(new Debit(new BigDecimal(25000), "BIG")).build(); debitChannel.send(message1);//w ww. jav a 2 s. c o m debitChannel.send(message2); }
From source file:com.apress.prospringintegration.errorhandling.ErrorHandlingDefault.java
public static void main(String[] args) { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "classpath:errorhandling/error-handling-default.xml"); MessageChannel input = context.getBean("input", MessageChannel.class); input.send(MessageBuilder.withPayload("Sample Message").build()); }
From source file:com.apress.prospringintegration.social.mail.SmtpMail.java
public static void main(String[] args) { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("/spring/mail/smtp-mail.xml", SmtpMail.class); MessageChannel input = context.getBean("input", MessageChannel.class); Message<String> message = MessageBuilder.withPayload("This is a test").build(); input.send(message);/* w ww . ja v a 2s . c o m*/ context.stop(); }
From source file:com.apress.prospringintegration.errorhandling.ErrorHandlingIntegration.java
public static void main(String[] args) { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "classpath:errorhandling/error-handling-integration.xml"); MessageChannel input = context.getBean("input", MessageChannel.class); input.send(MessageBuilder.withPayload("Sample Message").build()); }
From source file:com.apress.prospringintegration.social.xmpp.XmppOutbound.java
public static void main(String[] args) { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "/spring/xmpp/xmpp-outbound.xml", XmppOutbound.class); MessageChannel input = context.getBean("input", MessageChannel.class); Message<String> message = MessageBuilder.withPayload("This is a test").build(); input.send(message);//from w w w . j av a 2 s .c om context.stop(); }
From source file:com.apress.prospringintegration.transform.HeaderEnricher.java
public static void main(String[] args) { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "classpath: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);/*w w w .j ava2 s.c o m*/ Message<?> reply = output.receive(); System.out.println("received: " + reply); }
From source file:com.apress.prospringintegration.wiretap.WireTapExample.java
public static void main(String[] args) { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "classpath:wiretap/wiretap.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 w ww. j av a2 s . co m Message<?> reply = output.receive(); System.out.println("received: " + reply.getPayload()); }
From source file:com.apress.prospringintegration.transform.MapTransformer.java
public static void main(String[] args) { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "classpath:map-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);/* w ww . j av a 2s . c o m*/ Message<?> reply = output.receive(); System.out.println("received: " + reply.getPayload()); }
From source file:com.apress.prospringintegration.transform.XmlTransformer.java
public static void main(String[] args) { ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "classpath:xml-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);// w ww.j av a2 s. c o m Message<?> reply = output.receive(); System.out.println("received: " + reply.getPayload()); }