The <router/> element now creates its own endpoint (i.e. it is no longer necessary to create a <handler-endpoint/> as well) (INT-284).
This commit is contained in:
@@ -18,20 +18,13 @@ package org.springframework.integration.samples.oddeven;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.springframework.integration.annotation.MessageEndpoint;
|
||||
import org.springframework.integration.annotation.MessageSource;
|
||||
import org.springframework.integration.annotation.Polled;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
@MessageEndpoint(output="numbers")
|
||||
@Polled(initialDelay=1000, period=3000)
|
||||
public class Counter {
|
||||
|
||||
private final AtomicInteger count = new AtomicInteger();
|
||||
|
||||
@MessageSource
|
||||
public int next() {
|
||||
return count.incrementAndGet();
|
||||
}
|
||||
|
||||
@@ -16,17 +16,15 @@
|
||||
|
||||
package org.springframework.integration.samples.oddeven;
|
||||
|
||||
import org.springframework.integration.annotation.MessageEndpoint;
|
||||
import org.springframework.integration.annotation.MessageTarget;
|
||||
import org.springframework.integration.annotation.Handler;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
@MessageEndpoint(input="even")
|
||||
public class EvenLogger {
|
||||
|
||||
@MessageTarget
|
||||
public void even(int i) {
|
||||
@Handler
|
||||
public void log(int i) {
|
||||
System.out.println("even: " + i);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,17 +16,15 @@
|
||||
|
||||
package org.springframework.integration.samples.oddeven;
|
||||
|
||||
import org.springframework.integration.annotation.MessageEndpoint;
|
||||
import org.springframework.integration.annotation.MessageTarget;
|
||||
import org.springframework.integration.annotation.Handler;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
@MessageEndpoint(input="odd")
|
||||
public class OddLogger {
|
||||
|
||||
@MessageTarget
|
||||
public void odd(int i) {
|
||||
@Handler
|
||||
public void log(int i) {
|
||||
System.out.println("odd: " + i);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,17 +16,12 @@
|
||||
|
||||
package org.springframework.integration.samples.oddeven;
|
||||
|
||||
import org.springframework.integration.annotation.MessageEndpoint;
|
||||
import org.springframework.integration.annotation.Router;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
@MessageEndpoint(input="numbers")
|
||||
public class NumberRouter {
|
||||
public class ParityResolver {
|
||||
|
||||
@Router
|
||||
public String resolveChannel(int i) {
|
||||
public String getParity(int i) {
|
||||
if (i % 2 == 0) {
|
||||
return "even";
|
||||
}
|
||||
@@ -2,22 +2,34 @@
|
||||
<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"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
|
||||
http://www.springframework.org/schema/context
|
||||
http://www.springframework.org/schema/context/spring-context-2.5.xsd
|
||||
http://www.springframework.org/schema/integration
|
||||
http://www.springframework.org/schema/integration/spring-integration-1.0.xsd">
|
||||
|
||||
<context:component-scan base-package="org.springframework.integration.samples.oddeven"/>
|
||||
|
||||
<message-bus/>
|
||||
<annotation-driven/>
|
||||
|
||||
<channel id="numbers"/>
|
||||
<channel id="even"/>
|
||||
<channel id="odd"/>
|
||||
|
||||
<annotation-driven/>
|
||||
<channel-adapter source="counter" method="next" channel="numbers">
|
||||
<schedule period="3000"/>
|
||||
</channel-adapter>
|
||||
|
||||
<router ref="parityResolver" method="getParity" input-channel="numbers"/>
|
||||
|
||||
<handler-endpoint ref="oddLogger" input-channel="odd"/>
|
||||
|
||||
<handler-endpoint ref="evenLogger" input-channel="even"/>
|
||||
|
||||
<beans:bean id="counter" class="org.springframework.integration.samples.oddeven.Counter"/>
|
||||
|
||||
<beans:bean id="parityResolver" class="org.springframework.integration.samples.oddeven.ParityResolver"/>
|
||||
|
||||
<beans:bean id="oddLogger" class="org.springframework.integration.samples.oddeven.OddLogger"/>
|
||||
|
||||
<beans:bean id="evenLogger" class="org.springframework.integration.samples.oddeven.EvenLogger"/>
|
||||
|
||||
</beans:beans>
|
||||
|
||||
Reference in New Issue
Block a user