public abstract class RestPagingProvider extends Object implements org.mule.runtime.extension.api.runtime.streaming.PagingProvider<RestConnection,org.mule.runtime.api.metadata.TypedValue<String>>
Different APIs use different paging strategies which are tackled in implementations of this class. This class provides the basics as:
PagingProvider contract
Each item in the obtained page will be returned as an individual TypedValue, with the proper mime type and encoding
set.
| Modifier and Type | Field and Description |
|---|---|
protected String |
encoding |
protected org.mule.runtime.api.el.ExpressionLanguage |
expressionLanguage |
protected org.mule.runtime.api.metadata.MediaType |
mediaType |
protected int |
responseTimeout |
| Constructor and Description |
|---|
RestPagingProvider(Function<RestConnection,org.mule.runtime.http.api.domain.message.request.HttpRequestBuilder> requestFactory,
org.mule.runtime.api.el.ExpressionLanguage expressionLanguage,
org.mule.runtime.extension.api.runtime.streaming.StreamingHelper streamingHelper,
String payloadExpression,
org.mule.runtime.api.metadata.MediaType mediaType,
String encoding,
int responseTimeout)
Creates a new instance
|
| Modifier and Type | Method and Description |
|---|---|
void |
close(RestConnection connection) |
protected abstract void |
configureRequest(org.mule.runtime.http.api.domain.message.request.HttpRequestBuilder requestBuilder)
Depending on the paging strategy, different parameters or headers may need to be passed.
|
protected void |
doClose(RestConnection connection)
Invoked when
close(RestConnection) is invoked |
protected <T> org.mule.runtime.api.metadata.TypedValue<T> |
evaluate(String content,
String expression,
org.mule.runtime.api.metadata.DataType expectedOutputType) |
List<org.mule.runtime.api.metadata.TypedValue<String>> |
getPage(RestConnection connection) |
Optional<Integer> |
getTotalResults(RestConnection connection) |
protected void |
onPage(List<org.mule.runtime.api.metadata.TypedValue<String>> page,
String rawPage)
Invoked each time a page is obtained.
|
protected void |
stopPaging() |
protected final org.mule.runtime.api.el.ExpressionLanguage expressionLanguage
protected final int responseTimeout
protected final org.mule.runtime.api.metadata.MediaType mediaType
protected final String encoding
public RestPagingProvider(Function<RestConnection,org.mule.runtime.http.api.domain.message.request.HttpRequestBuilder> requestFactory, org.mule.runtime.api.el.ExpressionLanguage expressionLanguage, org.mule.runtime.extension.api.runtime.streaming.StreamingHelper streamingHelper, String payloadExpression, org.mule.runtime.api.metadata.MediaType mediaType, String encoding, int responseTimeout)
requestFactory - a Function to generate the request to be used on each page request. Each invocation should yield a different instanceexpressionLanguage - the app's ExpressionLanguagestreamingHelper - the StreamingHelper associated to the executing operationpayloadExpression - a DW expression to extract the data from the responsemediaType - the MediaType for the page itemsencoding - the encoding for the page itemsresponseTimeout - the timeout for each requestprotected abstract void configureRequest(org.mule.runtime.http.api.domain.message.request.HttpRequestBuilder requestBuilder)
requestFactory in order to configure the custom parameters that apply/requestBuilder - a HttpRequestBuilderpublic final List<org.mule.runtime.api.metadata.TypedValue<String>> getPage(RestConnection connection)
getPage in interface org.mule.runtime.extension.api.runtime.streaming.PagingProvider<RestConnection,org.mule.runtime.api.metadata.TypedValue<String>>public Optional<Integer> getTotalResults(RestConnection connection)
getTotalResults in interface org.mule.runtime.extension.api.runtime.streaming.PagingProvider<RestConnection,org.mule.runtime.api.metadata.TypedValue<String>>public final void close(RestConnection connection) throws org.mule.runtime.api.exception.MuleException
close in interface org.mule.runtime.extension.api.runtime.streaming.PagingProvider<RestConnection,org.mule.runtime.api.metadata.TypedValue<String>>org.mule.runtime.api.exception.MuleExceptionprotected void onPage(List<org.mule.runtime.api.metadata.TypedValue<String>> page, String rawPage)
page - the obtained pageprotected void stopPaging()
protected void doClose(RestConnection connection) throws org.mule.runtime.api.exception.MuleException
close(RestConnection) is invokedconnection - the current connectionorg.mule.runtime.api.exception.MuleExceptionCopyright © 2019. All rights reserved.