Interface PagingProvider<C,T>

Type Parameters:
C - connection type expected to handle the operations.
T - the type of the returned pages.

@MinMuleVersion("4.4") public interface PagingProvider<C,T>
This interface provides functionality for consuming a data feed in pages.

Instances should not be reused. Each execution of a paging operation should return different instances.

Implementing this interface does not guarantee thread safeness.

Since:
1.0
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    close(C connection)
    Closes this provider and all resources allocated by it, both local and remote.
    getPage(C connection)
    Returns the next page of items.
    getTotalResults(C connection)
    returns the total amount of items in the non-paged result set.
    default boolean
    Some systems require the same connection that obtained the first page to be used to fetch the subsequent ones.
  • Method Details

    • getPage

      List<T> getPage(C connection)
      Returns the next page of items. If the return value is an empty List then it means no more items are available
      Parameters:
      connection - The connection to be used to do the query.
      Returns:
      a populated List of elements of type Type, An empty List if no more items are available
    • getTotalResults

      Optional<Integer> getTotalResults(C connection)
      returns the total amount of items in the non-paged result set. In some scenarios, it might not be possible/convenient to actually retrieve this value, in such a cases an Optional.empty() value is returned.
      Parameters:
      connection - The connection to be used to do the query.
    • useStickyConnections

      default boolean useStickyConnections()
      Some systems require the same connection that obtained the first page to be used to fetch the subsequent ones. Although this is not the case of most APIs, this method allows to instruct the runtime to always feed the same connection into the getPage(Object) method.

      Keep in mind that if the operation is participating in a transaction, then the connection will become sticky no matter what this method says.

      This method is optional and defaults to false

      Returns:
      Whether all pages should be fetch using the same connection
    • close

      void close(C connection) throws org.mule.runtime.api.exception.MuleException
      Closes this provider and all resources allocated by it, both local and remote. This method should not try to also close the connection, the runtime will do that when appropriate.
      Parameters:
      connection - The connection to be used in order to correctly close the PagingProvider.
      Throws:
      org.mule.runtime.api.exception.MuleException - if there was an error closing the resources