From 43b85119c82fbcb1805fc17d389ffda1c60ba2ca Mon Sep 17 00:00:00 2001 From: Gunnar Hillert Date: Fri, 10 Feb 2012 12:02:55 -0500 Subject: [PATCH 1/3] INTSAMPLES-54 - Update README.md * Update README.md to reflect correct classes * Add documentation for Delayer application * Add JavaDoc for delayer application * Delete redundant *src/main/resources/log4j.properties* * Add logger name to *Logging Channel Adapter* configuration * Add Maven Exec Maven Plugin for easy execution from the command line --- basic/helloworld/README.md | 35 +++++++++++++++++-- basic/helloworld/pom.xml | 25 +++++++++++++ .../samples/helloworld/DelayerApp.java | 10 ++++-- .../META-INF/spring/integration/delay.xml | 6 ++-- .../src/main/resources/log4j.properties | 9 ----- basic/helloworld/src/main/resources/log4j.xml | 2 +- 6 files changed, 69 insertions(+), 18 deletions(-) delete mode 100644 basic/helloworld/src/main/resources/log4j.properties diff --git a/basic/helloworld/README.md b/basic/helloworld/README.md index e8f3b687..6b3c2216 100644 --- a/basic/helloworld/README.md +++ b/basic/helloworld/README.md @@ -1,8 +1,37 @@ Hello World Sample ================== -This is an obvious place to get started. It demonstrates a simple message flow represented by the diagram below: +This is an obvious place to get started. This sample project contains 2 basic sample applications: - Message -> Channel -> ServiceActivator -> QueueChannel +* Hello World +* Delayer Application + +## Hello World + +The Hello World application demonstrates a simple message flow represented by the diagram below: + + Message -> Channel -> ServiceActivator -> QueueChannel + +To run the sample simply execute **HelloWorldApp** in package **org.springframework.integration.samples.helloworld**. You can also execute that class using the [Exec Maven Plugin](http://mojo.codehaus.org/exec-maven-plugin/): + + $ mvn clean package exec:java -P hello + +You should see the following output: + + INFO : org.springframework.integration.samples.helloworld.HelloWorldApp - ==> HelloWorldDemo: Hello World + +## Delayer Application + +This simple application will print out the current system time twice every 20 seconds. + +More specifically, an **Inbound Channel Adapter** polls for the current system time 2 times every 20 seconds (20000 milliseconds). The resulting message contains as payload the time in milliseconds and the message is sent to a **Logging Channel Adapter**, which will print the time to the command prompt. + +To run the sample simply execute **DelayerApp** in package **org.springframework.integration.samples.helloworld**. You can also execute that class using the [Exec Maven Plugin](http://mojo.codehaus.org/exec-maven-plugin/): + + $ mvn clean package exec:java -P delayer + +You should see output like the following: + + INFO : org.springframework.integration.samples.helloworld - 1328892135471 + INFO : org.springframework.integration.samples.helloworld - 1328892135524 -To run sample simply execute a test case in the **org.springframework.integration.samples.helloworld** package. \ No newline at end of file diff --git a/basic/helloworld/pom.xml b/basic/helloworld/pom.xml index 4f50472d..b6fb6eda 100644 --- a/basic/helloworld/pom.xml +++ b/basic/helloworld/pom.xml @@ -12,7 +12,24 @@ 2.1.0.RELEASE 1.2.16 4.10 + org.springframework.integration.samples.helloworld.HelloWorldApp + + + + hello + + org.springframework.integration.samples.helloworld.HelloWorldApp + + + + delayer + + org.springframework.integration.samples.helloworld.DelayerApp + + + + org.springframework.integration @@ -45,6 +62,14 @@ false + + org.codehaus.mojo + exec-maven-plugin + 1.2 + + ${java.main.class} + + diff --git a/basic/helloworld/src/main/java/org/springframework/integration/samples/helloworld/DelayerApp.java b/basic/helloworld/src/main/java/org/springframework/integration/samples/helloworld/DelayerApp.java index 804466eb..3182582f 100644 --- a/basic/helloworld/src/main/java/org/springframework/integration/samples/helloworld/DelayerApp.java +++ b/basic/helloworld/src/main/java/org/springframework/integration/samples/helloworld/DelayerApp.java @@ -5,11 +5,17 @@ import org.springframework.context.support.ClassPathXmlApplicationContext; public class DelayerApp { /** - * @param args + * Simple application that polls the current system time 2 times every + * 20 seconds (20000 milliseconds). + * + * The resulting message contains the time in milliseconds and the message + * is routed to a Logging Channel Adapter which will print the time to the + * command prompt. + * + * @param args Not used. */ public static void main(String[] args) throws Exception{ new ClassPathXmlApplicationContext("META-INF/spring/integration/delay.xml"); - System.in.read(); } } diff --git a/basic/helloworld/src/main/resources/META-INF/spring/integration/delay.xml b/basic/helloworld/src/main/resources/META-INF/spring/integration/delay.xml index 7345602b..2e650f8e 100644 --- a/basic/helloworld/src/main/resources/META-INF/spring/integration/delay.xml +++ b/basic/helloworld/src/main/resources/META-INF/spring/integration/delay.xml @@ -11,8 +11,8 @@ - - - + + + diff --git a/basic/helloworld/src/main/resources/log4j.properties b/basic/helloworld/src/main/resources/log4j.properties deleted file mode 100644 index eb601e8e..00000000 --- a/basic/helloworld/src/main/resources/log4j.properties +++ /dev/null @@ -1,9 +0,0 @@ -log4j.rootCategory=WARN, stdout - -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %t %c{2}:%L - %m%n - -#log4j.category.org.springframework=WARN -#log4j.category.org.springframework.integration.sftp=TRACE -log4j.category.org.springframework=TRACE diff --git a/basic/helloworld/src/main/resources/log4j.xml b/basic/helloworld/src/main/resources/log4j.xml index f391e2ed..678b69b3 100644 --- a/basic/helloworld/src/main/resources/log4j.xml +++ b/basic/helloworld/src/main/resources/log4j.xml @@ -24,5 +24,5 @@ - + \ No newline at end of file From 8ba0c2b58c94d740cf4a11496c4803379e004e3e Mon Sep 17 00:00:00 2001 From: Gunnar Hillert Date: Mon, 13 Feb 2012 09:43:28 -0500 Subject: [PATCH 2/3] INTSAMPLES-54 - Code Review: Rename DelayerApp to PollerApp --- basic/helloworld/README.md | 8 ++++---- basic/helloworld/pom.xml | 4 ++-- .../helloworld/{DelayerApp.java => PollerApp.java} | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) rename basic/helloworld/src/main/java/org/springframework/integration/samples/helloworld/{DelayerApp.java => PollerApp.java} (95%) diff --git a/basic/helloworld/README.md b/basic/helloworld/README.md index 6b3c2216..a7be3b2c 100644 --- a/basic/helloworld/README.md +++ b/basic/helloworld/README.md @@ -4,7 +4,7 @@ Hello World Sample This is an obvious place to get started. This sample project contains 2 basic sample applications: * Hello World -* Delayer Application +* Poller Application ## Hello World @@ -20,15 +20,15 @@ You should see the following output: INFO : org.springframework.integration.samples.helloworld.HelloWorldApp - ==> HelloWorldDemo: Hello World -## Delayer Application +## Poller Application This simple application will print out the current system time twice every 20 seconds. More specifically, an **Inbound Channel Adapter** polls for the current system time 2 times every 20 seconds (20000 milliseconds). The resulting message contains as payload the time in milliseconds and the message is sent to a **Logging Channel Adapter**, which will print the time to the command prompt. -To run the sample simply execute **DelayerApp** in package **org.springframework.integration.samples.helloworld**. You can also execute that class using the [Exec Maven Plugin](http://mojo.codehaus.org/exec-maven-plugin/): +To run the sample simply execute **PollerApp** in package **org.springframework.integration.samples.helloworld**. You can also execute that class using the [Exec Maven Plugin](http://mojo.codehaus.org/exec-maven-plugin/): - $ mvn clean package exec:java -P delayer + $ mvn clean package exec:java -P poller You should see output like the following: diff --git a/basic/helloworld/pom.xml b/basic/helloworld/pom.xml index b6fb6eda..a96e401d 100644 --- a/basic/helloworld/pom.xml +++ b/basic/helloworld/pom.xml @@ -23,9 +23,9 @@ - delayer + poller - org.springframework.integration.samples.helloworld.DelayerApp + org.springframework.integration.samples.helloworld.PollerApp diff --git a/basic/helloworld/src/main/java/org/springframework/integration/samples/helloworld/DelayerApp.java b/basic/helloworld/src/main/java/org/springframework/integration/samples/helloworld/PollerApp.java similarity index 95% rename from basic/helloworld/src/main/java/org/springframework/integration/samples/helloworld/DelayerApp.java rename to basic/helloworld/src/main/java/org/springframework/integration/samples/helloworld/PollerApp.java index 3182582f..b173b22b 100644 --- a/basic/helloworld/src/main/java/org/springframework/integration/samples/helloworld/DelayerApp.java +++ b/basic/helloworld/src/main/java/org/springframework/integration/samples/helloworld/PollerApp.java @@ -2,7 +2,7 @@ package org.springframework.integration.samples.helloworld; import org.springframework.context.support.ClassPathXmlApplicationContext; -public class DelayerApp { +public class PollerApp { /** * Simple application that polls the current system time 2 times every From b1aecbd91010857e2bd2b7e4af49de49b61f09fb Mon Sep 17 00:00:00 2001 From: Gunnar Hillert Date: Mon, 13 Feb 2012 09:46:20 -0500 Subject: [PATCH 3/3] INTSAMPLES-54 - Add missing Copyright notice --- .../samples/helloworld/HelloService.java | 4 ++-- .../samples/helloworld/HelloWorldApp.java | 8 ++++---- .../integration/samples/helloworld/PollerApp.java | 15 +++++++++++++++ 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/basic/helloworld/src/main/java/org/springframework/integration/samples/helloworld/HelloService.java b/basic/helloworld/src/main/java/org/springframework/integration/samples/helloworld/HelloService.java index a8f76a8c..a1c6e202 100644 --- a/basic/helloworld/src/main/java/org/springframework/integration/samples/helloworld/HelloService.java +++ b/basic/helloworld/src/main/java/org/springframework/integration/samples/helloworld/HelloService.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 the original author or authors. + * Copyright 2002-2012 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. @@ -18,7 +18,7 @@ package org.springframework.integration.samples.helloworld; /** * Simple POJO to be referenced from a Service Activator. - * + * * @author Mark Fisher */ public class HelloService { diff --git a/basic/helloworld/src/main/java/org/springframework/integration/samples/helloworld/HelloWorldApp.java b/basic/helloworld/src/main/java/org/springframework/integration/samples/helloworld/HelloWorldApp.java index b4b47a4e..ce6f876c 100644 --- a/basic/helloworld/src/main/java/org/springframework/integration/samples/helloworld/HelloWorldApp.java +++ b/basic/helloworld/src/main/java/org/springframework/integration/samples/helloworld/HelloWorldApp.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 the original author or authors. + * Copyright 2002-2012 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. @@ -33,20 +33,20 @@ import org.springframework.integration.message.GenericMessage; *

* View the configuration of the channels and the endpoint (a <service-activator/> * element) in 'helloWorldDemo.xml' within this same package. - * + * * @author Mark Fisher * @author Oleg Zhurakousky */ public class HelloWorldApp { private static Logger logger = Logger.getLogger(HelloWorldApp.class); - + public static void main(String[] args) { AbstractApplicationContext context = new ClassPathXmlApplicationContext("/META-INF/spring/integration/helloWorldDemo.xml", HelloWorldApp.class); MessageChannel inputChannel = context.getBean("inputChannel", MessageChannel.class); PollableChannel outputChannel = context.getBean("outputChannel", PollableChannel.class); inputChannel.send(new GenericMessage("World")); - logger.info("==> HelloWorldDemo: " + outputChannel.receive(0).getPayload()); + logger.info("==> HelloWorldDemo: " + outputChannel.receive(0).getPayload()); } } diff --git a/basic/helloworld/src/main/java/org/springframework/integration/samples/helloworld/PollerApp.java b/basic/helloworld/src/main/java/org/springframework/integration/samples/helloworld/PollerApp.java index b173b22b..f9a38206 100644 --- a/basic/helloworld/src/main/java/org/springframework/integration/samples/helloworld/PollerApp.java +++ b/basic/helloworld/src/main/java/org/springframework/integration/samples/helloworld/PollerApp.java @@ -1,3 +1,18 @@ +/* + * Copyright 2002-2012 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.ClassPathXmlApplicationContext;