net.sf.sasl.common.schedule
Class ScheduledFutureDecorator<V>
java.lang.Object
net.sf.sasl.common.schedule.ScheduledFutureDecorator<V>
- All Implemented Interfaces:
- Comparable<Delayed>, Callable<V>, Delayed, Future<V>, ScheduledFuture<V>
public class ScheduledFutureDecorator<V>
- extends Object
- implements ScheduledFuture<V>, Callable<V>
Decorator class for a (scheduled future, callable) pair which should solve a
strange behavior (feature or bug?) of the
Future.cancel(boolean)
method. Thats
it, if the callable gets already executed a call to cancel will return true,
which means that the scheduled future was successfully cancelled, but in real
it was not cancelled, because its currently running. So cancel(...) =>
!executed does not hold.
- Since:
- 0.0.1 (sasl-common-aspect-library)
- Author:
- Philipp Förmer
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ScheduledFutureDecorator
protected ScheduledFutureDecorator(Callable<V> callable)
throws IllegalArgumentException
- Proxies the given callable.
- Parameters:
callable
- non null
- Throws:
IllegalArgumentException
- if callable is null
setScheduledFuture
protected void setScheduledFuture(ScheduledFuture<V> scheduledFuture)
throws IllegalArgumentException
- Decorates the given scheduled future.
- Parameters:
scheduledFuture
- non null
- Throws:
IllegalArgumentException
- if scheduled future is null.
getDelay
public long getDelay(TimeUnit unit)
- Specified by:
getDelay
in interface Delayed
- See Also:
Delayed.getDelay(java.util.concurrent.TimeUnit)
compareTo
public int compareTo(Delayed delayed)
- Specified by:
compareTo
in interface Comparable<Delayed>
- See Also:
Comparable.compareTo(java.lang.Object)
cancel
public boolean cancel(boolean mayInterruptIfRunning)
- Specified by:
cancel
in interface Future<V>
- See Also:
Future.cancel(boolean)
get
public V get()
throws InterruptedException,
ExecutionException
- Specified by:
get
in interface Future<V>
- Throws:
InterruptedException
ExecutionException
- See Also:
Future.get()
get
public V get(long timeout,
TimeUnit unit)
throws InterruptedException,
ExecutionException,
TimeoutException
- Specified by:
get
in interface Future<V>
- Throws:
InterruptedException
ExecutionException
TimeoutException
- See Also:
Future.get(long, java.util.concurrent.TimeUnit)
isCancelled
public boolean isCancelled()
- Specified by:
isCancelled
in interface Future<V>
- See Also:
Future.isCancelled()
isDone
public boolean isDone()
- Specified by:
isDone
in interface Future<V>
- See Also:
Future.isDone()
call
public V call()
throws Exception
- Specified by:
call
in interface Callable<V>
- Throws:
Exception
- See Also:
Callable.call()
Copyright © 2010. All Rights Reserved.