From fc16b90f9423352292d56a6efb9782140ec88264 Mon Sep 17 00:00:00 2001 From: Mark Fisher Date: Tue, 18 Dec 2007 16:37:06 +0000 Subject: [PATCH] Added hello world sample. --- .../samples/helloworld/HelloService.java | 28 ++++++++++++ .../samples/helloworld/HelloWorldDemo.java | 43 +++++++++++++++++++ .../samples/helloworld/helloWorldDemo.xml | 19 ++++++++ 3 files changed, 90 insertions(+) create mode 100644 spring-integration-samples/src/main/java/org/springframework/integration/samples/helloworld/HelloService.java create mode 100644 spring-integration-samples/src/main/java/org/springframework/integration/samples/helloworld/HelloWorldDemo.java create mode 100644 spring-integration-samples/src/main/java/org/springframework/integration/samples/helloworld/helloWorldDemo.xml diff --git a/spring-integration-samples/src/main/java/org/springframework/integration/samples/helloworld/HelloService.java b/spring-integration-samples/src/main/java/org/springframework/integration/samples/helloworld/HelloService.java new file mode 100644 index 0000000000..445fa7b55c --- /dev/null +++ b/spring-integration-samples/src/main/java/org/springframework/integration/samples/helloworld/HelloService.java @@ -0,0 +1,28 @@ +/* + * Copyright 2002-2007 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.integration.samples.helloworld; + +/** + * @author Mark Fisher + */ +public class HelloService { + + public String sayHello(String name) { + return "Hello " + name; + } + +} diff --git a/spring-integration-samples/src/main/java/org/springframework/integration/samples/helloworld/HelloWorldDemo.java b/spring-integration-samples/src/main/java/org/springframework/integration/samples/helloworld/HelloWorldDemo.java new file mode 100644 index 0000000000..2615161ef9 --- /dev/null +++ b/spring-integration-samples/src/main/java/org/springframework/integration/samples/helloworld/HelloWorldDemo.java @@ -0,0 +1,43 @@ +/* + * Copyright 2002-2007 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.integration.samples.helloworld; + +import org.springframework.context.support.AbstractApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; +import org.springframework.integration.channel.ChannelRegistry; +import org.springframework.integration.channel.MessageChannel; +import org.springframework.integration.config.MessageBusParser; +import org.springframework.integration.message.StringMessage; + +/** + * Demonstrates a basic message endpoint. + * + * @author Mark Fisher + */ +public class HelloWorldDemo { + + public static void main(String[] args) { + AbstractApplicationContext context = new ClassPathXmlApplicationContext("helloWorldDemo.xml", HelloWorldDemo.class); + context.start(); + ChannelRegistry channelRegistry = (ChannelRegistry) context.getBean(MessageBusParser.MESSAGE_BUS_BEAN_NAME); + MessageChannel inputChannel = channelRegistry.lookupChannel("inputChannel"); + MessageChannel outputChannel = channelRegistry.lookupChannel("outputChannel"); + inputChannel.send(new StringMessage(1, "World")); + System.out.println(outputChannel.receive().getPayload()); + } + +} diff --git a/spring-integration-samples/src/main/java/org/springframework/integration/samples/helloworld/helloWorldDemo.xml b/spring-integration-samples/src/main/java/org/springframework/integration/samples/helloworld/helloWorldDemo.xml new file mode 100644 index 0000000000..31ab8da15e --- /dev/null +++ b/spring-integration-samples/src/main/java/org/springframework/integration/samples/helloworld/helloWorldDemo.xml @@ -0,0 +1,19 @@ + + + + + + + + + +