Refactor of Task API

This change removes the Spring Cloud Task dependency upon a
CommandLineRunner from boot and moves the handling of the task lifecycle
closer to the "edge" of a Spring Boot application.

With this change, now a developer simply adds @EnableTask to their
configuration somewhere and the task lifecycle will be recorded.

Resolves spring-cloud/spring-cloud-task#39
This commit is contained in:
Michael Minella
2015-12-15 13:00:42 -06:00
committed by Glenn Renfro
parent 7be3a88826
commit 61d3cc3641
23 changed files with 453 additions and 465 deletions

View File

@@ -22,13 +22,13 @@ import java.text.SimpleDateFormat;
import java.util.Date;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cloud.task.annotation.EnableTask;
import org.springframework.cloud.task.annotation.Task;
import org.springframework.cloud.task.configuration.EnableTask;
import org.springframework.context.annotation.Bean;
/**
@@ -49,9 +49,8 @@ public class TaskApplication {
}
/**
* A commandline runner that prints a timestamp and is annotated with @Task.
* A commandline runner that prints a timestamp.
*/
@Task("Demo Timestamp Task")
public class TimestampTask implements CommandLineRunner {
private final org.slf4j.Logger logger = LoggerFactory.getLogger(TimestampTask.class);

View File

@@ -0,0 +1 @@
spring.application.name=Demo Timestamp Task