Module jtrim.query

Interface DataInterceptor<DataType>

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.
See Also:
  • Method Details

    • onDataArrive

      boolean onDataArrive(DataType newData)
      Invoked before data is forwarded to the AsyncDataListener. It is possible to filter out this data (i.e.: not forward it to the listener) by returning false.

      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 like AsyncDataListener, this method should throw an exception.

      Parameters:
      newData - the data received and to be forwarded to the AsyncDataListener. This argument can be null if it is possible for the providing AsyncDataLink to provide null data objects.
      Returns:
      true if the specified data is to be forwarded to the AsyncDataListener, false if this data should be filtered out.
    • onDoneReceive

      void onDoneReceive(AsyncReport report)
      Invoked before the AsyncDataListener onDoneReceive was called.

      The onDoneReceive of 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 - the AsyncReport which is to be passed to the onDoneReceive method of the AsyncDataListener. This argument cannot be null.