public class TaskLifecycleListener extends Object implements org.springframework.context.ApplicationListener<org.springframework.context.ApplicationEvent>, org.springframework.context.SmartLifecycle, org.springframework.beans.factory.DisposableBean
TaskRepository
.
The following events are used to identify the start and end of a task:
ContextRefreshedEvent
- Used to identify the start of a task. A task
is expected to contain a single application context.ApplicationReadyEvent
- Used to identify the successful end of a task.ApplicationFailedEvent
- Used to identify the failure of a task.spring.cloud.task.closecontext.enable
(defaults to true).Constructor and Description |
---|
TaskLifecycleListener(TaskRepository taskRepository,
TaskNameResolver taskNameResolver,
org.springframework.boot.ApplicationArguments applicationArguments,
TaskExplorer taskExplorer,
TaskProperties taskProperties) |
Modifier and Type | Method and Description |
---|---|
void |
destroy() |
int |
getPhase() |
boolean |
isAutoStartup() |
boolean |
isRunning() |
void |
onApplicationEvent(org.springframework.context.ApplicationEvent applicationEvent)
Utilizes
ApplicationEvent s to determine the start, end, and failure of a
task. |
void |
start() |
void |
stop() |
void |
stop(Runnable callback) |
public TaskLifecycleListener(TaskRepository taskRepository, TaskNameResolver taskNameResolver, org.springframework.boot.ApplicationArguments applicationArguments, TaskExplorer taskExplorer, TaskProperties taskProperties)
taskRepository
- The repository to record executions in.public void onApplicationEvent(org.springframework.context.ApplicationEvent applicationEvent)
ApplicationEvent
s to determine the start, end, and failure of a
task. Specifically:
ContextRefreshedEvent
- Start of a taskApplicationReadyEvent
- Successful end of a taskApplicationFailedEvent
- Failure of a taskonApplicationEvent
in interface org.springframework.context.ApplicationListener<org.springframework.context.ApplicationEvent>
applicationEvent
- The application being listened for.public boolean isAutoStartup()
isAutoStartup
in interface org.springframework.context.SmartLifecycle
public void stop(Runnable callback)
stop
in interface org.springframework.context.SmartLifecycle
public void start()
start
in interface org.springframework.context.Lifecycle
public void stop()
stop
in interface org.springframework.context.Lifecycle
public boolean isRunning()
isRunning
in interface org.springframework.context.Lifecycle
public int getPhase()
getPhase
in interface org.springframework.context.Phased
Copyright © 2018 Pivotal Software, Inc.. All rights reserved.