|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.asyncobjects.When<I,R>
I
- a type of input valueR
- a type of resultpublic abstract class When<I,R>
When construct support class. The construct is inspired by when/catch/finally exprssion in E programming language. The class is an utility implementation of resolver interface. The class is used by many other control construct to implement more specialized control flows.
Subclasses override the following methods:
resolved(Object)
bodySmashed(Throwable)
resolved(Object)
fails. By default,
it delegates to smashed(Throwable)
.smashed(Throwable)
bodySmashed(Throwable)
is not overriden. resolved(Object)
fails.finallyDo()
resolved(Object)
or smashed(Throwable)
finish.
See AsyncUnicastServer
for definition of "fails", "finishes", and
"finishes successfully".
Nested Class Summary | |
---|---|
class |
When.InternalArgumentListener
This is an internal class. |
class |
When.InternalBodyPromiseResolver
This is an internal class. |
class |
When.InternalFinallyListenerAfterFault
This is an internal class. |
class |
When.InternalFinallyListenerAfterSuccess
This is an internal class. |
class |
When.InternalResultPromiseResolver
This is internal class. |
Constructor Summary | |
---|---|
When(I p)
A constructor from value. |
|
When(Promise<? extends I> p)
A constructor from promise. |
Method Summary | |
---|---|
protected Promise<? extends R> |
bodySmashed(Throwable problem)
This method is called if the method resolved(Object) throws
exception or when promise returned from that method is smashed. |
protected Promise<?> |
finallyDo()
This action is called when promise is already either resolved or smashed if this method returns promise, the result promise is not resolved until a promise returned by this method is resolved. |
Promise<R> |
promise()
|
protected abstract Promise<? extends R> |
resolved(I value)
This method is called when promise is overloaded in subclasses. |
protected Promise<? extends R> |
smashed(Throwable problem)
This method is called when argument promise is broken. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public When(Promise<? extends I> p)
p
- promise to listen topublic When(I p)
p
- a possibly unresolved reference to asynchronous serviceMethod Detail |
---|
public Promise<R> promise()
protected abstract Promise<? extends R> resolved(I value) throws Throwable
value
- value to which promise had been resolved
Throwable
- if there is a problemprotected Promise<? extends R> bodySmashed(Throwable problem) throws Throwable
resolved(Object)
throws
exception or when promise returned from that method is smashed. By
default the method calls the method smashed(Throwable)
.
problem
- a problem that broken a promise.
Throwable
- if there is a problemprotected Promise<? extends R> smashed(Throwable problem) throws Throwable
This method is called when argument promise is broken. If method
bodySmashed(Throwable)
is not overriden, it is also called if
the method resolved(Object)
throws exception or when promise
returned from that method is smashed.
The default implementation returns a smashed promise.
problem
- a problem that broken a promise.
Throwable
- if there is a problemprotected Promise<?> finallyDo() throws Throwable
This action is called when promise is already either resolved or smashed if this method returns promise, the result promise is not resolved until a promise returned by this method is resolved. If this method throws exception or promise returned by this method is smashed, the resulting promise is smashed too.
Default implementation returns null.
Throwable
- if there is a problem
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |