From e4462caf5c82784888337dc5d1bf98e500a857e7 Mon Sep 17 00:00:00 2001 From: Mark Fisher Date: Thu, 29 Apr 2010 18:27:52 +0000 Subject: [PATCH] simplified demo main --- .../samples/helloworld/HelloService.java | 2 +- .../samples/helloworld/HelloWorldDemo.java | 24 +++++-------------- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/spring-integration-samples/helloworld/src/main/java/org/springframework/integration/samples/helloworld/HelloService.java b/spring-integration-samples/helloworld/src/main/java/org/springframework/integration/samples/helloworld/HelloService.java index e7029dfccf..a8f76a8c03 100644 --- a/spring-integration-samples/helloworld/src/main/java/org/springframework/integration/samples/helloworld/HelloService.java +++ b/spring-integration-samples/helloworld/src/main/java/org/springframework/integration/samples/helloworld/HelloService.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2009 the original author or authors. + * Copyright 2002-2010 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-integration-samples/helloworld/src/main/java/org/springframework/integration/samples/helloworld/HelloWorldDemo.java b/spring-integration-samples/helloworld/src/main/java/org/springframework/integration/samples/helloworld/HelloWorldDemo.java index 2d58829cb3..1d40c1de97 100644 --- a/spring-integration-samples/helloworld/src/main/java/org/springframework/integration/samples/helloworld/HelloWorldDemo.java +++ b/spring-integration-samples/helloworld/src/main/java/org/springframework/integration/samples/helloworld/HelloWorldDemo.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2009 the original author or authors. + * Copyright 2002-2010 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,11 +16,8 @@ package org.springframework.integration.samples.helloworld; -import org.springframework.context.ApplicationContext; import org.springframework.context.support.AbstractApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; -import org.springframework.integration.channel.BeanFactoryChannelResolver; -import org.springframework.integration.channel.ChannelResolver; import org.springframework.integration.channel.PollableChannel; import org.springframework.integration.core.MessageChannel; import org.springframework.integration.message.StringMessage; @@ -31,8 +28,7 @@ import org.springframework.integration.message.StringMessage; * low-level example, using Message Channels directly for both input and * output. Notice that the output channel has a queue sub-element. It is * therefore a PollableChannel and its consumers must invoke receive() as - * demonstrated below. The {@link BeanFactoryChannelResolver} is used here - * rather than performing a generic dependency lookup from the context. + * demonstrated below. *

* View the configuration of the channels and the endpoint (a <service-activator/> * element) in 'helloWorldDemo.xml' within this same package. @@ -43,19 +39,11 @@ import org.springframework.integration.message.StringMessage; public class HelloWorldDemo { public static void main(String[] args) { - HelloWorldDemo demo = new HelloWorldDemo(); - AbstractApplicationContext applicationContext = new ClassPathXmlApplicationContext("helloWorldDemo.xml", HelloWorldDemo.class); - demo.performDemo(applicationContext); - applicationContext.stop(); - } - - - public void performDemo(ApplicationContext applicationContext) { - ChannelResolver channelResolver = new BeanFactoryChannelResolver(applicationContext); - MessageChannel inputChannel = channelResolver.resolveChannelName("inputChannel"); - PollableChannel outputChannel = (PollableChannel) channelResolver.resolveChannelName("outputChannel"); + AbstractApplicationContext context = new ClassPathXmlApplicationContext("helloWorldDemo.xml", HelloWorldDemo.class); + MessageChannel inputChannel = context.getBean("inputChannel", MessageChannel.class); + PollableChannel outputChannel = context.getBean("outputChannel", PollableChannel.class); inputChannel.send(new StringMessage("World")); - System.out.println("==> HelloWorldDemo: " + outputChannel.receive(0).getPayload()); + System.out.println("==> HelloWorldDemo: " + outputChannel.receive(0).getPayload()); } }