com.levigo.util.swing
Class PendingOperations

java.lang.Object
  extended by com.levigo.util.swing.PendingOperations

public class PendingOperations
extends Object

Keep track of pending operations that might inhibit the shutdown of a component or the shutdown of the whole application.

Of course, it can also serve to request if a specific operation is already running in order to avoid starting the same operation twice.

Each instance of this class owns a context. Therefore this class can be used by different application parts to keep track of their running background processes.

Usage:



   PendingOperations.getInstance("myApplication").operationStarted(myObject);
   ...
   PendingOperations.getInstance("myApplication").operationFinished(myObject);


 
Other application part might want to know if a specific operation is already running:
 PendingOperations.getInstance("myApplication").isOperationPending(myObject);
 
or if any operation is running for a given context
 PendingOperations.getInstance("myApplication").isOperationPending();
 

Author:
Daniela Gehle

Method Summary
 void finished(Object key)
          Notify this instance that the operation that was registered as pending under the given key is finished now.
static PendingOperations getInstance(Object context)
          The context to add, query or remove an operation for.
 Vector<Object> getPendingOperations()
          Returns a flat copy of the pendingOperations, mostly for logging purposes.
 boolean isPending()
          Ask if any operation is still running in the current instance's context.
 boolean isPending(Object key)
          Ask if the specified operation is still running in the current instance's context.
 void started(Object key)
          Notify this instance that given operation should be registered as pending.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static PendingOperations getInstance(Object context)
The context to add, query or remove an operation for. Usage: The context might be interpreted as a sub-application.

Parameters:
context - The category or sub-application to inquire

started

public void started(Object key)
Notify this instance that given operation should be registered as pending.

Parameters:
key - The object that serves as key for registering a pending operation.

finished

public void finished(Object key)
Notify this instance that the operation that was registered as pending under the given key is finished now.

Parameters:
key - The object that serves as key for registering a pending operation.

isPending

public boolean isPending(Object key)
Ask if the specified operation is still running in the current instance's context.

Parameters:
key - The key of the operation to look up in the list of pending operations
Returns:
true if the given operation is registered as pending, false otherwise.

isPending

public boolean isPending()
Ask if any operation is still running in the current instance's context.

Returns:
true if the any operation is registered as pending, false otherwise.

getPendingOperations

public Vector<Object> getPendingOperations()
Returns a flat copy of the pendingOperations, mostly for logging purposes.

Returns:
a flat copy of the pendingOperations.


Copyright © 1995-2020 levigo holding gmbh. All Rights Reserved.