INT-1477 restructuring samples repo to have basic, intermediate, advancedand applications directories

This commit is contained in:
Oleg Zhurakousky
2010-09-28 16:58:48 -04:00
parent f44812b7a9
commit 59081a2df8
362 changed files with 0 additions and 0 deletions

10
basic/oddeven/.classpath Normal file
View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
<classpathentry kind="src" path="src/main/resources"/>
<classpathentry kind="src" path="src/test/java"/>
<classpathentry kind="src" path="src/test/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>

1
basic/oddeven/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/target

23
basic/oddeven/.project Normal file
View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>oddeven</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.maven.ide.eclipse.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.maven.ide.eclipse.maven2Nature</nature>
</natures>
</projectDescription>

View File

@@ -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=<?xml version\="1.0" encoding\="UTF-8"?>\n<graph>\n<element clazz\="ChannelModelElement" type\="channel">\n<structure end\="529" endstart\="529" start\="509" startend\="529"/>\n<bounds height\="112" width\="116" x\="19" y\="17"/>\n</element>\n<element clazz\="ChannelModelElement" type\="channel">\n<structure end\="550" endstart\="550" start\="531" startend\="550"/>\n<bounds height\="112" width\="116" x\="19" y\="149"/>\n</element>\n<element clazz\="InboundChannelAdapterModelElement" type\="inbound-channel-adapter">\n<structure end\="704" endstart\="678" start\="553" startend\="619"/>\n<bounds height\="112" width\="116" x\="19" y\="281"/>\n</element>\n<element clazz\="RouterModelElement" type\="router">\n<structure end\="787" endstart\="787" start\="707" startend\="787"/>\n<bounds height\="112" width\="116" x\="155" y\="281"/>\n</element>\n<element clazz\="ServiceActivatorModelElement" type\="service-activator">\n<structure end\="846" endstart\="846" start\="790" startend\="846"/>\n<bounds height\="112" width\="116" x\="155" y\="149"/>\n</element>\n<element clazz\="ServiceActivatorModelElement" type\="service-activator">\n<structure end\="907" endstart\="907" start\="849" startend\="907"/>\n<bounds height\="112" width\="116" x\="155" y\="17"/>\n</element>\n</graph>
eclipse.preferences.version=1

65
basic/oddeven/pom.xml Normal file
View File

@@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.springframework.integration.samples</groupId>
<artifactId>oddeven</artifactId>
<name>Spring Integration Odd-Even Sample</name>
<version>2.0.0</version>
<packaging>jar</packaging>
<properties>
<spring.integration.version>2.0.0.M7</spring.integration.version>
<log4j.version>1.2.16</log4j.version>
<junit.version>4.7</junit.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-core</artifactId>
<version>${spring.integration.version}</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
</dependency>
<!-- test-scoped dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
<compilerArgument>-Xlint:all</compilerArgument>
<showWarnings>true</showWarnings>
<showDeprecation>false</showDeprecation>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>repository.springframework.maven.release</id>
<name>Spring Framework Maven Release Repository</name>
<url>http://maven.springframework.org/release</url>
</repository>
<repository>
<id>repository.springframework.maven.milestone</id>
<name>Spring Framework Maven Milestone Repository</name>
<url>http://maven.springframework.org/milestone</url>
</repository>
<repository>
<id>repository.springframework.maven.snapshot</id>
<name>Spring Framework Maven Snapshot Repository</name>
<url>http://maven.springframework.org/snapshot</url>
</repository>
</repositories>
</project>

20
basic/oddeven/readme.txt Normal file
View File

@@ -0,0 +1,20 @@
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

View File

@@ -0,0 +1,39 @@
/*
* 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.
* 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.oddeven;
import java.util.concurrent.atomic.AtomicInteger;
/**
* A simple POJO providing a method that returns incrementing integer values.
* This is referenced in the sample's configuration by an inbound Channel
* Adapter acting as a Polling Consumer.
* <p/>
* Every 5th number will be returned as a negative value.
*
* @author Mark Fisher
*/
public class Counter {
private final AtomicInteger count = new AtomicInteger();
public int next() {
int nextNumber = count.incrementAndGet();
return (nextNumber % 5 == 0) ? -nextNumber : nextNumber;
}
}

View File

@@ -0,0 +1,41 @@
/*
* 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.
* 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.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;
/**
* A POJO Service Activator that logs even numbers and the current time.
*
* @author Mark Fisher
* @author Marius Bogoevici
*/
@MessageEndpoint
public class EvenLogger {
private static Logger logger = Logger.getLogger(EvenLogger.class);
@ServiceActivator
public void log(int i) {
logger.info("even: " + i + " at " + new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(new Date()));
}
}

View File

@@ -0,0 +1,41 @@
/*
* 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.
* 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.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;
/**
* A POJO Service Activator that logs odd numbers and the current time.
*
* @author Mark Fisher
* @author Marius Bogoevici
*/
@MessageEndpoint
public class OddLogger {
private static Logger logger = Logger.getLogger(OddLogger.class);
@ServiceActivator
public void log(int i) {
logger.info("odd: " + i + " at " + new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(new Date()));
}
}

View File

@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/integration"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration.xsd">
<annotation-config/>
<channel id="even"/>
<channel id="odd"/>
<inbound-channel-adapter id="numbers" ref="counter" method="next">
<poller max-messages-per-poll="1" cron="1,2,3,5,8,13,21,34,55 * * * * ?"/>
</inbound-channel-adapter>
<filter input-channel="numbers" output-channel="positives"
expression="payload > 0"
discard-channel="nullChannel"/>
<router input-channel="positives" expression="payload % 2 == 0 ? 'even' : 'odd'"/>
<service-activator input-channel="odd" ref="oddLogger"/>
<service-activator input-channel="even" ref="evenLogger"/>
<beans:bean id="counter" class="org.springframework.integration.samples.oddeven.Counter"/>
<beans:bean id="oddLogger" class="org.springframework.integration.samples.oddeven.OddLogger"/>
<beans:bean id="evenLogger" class="org.springframework.integration.samples.oddeven.EvenLogger"/>
</beans:beans>

View File

@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/integration"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration.xsd">
<annotation-config/>
<channel id="even"/>
<channel id="odd"/>
<inbound-channel-adapter id="numbers" ref="counter" method="next">
<poller max-messages-per-poll="1" fixed-delay="3000"/>
</inbound-channel-adapter>
<router input-channel="numbers" expression="payload % 2 == 0 ? 'even' : 'odd'"/>
<service-activator input-channel="odd" ref="oddLogger"/>
<service-activator input-channel="even" ref="evenLogger"/>
<beans:bean id="counter" class="org.springframework.integration.samples.oddeven.Counter"/>
<beans:bean id="oddLogger" class="org.springframework.integration.samples.oddeven.OddLogger"/>
<beans:bean id="evenLogger" class="org.springframework.integration.samples.oddeven.EvenLogger"/>
</beans:beans>

View File

@@ -0,0 +1,41 @@
/*
* 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.
* 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.oddeven;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
* Demonstrates a method-invoking inbound Channel Adapter acting as a Polling
* Consumer with a cron-based trigger. That adapter is followed, downstream, by
* a simple method-invoking Message Filter that discards negative numbers to
* the "nullChannel". Next is a Content Based Router. The router sends to one of
* two channels based on whether the payload number is odd or even. Each of
* those two channels has an Event Driven Consumer ready to log the number
* and the current time.
* <p>
* See the 'cronOddEvenDemo.xml' configuration file for more detail. The cron
* expression is based on the Fibonacci sequence. Feel free to modify it.
*
* @author Mark Fisher
*/
public class CronOddEvenDemo {
public static void main(String[] args) {
new ClassPathXmlApplicationContext("/META-INF/spring/integration/cronOddEvenDemo.xml", CronOddEvenDemo.class);
}
}

View File

@@ -0,0 +1,40 @@
/*
* 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.
* 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.oddeven;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
* Demonstrates a method-invoking inbound Channel Adapter acting as a Polling
* Consumer with an interval-based trigger. That adapter is followed,
* downstream, by a simple method-invoking Message Filter that discards
* negative numbers to the "nullChannel". Next is a Content Based Router. The
* router sends to one of two channels based on whether the payload number is
* odd or even. Each of those two channels has an Event Driven Consumer ready
* to log the number and the current time.
* <p>
* See the 'intervalOddEvenDemo.xml' configuration file for more detail.
*
* @author Mark Fisher
*/
public class IntervalOddEvenDemoTest {
public static void main(String[] args) {
new ClassPathXmlApplicationContext("/META-INF/spring/integration/intervalOddEvenDemo.xml", IntervalOddEvenDemoTest.class);
}
}

View File

@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<!-- Appenders -->
<appender name="console" class="org.apache.log4j.ConsoleAppender">
<param name="Target" value="System.out" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%-5p: %c - %m%n" />
</layout>
</appender>
<!-- Loggers -->
<logger name="org.springframework">
<level value="warn" />
</logger>
<logger name="org.springframework.integration.samples">
<level value="debug" />
</logger>
<logger name="org.springframework.integration.channel.NullChannel">
<level value="debug" />
</logger>
<!-- Root Logger -->
<root>
<priority value="warn" />
<appender-ref ref="console" />
</root>
</log4j:configuration>