public abstract class AbstractCallback<IN,OUT> extends Object implements Callback<IN,OUT>, Emit.IListener<IN>
Also contains a few special inner class implementations useful for unit tests
Modifier and Type | Class and Description |
---|---|
static class |
AbstractCallback.Canned<IN,OUT>
Inner class mainly for tests, allows for canned results
|
static class |
AbstractCallback.NOP<IN>
Class that does nothing (just calls failFast), then returns input unchanged
|
Callback.ProducesMore<IN,OUT,MORE>, Callback.ProducesMultiple<IN,OUT>
Modifier and Type | Field and Description |
---|---|
protected Callback |
nextCallback |
Constructor and Description |
---|
AbstractCallback() |
Modifier and Type | Method and Description |
---|---|
abstract OUT |
callback(Exception ex,
IN in,
Object... more)
The callback method
|
protected void |
failFast(Exception ex,
IN in,
Object... more)
Fail Fast means that you want this completedCallback to handle the exception
|
protected void |
failSlow(Exception ex,
IN in,
Object... more)
Fail Slow means that you will pass the Exception down to (perhaps the end) of the chain
This is handy if you have special Exception handling and can tack it on the end of all the callbacks.
|
Callback |
getNextCallback()
Get the callback to follow this one.
|
void |
handleEvent(IN arg0,
Object... more)
Receive and handle an "event", represented by arg0 and possibly more.
|
protected void |
handleException(Exception ex,
IN in,
Object... more)
Override this if you want to do something to try to recover
|
void |
setNextCallback(Callback nextCallback)
Set the callback to follow this one.
|
protected Callback nextCallback
public abstract OUT callback(Exception ex, IN in, Object... more) throws Exception
Callback
public void handleEvent(IN arg0, Object... more)
Emit.IListener
IEmitter.emit()
handleEvent
in interface Emit.IListener<IN>
arg0
- hopefully of type more
- often emptypublic void setNextCallback(Callback nextCallback)
Callback
setNextCallback
in interface Callback<IN,OUT>
nextCallback
- null means end of the linepublic Callback getNextCallback()
Callback
getNextCallback
in interface Callback<IN,OUT>
protected void handleException(Exception ex, IN in, Object... more) throws Exception
ex
- the Exception that was thrown by a previous callbackin
- results from the previous callback, usually null and ignoredException
protected void failFast(Exception ex, IN in, Object... more) throws Exception
ex
- if null, nothing happensin
- results from the previous callbackException
protected void failSlow(Exception ex, IN in, Object... more) throws Exception
ex
- if null, nothing happemsin
- results from the previous callbackException