Merging the interval and cron-based Odd-Even samples into the same package.

This commit is contained in:
Mark Fisher
2008-09-05 03:05:58 +00:00
parent 5daefc91de
commit d5ec7a5664
8 changed files with 20 additions and 75 deletions

View File

@@ -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);
}
}

View File

@@ -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()));
}
}

View File

@@ -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);
}
}

View File

@@ -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()));
}
}
}

View File

@@ -25,16 +25,16 @@
<beans:bean id="counter" class="org.springframework.integration.message.MethodInvokingSource">
<beans:property name="object">
<beans:bean class="org.springframework.integration.samples.quartzoddeven.Counter"/>
<beans:bean class="org.springframework.integration.samples.oddeven.Counter"/>
</beans:property>
<beans:property name="methodName" value="next"/>
</beans:bean>
<beans:bean id="parityResolver" class="org.springframework.integration.samples.oddeven.ParityResolver"/>
<beans:bean id="oddLogger" class="org.springframework.integration.samples.quartzoddeven.OddLogger"/>
<beans:bean id="oddLogger" class="org.springframework.integration.samples.oddeven.OddLogger"/>
<beans:bean id="evenLogger" class="org.springframework.integration.samples.quartzoddeven.EvenLogger"/>
<beans:bean id="evenLogger" class="org.springframework.integration.samples.oddeven.EvenLogger"/>
<beans:bean id="quartzTaskScheduler" class="org.springframework.integration.scheduling.spi.ProviderTaskScheduler">
<beans:constructor-arg>

View File

@@ -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();
}
}

View File

@@ -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";
}
}