diff --git a/getting-started/jmx/readme.txt b/getting-started/jmx/readme.txt new file mode 100644 index 00000000..c6ede142 --- /dev/null +++ b/getting-started/jmx/readme.txt @@ -0,0 +1,34 @@ +This example demonstrates the following aspects of the JMX support available with Spring Integration: +1. JMX Attribute Polling Channel +2. JMX Operation Invoking Channel Adapter + +StopWatch is a Managed Bean. It is bootstraped and deployed using annotation support (@Component, @ManagedResource) +and component scanning functionality provided by Spring JMX. Internally StopWatch simply runs a task that increments the +value of its 'seconds' attribute by 1 every second. + +JMX Attribute Polling Channel Adapter simply polls a managed attribute 'Seconds' of the StopWatch MBean identified by the 'org.springframework.integration.samples.jmx:type=StopWatch,name=stopWatch' name and sends its value to a 'seconds' channel. +The interesting this is that 'seconds' channel is a publish-subscribe-channel and has two subscribers; +- Stdout Channel Adapter which prints the value of the polled attribute to the console; +- Filter which essentially waits till payload value is 10; +Once the payload value is 10 filter sends the Message to a 'reset' channel which is represented as JMX Operation Invoking Channel Adapter +which simply invokes 'reset' operation on the same StopWatch MBean resetting 'Seconds' attribute value back to 1 and the process repeats. + + +To run samples simply execute the 3 test cases located in the org.springframework.integration.samples.filecopy package + +You will see the output similar to this which will loop for ~ 20 sec: +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +1 +2 +3 +. . . + diff --git a/getting-started/oddeven/.classpath b/getting-started/oddeven/.classpath index 24166ba5..dde3100b 100644 --- a/getting-started/oddeven/.classpath +++ b/getting-started/oddeven/.classpath @@ -1,6 +1,9 @@ + + + diff --git a/getting-started/oddeven/.gitignore b/getting-started/oddeven/.gitignore new file mode 100644 index 00000000..ea8c4bf7 --- /dev/null +++ b/getting-started/oddeven/.gitignore @@ -0,0 +1 @@ +/target diff --git a/getting-started/oddeven/.settings/com.springsource.sts.config.flow.prefs b/getting-started/oddeven/.settings/com.springsource.sts.config.flow.prefs new file mode 100644 index 00000000..1695b7f1 --- /dev/null +++ b/getting-started/oddeven/.settings/com.springsource.sts.config.flow.prefs @@ -0,0 +1,3 @@ +#Thu Sep 16 17:55:53 EDT 2010 +//com.springsource.sts.config.flow.coordinates\:http\://www.springframework.org/schema/integration\:/oddeven/src/main/resources/META-INF/spring/integration/intervalOddEvenDemo.xml=\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n +eclipse.preferences.version=1 diff --git a/getting-started/oddeven/pom.xml b/getting-started/oddeven/pom.xml index 5f7d4730..a9524409 100644 --- a/getting-started/oddeven/pom.xml +++ b/getting-started/oddeven/pom.xml @@ -2,34 +2,47 @@ 4.0.0 - - org.springframework.integration.samples - spring-integration-samples - 2.0.0.BUILD-SNAPSHOT - + org.springframework.integration.samples oddeven Spring Integration Odd-Even Sample + 2.0.0 + jar + + 2.0.0.M7 + 1.2.15 + 4.7 + org.springframework.integration spring-integration-core + ${spring.integration.version} + + + log4j + log4j + ${log4j.version} + + + + junit + junit + ${junit.version} - - - repository.springframework.maven.release - Spring Framework Maven Release Repository - http://maven.springframework.org/release - - - repository.springframework.maven.milestone - Spring Framework Maven Milestone Repository - http://maven.springframework.org/milestone - - - repository.springframework.maven.snapshot - Spring Framework Maven Snapshot Repository - http://maven.springframework.org/snapshot - - + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.5 + 1.5 + -Xlint:all + true + false + + + + diff --git a/getting-started/oddeven/readme.txt b/getting-started/oddeven/readme.txt index 775f38d0..4e704e30 100644 --- a/getting-started/oddeven/readme.txt +++ b/getting-started/oddeven/readme.txt @@ -1 +1,20 @@ -Demonstrates Inbound channel adapter and Poller configuration with Cron and Interval triggers \ No newline at end of file +This example demonstrates the following aspects of the CORE EIP support available with Spring Integration: +1. Inbound Channel Adapter +2. Filter +3. Router (SpEL based) +4. Poller with Cron and Interval Trigers + +Messages are simply being emitted by the Poller (interval based or cron) triggering 'next()' method of Counter class and +sent to a 'numbers' channel - Inbound Channel Adapter. From the 'numbers' channel Messages are sent +to an expression-based router (Spring Expression Language). ALl that router does is simply routing messages +to OddLogger and EvenLogger service + +To execute the Interval-based sample simply run IntervalOddEvenDemoTest class and for Cron-based sample simply +run CronOddEvenDemo class, You should see the output similar to this: + +INFO : org.springframework.integration.samples.oddeven.OddLogger - odd: 1 at 2010-09-16 05:55:46 +INFO : org.springframework.integration.samples.oddeven.EvenLogger - even: 2 at 2010-09-16 05:55:49 +INFO : org.springframework.integration.samples.oddeven.OddLogger - odd: 3 at 2010-09-16 05:55:52 +INFO : org.springframework.integration.samples.oddeven.EvenLogger - even: 4 at 2010-09-16 05:55:55 + + diff --git a/getting-started/oddeven/src/main/java/org/springframework/integration/samples/oddeven/EvenLogger.java b/getting-started/oddeven/src/main/java/org/springframework/integration/samples/oddeven/EvenLogger.java index 7f3f1e55..ac4937b0 100644 --- a/getting-started/oddeven/src/main/java/org/springframework/integration/samples/oddeven/EvenLogger.java +++ b/getting-started/oddeven/src/main/java/org/springframework/integration/samples/oddeven/EvenLogger.java @@ -19,6 +19,7 @@ package org.springframework.integration.samples.oddeven; import java.text.SimpleDateFormat; import java.util.Date; +import org.apache.log4j.Logger; import org.springframework.integration.annotation.MessageEndpoint; import org.springframework.integration.annotation.ServiceActivator; @@ -30,10 +31,11 @@ import org.springframework.integration.annotation.ServiceActivator; */ @MessageEndpoint public class EvenLogger { + private static Logger logger = Logger.getLogger(EvenLogger.class); @ServiceActivator public void log(int i) { - System.out.println("even: " + i + " at " + new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(new Date())); + logger.info("even: " + i + " at " + new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(new Date())); } } diff --git a/getting-started/oddeven/src/main/java/org/springframework/integration/samples/oddeven/OddLogger.java b/getting-started/oddeven/src/main/java/org/springframework/integration/samples/oddeven/OddLogger.java index 2e2dbb0c..cd237a8d 100644 --- a/getting-started/oddeven/src/main/java/org/springframework/integration/samples/oddeven/OddLogger.java +++ b/getting-started/oddeven/src/main/java/org/springframework/integration/samples/oddeven/OddLogger.java @@ -19,6 +19,7 @@ package org.springframework.integration.samples.oddeven; import java.text.SimpleDateFormat; import java.util.Date; +import org.apache.log4j.Logger; import org.springframework.integration.annotation.MessageEndpoint; import org.springframework.integration.annotation.ServiceActivator; @@ -30,10 +31,11 @@ import org.springframework.integration.annotation.ServiceActivator; */ @MessageEndpoint public class OddLogger { + private static Logger logger = Logger.getLogger(OddLogger.class); @ServiceActivator public void log(int i) { - System.out.println("odd: " + i + " at " + new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(new Date())); + logger.info("odd: " + i + " at " + new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(new Date())); } } \ No newline at end of file diff --git a/getting-started/oddeven/src/main/java/org/springframework/integration/samples/oddeven/intervalOddEvenDemo.xml b/getting-started/oddeven/src/main/java/org/springframework/integration/samples/oddeven/intervalOddEvenDemo.xml deleted file mode 100644 index a155d205..00000000 --- a/getting-started/oddeven/src/main/java/org/springframework/integration/samples/oddeven/intervalOddEvenDemo.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/getting-started/oddeven/src/main/java/org/springframework/integration/samples/oddeven/cronOddEvenDemo.xml b/getting-started/oddeven/src/main/resources/META-INF/spring/integration/cronOddEvenDemo.xml similarity index 100% rename from getting-started/oddeven/src/main/java/org/springframework/integration/samples/oddeven/cronOddEvenDemo.xml rename to getting-started/oddeven/src/main/resources/META-INF/spring/integration/cronOddEvenDemo.xml diff --git a/getting-started/oddeven/target/classes/org/springframework/integration/samples/oddeven/intervalOddEvenDemo.xml b/getting-started/oddeven/src/main/resources/META-INF/spring/integration/intervalOddEvenDemo.xml similarity index 84% rename from getting-started/oddeven/target/classes/org/springframework/integration/samples/oddeven/intervalOddEvenDemo.xml rename to getting-started/oddeven/src/main/resources/META-INF/spring/integration/intervalOddEvenDemo.xml index a155d205..200e4a8c 100644 --- a/getting-started/oddeven/target/classes/org/springframework/integration/samples/oddeven/intervalOddEvenDemo.xml +++ b/getting-started/oddeven/src/main/resources/META-INF/spring/integration/intervalOddEvenDemo.xml @@ -16,11 +16,7 @@ - - - + diff --git a/getting-started/oddeven/src/main/java/org/springframework/integration/samples/oddeven/CronOddEvenDemo.java b/getting-started/oddeven/src/test/java/org/springframework/integration/samples/oddeven/CronOddEvenDemo.java similarity index 93% rename from getting-started/oddeven/src/main/java/org/springframework/integration/samples/oddeven/CronOddEvenDemo.java rename to getting-started/oddeven/src/test/java/org/springframework/integration/samples/oddeven/CronOddEvenDemo.java index 5dfc387d..e540e956 100644 --- a/getting-started/oddeven/src/main/java/org/springframework/integration/samples/oddeven/CronOddEvenDemo.java +++ b/getting-started/oddeven/src/test/java/org/springframework/integration/samples/oddeven/CronOddEvenDemo.java @@ -35,7 +35,7 @@ import org.springframework.context.support.ClassPathXmlApplicationContext; public class CronOddEvenDemo { public static void main(String[] args) { - new ClassPathXmlApplicationContext("cronOddEvenDemo.xml", CronOddEvenDemo.class); + new ClassPathXmlApplicationContext("/META-INF/spring/integration/cronOddEvenDemo.xml", CronOddEvenDemo.class); } } diff --git a/getting-started/oddeven/src/main/java/org/springframework/integration/samples/oddeven/IntervalOddEvenDemo.java b/getting-started/oddeven/src/test/java/org/springframework/integration/samples/oddeven/IntervalOddEvenDemoTest.java similarity index 89% rename from getting-started/oddeven/src/main/java/org/springframework/integration/samples/oddeven/IntervalOddEvenDemo.java rename to getting-started/oddeven/src/test/java/org/springframework/integration/samples/oddeven/IntervalOddEvenDemoTest.java index fcf31073..b3ca538a 100644 --- a/getting-started/oddeven/src/main/java/org/springframework/integration/samples/oddeven/IntervalOddEvenDemo.java +++ b/getting-started/oddeven/src/test/java/org/springframework/integration/samples/oddeven/IntervalOddEvenDemoTest.java @@ -31,10 +31,10 @@ import org.springframework.context.support.ClassPathXmlApplicationContext; * * @author Mark Fisher */ -public class IntervalOddEvenDemo { +public class IntervalOddEvenDemoTest { public static void main(String[] args) { - new ClassPathXmlApplicationContext("intervalOddEvenDemo.xml", IntervalOddEvenDemo.class); + new ClassPathXmlApplicationContext("/META-INF/spring/integration/intervalOddEvenDemo.xml", IntervalOddEvenDemoTest.class); } } diff --git a/getting-started/oddeven/src/main/java/log4j.xml b/getting-started/oddeven/src/test/resources/log4j.xml similarity index 90% rename from getting-started/oddeven/src/main/java/log4j.xml rename to getting-started/oddeven/src/test/resources/log4j.xml index 78268c06..fd722913 100644 --- a/getting-started/oddeven/src/main/java/log4j.xml +++ b/getting-started/oddeven/src/test/resources/log4j.xml @@ -15,8 +15,8 @@ - - + + diff --git a/getting-started/oddeven/target/classes/log4j.xml b/getting-started/oddeven/target/classes/log4j.xml deleted file mode 100644 index 78268c06..00000000 --- a/getting-started/oddeven/target/classes/log4j.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/getting-started/oddeven/target/classes/org/springframework/integration/samples/oddeven/Counter.class b/getting-started/oddeven/target/classes/org/springframework/integration/samples/oddeven/Counter.class deleted file mode 100644 index 74759816..00000000 Binary files a/getting-started/oddeven/target/classes/org/springframework/integration/samples/oddeven/Counter.class and /dev/null differ diff --git a/getting-started/oddeven/target/classes/org/springframework/integration/samples/oddeven/CronOddEvenDemo.class b/getting-started/oddeven/target/classes/org/springframework/integration/samples/oddeven/CronOddEvenDemo.class deleted file mode 100644 index 6df63ccb..00000000 Binary files a/getting-started/oddeven/target/classes/org/springframework/integration/samples/oddeven/CronOddEvenDemo.class and /dev/null differ diff --git a/getting-started/oddeven/target/classes/org/springframework/integration/samples/oddeven/EvenLogger.class b/getting-started/oddeven/target/classes/org/springframework/integration/samples/oddeven/EvenLogger.class deleted file mode 100644 index 6b5f4b02..00000000 Binary files a/getting-started/oddeven/target/classes/org/springframework/integration/samples/oddeven/EvenLogger.class and /dev/null differ diff --git a/getting-started/oddeven/target/classes/org/springframework/integration/samples/oddeven/IntervalOddEvenDemo.class b/getting-started/oddeven/target/classes/org/springframework/integration/samples/oddeven/IntervalOddEvenDemo.class deleted file mode 100644 index dadea56a..00000000 Binary files a/getting-started/oddeven/target/classes/org/springframework/integration/samples/oddeven/IntervalOddEvenDemo.class and /dev/null differ diff --git a/getting-started/oddeven/target/classes/org/springframework/integration/samples/oddeven/OddLogger.class b/getting-started/oddeven/target/classes/org/springframework/integration/samples/oddeven/OddLogger.class deleted file mode 100644 index bbf02d91..00000000 Binary files a/getting-started/oddeven/target/classes/org/springframework/integration/samples/oddeven/OddLogger.class and /dev/null differ diff --git a/getting-started/oddeven/target/classes/org/springframework/integration/samples/oddeven/cronOddEvenDemo.xml b/getting-started/oddeven/target/classes/org/springframework/integration/samples/oddeven/cronOddEvenDemo.xml deleted file mode 100644 index eef728da..00000000 --- a/getting-started/oddeven/target/classes/org/springframework/integration/samples/oddeven/cronOddEvenDemo.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/getting-started/oddeven/target/maven-archiver/pom.properties b/getting-started/oddeven/target/maven-archiver/pom.properties deleted file mode 100644 index 3234a446..00000000 --- a/getting-started/oddeven/target/maven-archiver/pom.properties +++ /dev/null @@ -1,5 +0,0 @@ -#Generated by Maven -#Sat Sep 04 08:22:31 EDT 2010 -version=2.0.0.BUILD-SNAPSHOT -groupId=org.springframework.integration.samples -artifactId=oddeven diff --git a/getting-started/oddeven/target/oddeven-2.0.0.BUILD-SNAPSHOT.jar b/getting-started/oddeven/target/oddeven-2.0.0.BUILD-SNAPSHOT.jar deleted file mode 100644 index b5716e7f..00000000 Binary files a/getting-started/oddeven/target/oddeven-2.0.0.BUILD-SNAPSHOT.jar and /dev/null differ