|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.java.dev.vcc.api.Command<RESULT>
RESULT - the type of result from this command. If the command does not return a result per-se, but can either
succeed or fail, then the result type should be Success and failure will be
indicated by throwing an exception.public abstract class Command<RESULT>
Represents an operation to be performed. All instances of this class must comply with the JavaBeans specification
with the following modification: Setters will throw an IllegalStateException if the command has been
submitted, i.e. a setFoo method would look like this
public void setFoo(Foo foo) {
checkNotSubmitted();
this.foo = foo;
}
When a Command subclass is being extended, any new parameters should have
default values which ensure that older clients which are unaware of the new parameters will still achieve the same
behaviour.
| Constructor Summary | |
|---|---|
Command()
|
|
| Method Summary | |
|---|---|
boolean |
cancel(boolean mayInterruptIfRunning)
|
protected void |
checkNotSubmitted()
Throws an IllegalStateException if this command has been submitted. |
protected void |
checkSubmitted()
Throws an IllegalStateException if this command has not been submitted. |
RESULT |
get()
|
RESULT |
get(long timeout,
java.util.concurrent.TimeUnit unit)
|
boolean |
isCancelled()
|
boolean |
isDone()
|
boolean |
isSubmitted()
Returns true if the command has been submitted. |
void |
setSubmitted(java.util.concurrent.Future<RESULT> delegate)
This method is called by an SPI when the command has been submitted. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Command()
| Method Detail |
|---|
protected final void checkNotSubmitted()
IllegalStateException if this command has been submitted.
java.lang.IllegalStateException - if this command has been submitted.protected final void checkSubmitted()
IllegalStateException if this command has not been submitted.
java.lang.IllegalStateException - if this command has not been submitted.public final void setSubmitted(java.util.concurrent.Future<RESULT> delegate)
delegate - The future representing the command.public final boolean cancel(boolean mayInterruptIfRunning)
cancel in interface java.util.concurrent.Future<RESULT>public final boolean isSubmitted()
true if the command has been submitted.
true if the command has been submitted.public final boolean isCancelled()
isCancelled in interface java.util.concurrent.Future<RESULT>public final boolean isDone()
isDone in interface java.util.concurrent.Future<RESULT>
public final RESULT get()
throws java.lang.InterruptedException,
java.util.concurrent.ExecutionException
get in interface java.util.concurrent.Future<RESULT>java.lang.InterruptedException
java.util.concurrent.ExecutionException
public final RESULT get(long timeout,
java.util.concurrent.TimeUnit unit)
throws java.lang.InterruptedException,
java.util.concurrent.ExecutionException,
java.util.concurrent.TimeoutException
get in interface java.util.concurrent.Future<RESULT>java.lang.InterruptedException
java.util.concurrent.ExecutionException
java.util.concurrent.TimeoutException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||