Class ClientProgressManager

  • All Implemented Interfaces:
    ProgressManager

    public class ClientProgressManager
    extends java.lang.Object
    implements ProgressManager
    The ClientProgressManager handles asynchronous tasks in the client, and across the client/gateway boundary.

    It can be accessed through the static getInstance function as well as through the ClientContext.

    The way the progress system works is that long running tasks (that is, any task that takes long enough that progress might be desired) are wrapped up as a AsyncClientTask, and are run through this manager.

    When a task is registered, a TaskHandle is returned, which can be used to monitor status, wait for a result, and get the return value of the asynchronous operation. It can also be used to cancel the task.

    The class registering the operation does not need to worry about displaying status, as that is handled by the system. However, it is possible to "pause" the UI in situations where having a pop up display open is undesirable. Calling setUIPaused affects all outstanding progress operations, and should therefore be called very carefully.

    Tasks executing against the gateway
    It's important to note that the gateway has a separate notion of asynchronous tasks. For the best results, the progress system should be used on both sides, but they are fundamentally separate. As a result, operations on the gateway get their own UID. Asynchronous gateway operations, triggered from the designer (even if not through the progress system!), can publish updates to the designer progress manager. Thus it's possible that a progress dialog might be shown even when you are not using the client progress manager to run a task.

    In a normal, fully async setup, you would end up with the following progress updates:
    ClientOp
    GatewayOp
    GatewayOp
    GatewayOp
    ClientOp

    The client operation and gateway operations are seen as two seperate tasks. Which is displayed is based on whether the first task is dominant. If the client task is dominant, it will stay displayed, and its progress will be updated. If not, the display will switch to the gateway task when it comes in, and will stay on that until it's finished.

    More information about the way the gateway progress system works can be found on the GatewayProgressManager page.

    • Method Detail

      • startup

        public void startup()
      • getLogger

        protected org.apache.log4j.Logger getLogger()
      • setUIPaused

        public void setUIPaused​(boolean value)
      • shutdown

        public void shutdown()
      • runTask

        public TaskHandle runTask​(AsyncClientTask task)
        Executes the provided task asynchronously. Displays progress as appropriate, and will display an error box if the task execution throws an exception.

        Returns a TaskHandle that can be used to wait for the task to finish, cancel the task, etc.

      • runTask

        public TaskHandle runTask​(AsyncClientTask task,
                                  boolean dominant)
        Executes a task. See runTask(task) for more info.
        Parameters:
        dominant - true indicates that this task should be favored for display, and will spawn subtasks that it will account for in its progress.
      • run

        public <T> void run​(java.util.concurrent.CompletableFuture<T> cf,
                            java.util.function.Consumer<T> handler,
                            java.lang.Object owner)
      • cancelAllTasks

        public void cancelAllTasks()
      • cancelTask

        public void cancelTask​(java.lang.String uid)
      • registerGatewayTask

        public TaskHandle registerGatewayTask​(java.lang.String taskId)
      • updateUI

        protected void updateUI()
      • setClientContext

        public void setClientContext​(ClientContext context)