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 org.mule.runtime.api.metadata.MediaType |
defaultMediaType |
protected org.mule.runtime.api.el.ExpressionLanguage |
expressionLanguage |
protected int |
responseTimeout |
| Constructor and Description |
|---|
RestPagingProvider(Function<RestConnection,RestRequestBuilder> 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 defaultMediaType,
int responseTimeout)
Creates a new instance
|
| Modifier and Type | Method and Description |
|---|---|
void |
close(RestConnection connection) |
protected abstract void |
configureRequest(RestRequestBuilder 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(org.mule.runtime.api.metadata.TypedValue<String> content,
String expression,
org.mule.runtime.api.metadata.DataType expectedOutputType,
HttpResponseAttributes httpResponseAttributes) |
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,
org.mule.runtime.api.metadata.TypedValue<String> rawPage,
HttpResponseAttributes responseAttributes)
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 defaultMediaType
public RestPagingProvider(Function<RestConnection,RestRequestBuilder> 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 defaultMediaType, 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 responsedefaultMediaType - the MediaType for the page items if the server doesn't specify oneresponseTimeout - the timeout for each requestprotected abstract void configureRequest(RestRequestBuilder requestBuilder)
requestFactory in order to configure the custom parameters that apply/requestBuilder - a RestRequestBuilderpublic 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, org.mule.runtime.api.metadata.TypedValue<String> rawPage, HttpResponseAttributes responseAttributes)
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.MuleExceptionprotected <T> org.mule.runtime.api.metadata.TypedValue<T> evaluate(org.mule.runtime.api.metadata.TypedValue<String> content, String expression, org.mule.runtime.api.metadata.DataType expectedOutputType, HttpResponseAttributes httpResponseAttributes)
Copyright © 2021. All rights reserved.