Class TaskHandlerImpl<T,V>
java.lang.Object
io.jmix.flowui.backgroundtask.impl.TaskHandlerImpl<T,V>
- Type Parameters:
T
- the type used to measure progress for the taskV
- the type of task's result
- All Implemented Interfaces:
BackgroundTaskHandler<V>
Implementation of the
BackgroundTaskHandler
interface, which provides the functionality
to handle and manage the lifecycle of a BackgroundTask
.-
Constructor Summary
ConstructorsConstructorDescriptionTaskHandlerImpl
(UIAccessor uiAccessor, TaskExecutor<T, V> taskExecutor, BackgroundTaskWatchDog backgroundTaskWatchDog, org.springframework.context.ApplicationEventPublisher applicationEventPublisher, org.springframework.security.core.userdetails.UserDetails user, TimeSource timeSource) -
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
cancel()
Cancels task.final void
Cancels without events for tasks.final void
execute()
Executes theBackgroundTask
.final V
Join task thread to current
Caution! Call this method only from synchronous gui action;long
Returns the timestamp marking the start time of a task.final BackgroundTask<T,
V> getTask()
Returns the background task associated with this handler.long
Returns the timeout duration in milliseconds for the associated task.final boolean
isAlive()
final boolean
final boolean
isDone()
final void
kill()
Cancels without events for tasks.protected void
onOwnerViewRemoved
(com.vaadin.flow.component.Component ownerView) protected void
final void
Cancels with timeout exceeded event.
-
Constructor Details
-
TaskHandlerImpl
public TaskHandlerImpl(UIAccessor uiAccessor, TaskExecutor<T, V> taskExecutor, BackgroundTaskWatchDog backgroundTaskWatchDog, org.springframework.context.ApplicationEventPublisher applicationEventPublisher, org.springframework.security.core.userdetails.UserDetails user, TimeSource timeSource)
-
-
Method Details
-
onOwnerViewRemoved
protected void onOwnerViewRemoved(com.vaadin.flow.component.Component ownerView) -
execute
public final void execute()Description copied from interface:BackgroundTaskHandler
Executes theBackgroundTask
.
This method must be called only once for a handler instance.- Specified by:
execute
in interfaceBackgroundTaskHandler<T>
-
cancel
public final boolean cancel()Description copied from interface:BackgroundTaskHandler
Cancels task.- Specified by:
cancel
in interfaceBackgroundTaskHandler<T>
- Returns:
true
if canceled,false
if the task was not started or is already stopped
-
removeViewDetachListener
protected void removeViewDetachListener() -
getResult
Join task thread to current
Caution! Call this method only from synchronous gui action;- Specified by:
getResult
in interfaceBackgroundTaskHandler<T>
- Returns:
- Task result
-
closeByTimeout
public final void closeByTimeout()Cancels without events for tasks. Need to executetimeoutExceeded()
after this method. -
kill
public final void kill()Cancels without events for tasks. -
timeoutExceeded
public final void timeoutExceeded()Cancels with timeout exceeded event. -
isDone
public final boolean isDone()- Specified by:
isDone
in interfaceBackgroundTaskHandler<T>
- Returns:
true
if the task is completed
-
isCancelled
public final boolean isCancelled()- Specified by:
isCancelled
in interfaceBackgroundTaskHandler<T>
- Returns:
true
if the task has been canceled
-
isAlive
public final boolean isAlive()- Specified by:
isAlive
in interfaceBackgroundTaskHandler<T>
- Returns:
true
if the task is running
-
getTask
Returns the background task associated with this handler.- Returns:
- the background task being managed by this handler
-
getStartTimeStamp
public long getStartTimeStamp()Returns the timestamp marking the start time of a task.- Returns:
- the start timestamp of the task
-
getTimeoutMs
public long getTimeoutMs()Returns the timeout duration in milliseconds for the associated task.- Returns:
- the timeout duration in milliseconds
-