|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.asyncobjects.util.Compensated
public abstract class Compensated
This a special return value for actions in some control constructs like
Any
. These construct discard some values, an if the value is an open
resource, this could lead to serious resource leaks. This special value
allows for compensating in such situations. The normal scenario of this this
object is the following:
run()
method and waits until method finishes.
Note that before this method called, the action must not do anythig that
requires compensation. The caller might silently abandon the right to call
compensated action.cancel()
method.run()
method finishes, eventually it is determined
whether computation is commited or should be compensated.committed()
is called.compensateValue(Object)
or compensateFailure(Throwable)
are
called depending on situation.The subclasses are assumed to be thread-unsafe and they should not passed to other vats.
Constructor Summary | |
---|---|
Compensated()
|
Method Summary | |
---|---|
protected void |
cancel()
Cancel computation if it is possible. |
protected void |
committed()
Commit computation. |
protected void |
compensateFailure(Throwable value)
Compensate failed execution. |
protected abstract void |
compensateValue(Object value)
Compensate successful execution |
boolean |
equals(Object obj)
|
int |
hashCode()
|
protected abstract Object |
run()
Run primary action. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Compensated()
Method Detail |
---|
protected abstract Object run() throws Throwable
Throwable
- if there is a problem during executionprotected abstract void compensateValue(Object value) throws Throwable
value
- a value to compensate with
Throwable
- if there is problem with compensating. Note that fault is
logged and ignored.protected void compensateFailure(Throwable value) throws Throwable
value
- a value to compensate with
Throwable
- if there is problem with compensating. Note that fault is
logged and ignored.protected void cancel() throws Throwable
Throwable
- if there is problem with cancelling. Note that fault is
logged and ignored.protected void committed() throws Throwable
Throwable
- if there is problem with forgetting. Note that fault is
logged and ignored.public final int hashCode()
hashCode
in class Object
Object.hashCode()
public final boolean equals(Object obj)
equals
in class Object
Object.equals(java.lang.Object)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |