Class ProMFuture<T>
- java.lang.Object
-
- org.processmining.framework.plugin.ProMFuture<T>
-
- Type Parameters:
T-
- All Implemented Interfaces:
java.util.concurrent.Future<T>
public abstract class ProMFuture<T> extends java.lang.Object implements java.util.concurrent.Future<T>Class to represent a future on an object.- Author:
- bfvdonge
-
-
Constructor Summary
Constructors Constructor Description ProMFuture(java.lang.Class<? extends T> resultClass, java.lang.String label)Instantiates a ProMFuture object of the given type and with the given label.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleancancel(boolean mayInterruptIfRunning)protected abstract TdoInBackground()This method should be implemented by all subclasses of ProMFuture.protected voiddone()This method is called by the runnable of this future as soon as the computation of the result is ready, but before any listeners are notified of the completion.Tget()Tget(long timeout, java.util.concurrent.TimeUnit unit)FutureListener.ListenerListgetFutureListeners()Returns a ListenerList containing the registered future listenersjava.lang.StringgetLabel()returns the label of this futureNameChangeListener.ListenerListgetNameChangeListeners()Returns a ListenerList containing the registered name change listenersjava.lang.Class<?>getReturnType()The return type of this future.java.lang.RunnablegetRunnable()Returns the Runnable representing the execution that needs to be performed to produce the result of this future.booleanisCancelled()booleanisDone()voidsetLabel(java.lang.String label)Sets the label of this future to the given label and fires name change events in any registered name change listeners.java.lang.StringtoString()Return a string representation of this future.
-
-
-
Constructor Detail
-
ProMFuture
public ProMFuture(java.lang.Class<? extends T> resultClass, java.lang.String label)
Instantiates a ProMFuture object of the given type and with the given label. A SwingWorker is instantiated by the constructor. This SwingWorker is provided through thegetRunnable()method and once executed, it will execute thedoInBackground()method of this ProMFuture. When finished, thedone()method is invoked, after which any Future listeners are notified that this future is ready.- Parameters:
resultClass- Any type that extends T. However, no subtype of ProMFuture can be provided.label-
-
-
Method Detail
-
done
protected void done()
This method is called by the runnable of this future as soon as the computation of the result is ready, but before any listeners are notified of the completion. Any overriding implementation can use the get() method to return the object computed, as this method is guaranteed not to throw exceptions when done() is reached.
-
getRunnable
public java.lang.Runnable getRunnable()
Returns the Runnable representing the execution that needs to be performed to produce the result of this future.- Returns:
-
getReturnType
public java.lang.Class<?> getReturnType()
The return type of this future.- Returns:
-
cancel
public boolean cancel(boolean mayInterruptIfRunning)
- Specified by:
cancelin interfacejava.util.concurrent.Future<T>
-
get
public T get() throws java.lang.InterruptedException, java.util.concurrent.ExecutionException, java.util.concurrent.CancellationException
- Specified by:
getin interfacejava.util.concurrent.Future<T>- Throws:
java.lang.InterruptedExceptionjava.util.concurrent.ExecutionExceptionjava.util.concurrent.CancellationException
-
get
public T get(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException, java.util.concurrent.TimeoutException, java.util.concurrent.CancellationException
- Specified by:
getin interfacejava.util.concurrent.Future<T>- Throws:
java.lang.InterruptedExceptionjava.util.concurrent.ExecutionExceptionjava.util.concurrent.TimeoutExceptionjava.util.concurrent.CancellationException
-
isCancelled
public boolean isCancelled()
- Specified by:
isCancelledin interfacejava.util.concurrent.Future<T>
-
isDone
public boolean isDone()
- Specified by:
isDonein interfacejava.util.concurrent.Future<T>
-
doInBackground
protected abstract T doInBackground() throws java.lang.Exception
This method should be implemented by all subclasses of ProMFuture. Here, the object of type T is computed and returned.- Returns:
- Throws:
java.lang.Exception- This exception should be any exception thrown by the logic of the underlying method. Note that "wrapper"-Exceptions such as InvocationTargetException and ExecutionException should be unwrapped.
-
toString
public java.lang.String toString()
Return a string representation of this future.- Overrides:
toStringin classjava.lang.Object
-
getLabel
public java.lang.String getLabel()
returns the label of this future- Returns:
-
setLabel
public void setLabel(java.lang.String label)
Sets the label of this future to the given label and fires name change events in any registered name change listeners.- Parameters:
label-
-
getNameChangeListeners
public NameChangeListener.ListenerList getNameChangeListeners()
Returns a ListenerList containing the registered name change listeners- Returns:
-
getFutureListeners
public FutureListener.ListenerList getFutureListeners()
Returns a ListenerList containing the registered future listeners- Returns:
-
-