Class CockpitNGBackgroundOperation
- java.lang.Object
-
- com.hybris.cockpitng.engine.operations.CockpitNGBackgroundOperation
-
- All Implemented Interfaces:
Cancellable,java.lang.Runnable
public class CockpitNGBackgroundOperation extends java.lang.Object implements java.lang.Runnable, Cancellable
Backoffice background operation that is capable of performing long running tasks in background allowing the UI to remain responsive.
After long running task is completed an operation to update
the UI is scheduled viaExecutions.schedule(Desktop, EventListener, Event)method.
The contract for background task is to execute normally and return the result or throwRuntimeExceptionin case of error.
Background task should not interact with ZK UI neither viaExecutions.schedule(Desktop, EventListener, Event)nor viaExecutions.activate(Desktop)
-
-
Constructor Summary
Constructors Constructor Description CockpitNGBackgroundOperation(org.zkoss.zk.ui.Desktop desktop, RequestOperationContextHolder.ContextRequest contextRequest, java.util.function.Supplier backgroundTask, java.util.function.Consumer<java.lang.Object> onSuccess, java.util.function.Consumer<java.lang.Exception> onError)Creates new instance ofCockpitNGBackgroundOperation
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcancel()Cancels the operation.voidrun()protected voidrunInternal(org.zkoss.zk.ui.Desktop desktop)protected voidscheduleForUI(java.lang.Object result, java.util.function.Consumer consumer)
-
-
-
Constructor Detail
-
CockpitNGBackgroundOperation
public CockpitNGBackgroundOperation(org.zkoss.zk.ui.Desktop desktop, RequestOperationContextHolder.ContextRequest contextRequest, java.util.function.Supplier backgroundTask, java.util.function.Consumer<java.lang.Object> onSuccess, java.util.function.Consumer<java.lang.Exception> onError)Creates new instance ofCockpitNGBackgroundOperation- Parameters:
contextRequest- context of currently running server requestbackgroundTask- long running task to be executedonSuccess- callback to be executed after background tasks finishes successfully.
This callback will be scheduled for the UI thread viaExecutions.schedule(Desktop, EventListener, Event)onError- callback to be executed on background task error.
This callback will be scheduled for the UI thread viaExecutions.schedule(Desktop, EventListener, Event)
-
-
Method Detail
-
run
public void run()
- Specified by:
runin interfacejava.lang.Runnable
-
cancel
public void cancel()
Description copied from interface:CancellableCancels the operation.- Specified by:
cancelin interfaceCancellable
-
runInternal
protected void runInternal(org.zkoss.zk.ui.Desktop desktop)
-
scheduleForUI
protected void scheduleForUI(java.lang.Object result, java.util.function.Consumer consumer)
-
-