- Type Parameters:
DataType- the type of the data being intercepted
public interface DataInterceptor<DataType>
Defines an interface for intercepting data provided by an
AsyncDataLink. That is, before actually notifying the
AsyncDataListener, the appropriate method of this interface is
notified first. It is also possible to filter out some data, so it won't be
forwarded to the listener.
This interface is used by the AsyncDataLink create by the
AsyncLinks.interceptData(AsyncDataLink, DataInterceptor) method.
Thread safety
Implementations of this interface are required to be safe to be used by multiple threads concurrently.Synchronization transparency
Implementations of this interface are not required to be synchronization transparent. Note however, that they must be quick non-blocking methods.-
Method Summary
Modifier and TypeMethodDescriptionbooleanonDataArrive(DataType newData) Invoked before data is forwarded to theAsyncDataListener.voidonDoneReceive(AsyncReport report) Invoked before theAsyncDataListeneronDoneReceivewas called.
-
Method Details
-
onDataArrive
Invoked before data is forwarded to theAsyncDataListener. It is possible to filter out this data (i.e.: not forward it to the listener) by returningfalse.Since this method is called in a listener, it should be a quick non-blocking method. Also if this method throws an exception, the data will not be forwarded (as if returning
false). Note however, that likeAsyncDataListener, this method should throw an exception.- Parameters:
newData- the data received and to be forwarded to theAsyncDataListener. This argument can benullif it is possible for the providingAsyncDataLinkto providenulldata objects.- Returns:
trueif the specified data is to be forwarded to theAsyncDataListener,falseif this data should be filtered out.
-
onDoneReceive
Invoked before theAsyncDataListeneronDoneReceivewas called.The
onDoneReceiveof the listener will be called after this method returns even if it throws an exception. Note however, that this method should not throw exceptions,- Parameters:
report- theAsyncReportwhich is to be passed to theonDoneReceivemethod of theAsyncDataListener. This argument cannot benull.
-