From d5ec7a566487aa82bb7861a37faa50a4c191c2dd Mon Sep 17 00:00:00 2001 From: Mark Fisher Date: Fri, 5 Sep 2008 03:05:58 +0000 Subject: [PATCH] Merging the interval and cron-based Odd-Even samples into the same package. --- ...{OddEvenDemo.java => CronOddEvenDemo.java} | 4 +-- .../samples/oddeven/EvenLogger.java | 8 +++-- .../IntervalOddEvenDemo.java} | 6 ++-- .../samples/oddeven/OddLogger.java | 8 +++-- .../cronOddEvenDemo.xml} | 6 ++-- ...ddEvenDemo.xml => intervalOddEvenDemo.xml} | 0 .../samples/quartzoddeven/Counter.java | 32 ------------------- .../samples/quartzoddeven/ParityResolver.java | 31 ------------------ 8 files changed, 20 insertions(+), 75 deletions(-) rename org.springframework.integration.samples/src/main/java/org/springframework/integration/samples/oddeven/{OddEvenDemo.java => CronOddEvenDemo.java} (87%) rename org.springframework.integration.samples/src/main/java/org/springframework/integration/samples/{quartzoddeven/OddEvenDemo.java => oddeven/IntervalOddEvenDemo.java} (80%) rename org.springframework.integration.samples/src/main/java/org/springframework/integration/samples/{quartzoddeven/oddEvenDemo.xml => oddeven/cronOddEvenDemo.xml} (91%) rename org.springframework.integration.samples/src/main/java/org/springframework/integration/samples/oddeven/{oddEvenDemo.xml => intervalOddEvenDemo.xml} (100%) delete mode 100644 org.springframework.integration.samples/src/main/java/org/springframework/integration/samples/quartzoddeven/Counter.java delete mode 100644 org.springframework.integration.samples/src/main/java/org/springframework/integration/samples/quartzoddeven/ParityResolver.java diff --git a/org.springframework.integration.samples/src/main/java/org/springframework/integration/samples/oddeven/OddEvenDemo.java b/org.springframework.integration.samples/src/main/java/org/springframework/integration/samples/oddeven/CronOddEvenDemo.java similarity index 87% rename from org.springframework.integration.samples/src/main/java/org/springframework/integration/samples/oddeven/OddEvenDemo.java rename to org.springframework.integration.samples/src/main/java/org/springframework/integration/samples/oddeven/CronOddEvenDemo.java index ed2bbcd691..9110dcf8c6 100644 --- a/org.springframework.integration.samples/src/main/java/org/springframework/integration/samples/oddeven/OddEvenDemo.java +++ b/org.springframework.integration.samples/src/main/java/org/springframework/integration/samples/oddeven/CronOddEvenDemo.java @@ -21,10 +21,10 @@ import org.springframework.context.support.ClassPathXmlApplicationContext; /** * @author Mark Fisher */ -public class OddEvenDemo { +public class CronOddEvenDemo { public static void main(String[] args) { - new ClassPathXmlApplicationContext("oddEvenDemo.xml", OddEvenDemo.class); + new ClassPathXmlApplicationContext("cronOddEvenDemo.xml", CronOddEvenDemo.class); } } diff --git a/org.springframework.integration.samples/src/main/java/org/springframework/integration/samples/oddeven/EvenLogger.java b/org.springframework.integration.samples/src/main/java/org/springframework/integration/samples/oddeven/EvenLogger.java index 8eec31d7d5..41840b16e4 100644 --- a/org.springframework.integration.samples/src/main/java/org/springframework/integration/samples/oddeven/EvenLogger.java +++ b/org.springframework.integration.samples/src/main/java/org/springframework/integration/samples/oddeven/EvenLogger.java @@ -16,18 +16,22 @@ package org.springframework.integration.samples.oddeven; +import java.text.SimpleDateFormat; +import java.util.Date; + import org.springframework.integration.annotation.MessageEndpoint; import org.springframework.integration.annotation.ServiceActivator; /** * @author Mark Fisher + * @author Marius Bogoevici */ @MessageEndpoint public class EvenLogger { - + @ServiceActivator public void log(int i) { - System.out.println("even: " + i); + System.out.println("even: " + i + " at " + new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(new Date())); } } diff --git a/org.springframework.integration.samples/src/main/java/org/springframework/integration/samples/quartzoddeven/OddEvenDemo.java b/org.springframework.integration.samples/src/main/java/org/springframework/integration/samples/oddeven/IntervalOddEvenDemo.java similarity index 80% rename from org.springframework.integration.samples/src/main/java/org/springframework/integration/samples/quartzoddeven/OddEvenDemo.java rename to org.springframework.integration.samples/src/main/java/org/springframework/integration/samples/oddeven/IntervalOddEvenDemo.java index 9afa9c662a..5456ec1960 100644 --- a/org.springframework.integration.samples/src/main/java/org/springframework/integration/samples/quartzoddeven/OddEvenDemo.java +++ b/org.springframework.integration.samples/src/main/java/org/springframework/integration/samples/oddeven/IntervalOddEvenDemo.java @@ -14,17 +14,17 @@ * limitations under the License. */ -package org.springframework.integration.samples.quartzoddeven; +package org.springframework.integration.samples.oddeven; import org.springframework.context.support.ClassPathXmlApplicationContext; /** * @author Mark Fisher */ -public class OddEvenDemo { +public class IntervalOddEvenDemo { public static void main(String[] args) { - new ClassPathXmlApplicationContext("oddEvenDemo.xml", OddEvenDemo.class); + new ClassPathXmlApplicationContext("intervalOddEvenDemo.xml", IntervalOddEvenDemo.class); } } diff --git a/org.springframework.integration.samples/src/main/java/org/springframework/integration/samples/oddeven/OddLogger.java b/org.springframework.integration.samples/src/main/java/org/springframework/integration/samples/oddeven/OddLogger.java index ef30580536..7b6c2e6b3a 100644 --- a/org.springframework.integration.samples/src/main/java/org/springframework/integration/samples/oddeven/OddLogger.java +++ b/org.springframework.integration.samples/src/main/java/org/springframework/integration/samples/oddeven/OddLogger.java @@ -16,18 +16,22 @@ package org.springframework.integration.samples.oddeven; +import java.text.SimpleDateFormat; +import java.util.Date; + import org.springframework.integration.annotation.MessageEndpoint; import org.springframework.integration.annotation.ServiceActivator; /** * @author Mark Fisher + * @author Marius Bogoevici */ @MessageEndpoint public class OddLogger { @ServiceActivator public void log(int i) { - System.out.println("odd: " + i); + System.out.println("odd: " + i + " at " + new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(new Date())); } -} +} \ No newline at end of file diff --git a/org.springframework.integration.samples/src/main/java/org/springframework/integration/samples/quartzoddeven/oddEvenDemo.xml b/org.springframework.integration.samples/src/main/java/org/springframework/integration/samples/oddeven/cronOddEvenDemo.xml similarity index 91% rename from org.springframework.integration.samples/src/main/java/org/springframework/integration/samples/quartzoddeven/oddEvenDemo.xml rename to org.springframework.integration.samples/src/main/java/org/springframework/integration/samples/oddeven/cronOddEvenDemo.xml index f05318223e..1f1c2405da 100644 --- a/org.springframework.integration.samples/src/main/java/org/springframework/integration/samples/quartzoddeven/oddEvenDemo.xml +++ b/org.springframework.integration.samples/src/main/java/org/springframework/integration/samples/oddeven/cronOddEvenDemo.xml @@ -25,16 +25,16 @@ - + - + - + diff --git a/org.springframework.integration.samples/src/main/java/org/springframework/integration/samples/oddeven/oddEvenDemo.xml b/org.springframework.integration.samples/src/main/java/org/springframework/integration/samples/oddeven/intervalOddEvenDemo.xml similarity index 100% rename from org.springframework.integration.samples/src/main/java/org/springframework/integration/samples/oddeven/oddEvenDemo.xml rename to org.springframework.integration.samples/src/main/java/org/springframework/integration/samples/oddeven/intervalOddEvenDemo.xml diff --git a/org.springframework.integration.samples/src/main/java/org/springframework/integration/samples/quartzoddeven/Counter.java b/org.springframework.integration.samples/src/main/java/org/springframework/integration/samples/quartzoddeven/Counter.java deleted file mode 100644 index 28afc81d5c..0000000000 --- a/org.springframework.integration.samples/src/main/java/org/springframework/integration/samples/quartzoddeven/Counter.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2002-2008 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.quartzoddeven; - -import java.util.concurrent.atomic.AtomicInteger; - -/** - * @author Mark Fisher - */ -public class Counter { - - private final AtomicInteger count = new AtomicInteger(); - - public int next() { - return count.incrementAndGet(); - } - -} diff --git a/org.springframework.integration.samples/src/main/java/org/springframework/integration/samples/quartzoddeven/ParityResolver.java b/org.springframework.integration.samples/src/main/java/org/springframework/integration/samples/quartzoddeven/ParityResolver.java deleted file mode 100644 index 3bb46e6892..0000000000 --- a/org.springframework.integration.samples/src/main/java/org/springframework/integration/samples/quartzoddeven/ParityResolver.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2002-2008 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.quartzoddeven; - -/** - * @author Mark Fisher - */ -public class ParityResolver { - - public String getParity(int i) { - if (i % 2 == 0) { - return "even"; - } - return "odd"; - } - -}