Polish scheduled task execution infrastructure

In anticipation of substantive changes required to implement "initial
delay" support in the <task:scheduled> element and @Scheduled
annotation, the following updates have been made to the components and
infrastructure supporting scheduled task execution:

 - Fix code style violations
 - Fix compiler warnings
 - Add Javadoc where missing, update to use {@code} tags, etc.
 - Organize imports to follow conventions
This commit is contained in:
Chris Beams
2012-05-21 08:47:59 +03:00
parent e2fbaa8470
commit 4d5fe57a08
9 changed files with 109 additions and 84 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2011 the original author or authors.
* Copyright 2002-2012 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.
@@ -16,15 +16,11 @@
package org.springframework.scheduling.annotation;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.hamcrest.Matchers.startsWith;
import static org.junit.Assert.assertThat;
import java.util.Date;
import java.util.concurrent.atomic.AtomicInteger;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -34,6 +30,10 @@ import org.springframework.scheduling.TriggerContext;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
/**
* Tests use of @EnableScheduling on @Configuration classes.
*

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2011 the original author or authors.
* Copyright 2002-2012 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.
@@ -25,7 +25,6 @@ import java.lang.reflect.Method;
import java.util.Map;
import java.util.Properties;
import static org.junit.Assert.*;
import org.junit.Test;
import org.springframework.beans.DirectFieldAccessor;
@@ -37,6 +36,8 @@ import org.springframework.context.support.StaticApplicationContext;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;
import org.springframework.scheduling.support.ScheduledMethodRunnable;
import static org.junit.Assert.*;
/**
* @author Mark Fisher
* @author Juergen Hoeller
@@ -269,7 +270,7 @@ public class ScheduledAnnotationBeanPostProcessorTests {
}
public static class FixedDelayTestBean {
static class FixedDelayTestBean {
@Scheduled(fixedDelay=5000)
public void fixedDelay() {
@@ -277,7 +278,7 @@ public class ScheduledAnnotationBeanPostProcessorTests {
}
public static class FixedRateTestBean {
static class FixedRateTestBean {
@Scheduled(fixedRate=3000)
public void fixedRate() {
@@ -285,7 +286,15 @@ public class ScheduledAnnotationBeanPostProcessorTests {
}
public static class CronTestBean {
static class FixedRateWithInitialDelayTestBean {
@Scheduled(initialDelay=1000, fixedRate=3000)
public void fixedRate() {
}
}
static class CronTestBean {
@Scheduled(cron="*/7 * * * * ?")
public void cron() throws IOException {
@@ -295,7 +304,7 @@ public class ScheduledAnnotationBeanPostProcessorTests {
}
private static class EmptyAnnotationTestBean {
static class EmptyAnnotationTestBean {
@Scheduled
public void invalid() {
@@ -304,7 +313,7 @@ public class ScheduledAnnotationBeanPostProcessorTests {
}
private static class InvalidCronTestBean {
static class InvalidCronTestBean {
@Scheduled(cron="abc")
public void invalid() {
@@ -313,7 +322,7 @@ public class ScheduledAnnotationBeanPostProcessorTests {
}
private static class NonVoidReturnTypeTestBean {
static class NonVoidReturnTypeTestBean {
@Scheduled(fixedRate=3000)
public String invalid() {
@@ -323,7 +332,7 @@ public class ScheduledAnnotationBeanPostProcessorTests {
}
private static class NonEmptyParamListTestBean {
static class NonEmptyParamListTestBean {
@Scheduled(fixedRate=3000)
public void invalid(String oops) {
@@ -344,7 +353,7 @@ public class ScheduledAnnotationBeanPostProcessorTests {
private static @interface Hourly {}
private static class MetaAnnotationFixedRateTestBean {
static class MetaAnnotationFixedRateTestBean {
@EveryFiveSeconds
public void checkForUpdates() {
@@ -352,7 +361,7 @@ public class ScheduledAnnotationBeanPostProcessorTests {
}
private static class MetaAnnotationCronTestBean {
static class MetaAnnotationCronTestBean {
@Hourly
public void generateReport() {
@@ -360,7 +369,7 @@ public class ScheduledAnnotationBeanPostProcessorTests {
}
private static class PropertyPlaceholderTestBean {
static class PropertyPlaceholderTestBean {
@Scheduled(cron = "${schedules.businessHours}")
public void x() {
@@ -370,11 +379,11 @@ public class ScheduledAnnotationBeanPostProcessorTests {
@Scheduled(cron = "${schedules.businessHours}")
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Retention(RetentionPolicy.RUNTIME)
private static @interface BusinessHours {}
private static class PropertyPlaceholderMetaAnnotationTestBean {
static class PropertyPlaceholderMetaAnnotationTestBean {
@BusinessHours
public void y() {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2011 the original author or authors.
* Copyright 2002-2012 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.
@@ -21,7 +21,6 @@ import java.util.Collection;
import java.util.Date;
import java.util.Map;
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
@@ -32,6 +31,8 @@ import org.springframework.scheduling.Trigger;
import org.springframework.scheduling.TriggerContext;
import org.springframework.scheduling.support.ScheduledMethodRunnable;
import static org.junit.Assert.*;
/**
* @author Mark Fisher
*/