Package com.shri.restinpeace.internal
Class RequestExecutor
java.lang.Object
com.shri.restinpeace.internal.RequestExecutor
Builds and executes the actual HTTP request for a
@RestClient
method call, applying path/query/header/body parameters and registered
RequestInterceptors. Used internally by
RestClientInvocationHandler; not part
of the library's public API - use RIP
instead.
Genuinely separate concerns that grew large enough to earn their own
class are delegated out to package-private collaborators instead of
living here as private methods: response caching (CacheCoordinator),
@FormUrlEncoded body building (FormEncoder), the
@Retry loop (RetryExecutor), @Multipart body
building (MultipartEncoder), URL template resolution
(UrlResolver), response decoding (ResponseDecoder), and
interceptor dispatch (InterceptorDispatcher). Every method
generated code calls directly (see
com.shri.restinpeace.processor.RestClientProcessor) stays here
regardless, since generated code's field type is fixed as
RequestExecutor - those methods are thin delegates to the
collaborator that actually does the work.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a processor with no runtime base URL override.RequestExecutor(RipClientConfig config) Creates a processor from aRipClientConfig.RequestExecutor(String baseUrlOverride) Creates a processor that resolves every relative method URL againstbaseUrlOverrideinstead of the interface's@BaseUrl, for a base URL that's only known at runtime (e.g. per deployment environment). -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddCallAdapterFactory(CallAdapterFactory factory) Registers a globalCallAdapterFactory, unless this exact instance (by reference, notequals) is already registered.static voidaddInterceptor(RequestInterceptor interceptor) Registers a global interceptor applied to every request/response made through RIP.static voidRegisters a globalPaginatedCallAdapterFactory, unless this exact instance is already registered - identity-based, notequals-based, for the same reasonaddCallAdapterFactory(com.shri.restinpeace.CallAdapterFactory)is.voidappendFormField(List<String> formFields, String name, Object value) Appends one@Field/@FieldMapentry to a@FormUrlEncodedmethod's accumulated body.voidappendFormFieldMap(List<String> formFields, Map<?, ?> fieldMap) Also used directly by compile-time-generated code for a@FieldMapparameter.voidapplyDownloadMonitor(kong.unirest.HttpRequest<?> request, DownloadProgressListener listener) Also used directly by compile-time-generated code for aDownloadProgressListenerparameter.kong.unirest.HttpRequest<?>applyFormUrlEncodedBody(kong.unirest.HttpRequest<?> request, List<String> formFields) Finalizes a@FormUrlEncodedmethod's accumulatedname=valuepairs into the request's body - the generated-code counterpart of the reflective path's own finalization inapplyParams(kong.unirest.HttpRequest<?>, java.lang.reflect.Method, java.lang.Object[], com.shri.restinpeace.interceptor.RequestContext).kong.unirest.HttpRequest<?>applyGeneratedBodyIfPresent(kong.unirest.HttpRequest<?> request, Object value, RequestContext context) The generated-code counterpart ofapplyBody(kong.unirest.HttpRequest<?>, java.lang.reflect.Method, java.lang.Object, com.shri.restinpeace.interceptor.RequestContext), applying a@Bodyvalue only if it's non-null.voidapplyGeneratedHeaders(kong.unirest.HttpRequest<?> request, String[] headerEntries) The generated-code counterpart ofapplyFixedHeaders(kong.unirest.HttpRequest<?>, java.lang.reflect.Method), taking@Headers' entries as a literal.voidapplyHeaderMap(kong.unirest.HttpRequest<?> request, Map<?, ?> headerMap) Also used directly by compile-time-generated code for a@HeaderMapparameter.voidapplyIdempotencyKeyIfNeeded(kong.unirest.HttpRequest<?> request, boolean idempotent) Sends a freshly generatedIdempotency-Keyheader whenidempotentis true - called once per call, before any attempt is made, so every retry of that call (which re-sends the samerequestobject) carries the identical value.voidapplyPartMap(kong.unirest.MultipartBody multipartBody, Map<?, ?> partMap) Also used directly by compile-time-generated code for a@PartMapparameter.voidapplyPartValue(kong.unirest.MultipartBody multipartBody, String name, String fileName, Object value) Also used directly by compile-time-generated code for a@Partparameter.voidapplyQueryMap(kong.unirest.HttpRequest<?> request, Map<?, ?> queryMap) Also used directly by compile-time-generated code for a@QueryMapparameter.static voidapplyQueryValue(kong.unirest.HttpRequest<?> request, String name, Object value) Adds a query param, repeating it once per element - instead of once with a single mangledtoString()value - whenvalueis aCollection(e.g. aList<String>of tags producing?tag=a&tag=b), matching Unirest's ownqueryString(String, Collection)overload thatObject-typed dispatch would otherwise never reach.voidapplyUploadMonitor(kong.unirest.MultipartBody multipartBody, UploadProgressListener listener) Also used directly by compile-time-generated code for anUploadProgressListenerparameter.kong.unirest.MultipartBodybeginGeneratedMultipart(kong.unirest.HttpRequest<?> request) The generated-code counterpart of the reflective path's own((HttpRequestWithBody) request).multiPartContent()call for a@Multipartmethod - seeapplyParams(kong.unirest.HttpRequest<?>, java.lang.reflect.Method, java.lang.Object[], com.shri.restinpeace.interceptor.RequestContext).static voidRemoves all registeredCallAdapterFactorys.static voidRemoves all registered interceptors.static voidRemoves all registeredPaginatedCallAdapterFactorys.kong.unirest.HttpRequest<?>createGeneratedRequest(HTTPMethod httpMethod, String url, int connectMillis, int readMillis) Builds the request and applies its@Timeout(if any) - the generated-code counterpart ofcreateRequest(HTTPMethod, String)plusapplyTimeout(HttpRequest, Method), taking@Timeout's values as literals (or-1, its own "unset" default, for a method with none) instead of a reflective lookup.finishGeneratedAsync(kong.unirest.HttpRequest<?> request, RequestContext context, Class<?> returnType, Class<?> errorType, boolean hasRetry, int retryTimes, long retryDelayMillis, double retryBackoffMultiplier, double retryJitterFactor, int[] retryOnStatus) The generated-code counterpart ofprocessAsync(kong.unirest.HttpRequest<?>, java.lang.reflect.Method, java.lang.Object[], com.shri.restinpeace.interceptor.RequestContext)'s plain (non-byte[]/File/RipResponse) branch.CompletableFuture<byte[]>finishGeneratedAsyncBytes(kong.unirest.HttpRequest<?> request, RequestContext context, Class<?> errorType, boolean hasRetry, int retryTimes, long retryDelayMillis, double retryBackoffMultiplier, double retryJitterFactor, int[] retryOnStatus) The generated-code counterpart ofprocessAsync(kong.unirest.HttpRequest<?>, java.lang.reflect.Method, java.lang.Object[], com.shri.restinpeace.interceptor.RequestContext)'sbyte[]-inner-type branch.finishGeneratedAsyncFile(kong.unirest.HttpRequest<?> request, RequestContext context, File destination, Class<?> errorType, boolean hasRetry, int retryTimes, long retryDelayMillis, double retryBackoffMultiplier, double retryJitterFactor, int[] retryOnStatus) The generated-code counterpart ofprocessAsync(kong.unirest.HttpRequest<?>, java.lang.reflect.Method, java.lang.Object[], com.shri.restinpeace.interceptor.RequestContext)'sFile-inner-type branch.finishGeneratedAsyncRipResponse(kong.unirest.HttpRequest<?> request, RequestContext context, Class<?> innerType, Class<?> errorType, boolean hasRetry, int retryTimes, long retryDelayMillis, double retryBackoffMultiplier, double retryJitterFactor, int[] retryOnStatus) The generated-code counterpart ofprocessAsync(kong.unirest.HttpRequest<?>, java.lang.reflect.Method, java.lang.Object[], com.shri.restinpeace.interceptor.RequestContext)'sRipResponse<T>-inner-type branch for aString/POJOT.CompletableFuture<RipResponse<byte[]>>finishGeneratedAsyncRipResponseBytes(kong.unirest.HttpRequest<?> request, RequestContext context, Class<?> errorType, boolean hasRetry, int retryTimes, long retryDelayMillis, double retryBackoffMultiplier, double retryJitterFactor, int[] retryOnStatus) Thebyte[]-wrapped counterpart offinishGeneratedAsyncRipResponse(kong.unirest.HttpRequest<?>, com.shri.restinpeace.interceptor.RequestContext, java.lang.Class<?>, java.lang.Class<?>, boolean, int, long, double, double, int[]), for aCompletableFuture<RipResponse<byte[]>>return type.finishGeneratedSync(kong.unirest.HttpRequest<?> request, RequestContext context, Class<?> returnType, Class<?> errorType, boolean hasRetry, int retryTimes, long retryDelayMillis, double retryBackoffMultiplier, double retryJitterFactor, int[] retryOnStatus) Executes and decodes a sync request whose return type isvoid,String, or a POJO - the generated-code counterpart of the plain (non-byte[]/File/RipResponse/CompletableFuture) branch ofprocessRestRequest(java.lang.reflect.Method, com.shri.restinpeace.constant.HTTPMethod, java.lang.Object[]), applying registered interceptors first.byte[]finishGeneratedSyncBytes(kong.unirest.HttpRequest<?> request, RequestContext context, Class<?> errorType, boolean hasRetry, int retryTimes, long retryDelayMillis, double retryBackoffMultiplier, double retryJitterFactor, int[] retryOnStatus) The generated-code counterpart ofprocessRestRequest(java.lang.reflect.Method, com.shri.restinpeace.constant.HTTPMethod, java.lang.Object[])'sbyte[]-return branch.finishGeneratedSyncFile(kong.unirest.HttpRequest<?> request, RequestContext context, File destination, Class<?> errorType, boolean hasRetry, int retryTimes, long retryDelayMillis, double retryBackoffMultiplier, double retryJitterFactor, int[] retryOnStatus) The generated-code counterpart ofprocessRestRequest(java.lang.reflect.Method, com.shri.restinpeace.constant.HTTPMethod, java.lang.Object[])'sFile-return branch.RipResponse<?>finishGeneratedSyncRipResponse(kong.unirest.HttpRequest<?> request, RequestContext context, Class<?> innerType, Class<?> errorType, boolean hasRetry, int retryTimes, long retryDelayMillis, double retryBackoffMultiplier, double retryJitterFactor, int[] retryOnStatus) The generated-code counterpart ofprocessRestRequest(java.lang.reflect.Method, com.shri.restinpeace.constant.HTTPMethod, java.lang.Object[])'sRipResponse<T>-return branch for aString/POJOT-innerTypeisT.RipResponse<byte[]>finishGeneratedSyncRipResponseBytes(kong.unirest.HttpRequest<?> request, RequestContext context, Class<?> errorType, boolean hasRetry, int retryTimes, long retryDelayMillis, double retryBackoffMultiplier, double retryJitterFactor, int[] retryOnStatus) Thebyte[]-wrapped counterpart offinishGeneratedSyncRipResponse(kong.unirest.HttpRequest<?>, com.shri.restinpeace.interceptor.RequestContext, java.lang.Class<?>, java.lang.Class<?>, boolean, int, long, double, double, int[]), for aRipResponse<byte[]>return type.voidmarkNoCache(RequestContext context) Marks the current call as never cacheable, regardless of anyCacheconfigured for its client - the generated-code counterpart of the reflective path's own@NoCachecheck.processRestRequest(Method method, HTTPMethod httpMethod, Object[] args) Executes the given@RestClientmethod call and returns its result.static voidRemoves one previously registeredCallAdapterFactoryby identity, notequals- seeaddCallAdapterFactory(com.shri.restinpeace.CallAdapterFactory)'s own reasoning for why.static voidremoveInterceptor(RequestInterceptor interceptor) Removes one previously registered global interceptor by identity.static voidRemoves one previously registeredPaginatedCallAdapterFactoryby identity.static StringrequireUrlParam(Object value, String methodDescription) The generated-code counterpart of a method annotated@Url:valueused verbatim as the request URL, bypassingresolveGeneratedUrl(java.lang.String, java.lang.String, java.lang.String[], java.lang.Object[])(and everything it would otherwise resolve -@BaseUrl, a runtime base URL,@PathParam) entirely, mirroringUrlResolver's ownresolveUrlParam.static Optional<CallAdapter<?>>resolveCallAdapter(Method method) Consults every registeredCallAdapterFactory, in registration order, returning the first non-empty answer - seeCallAdapterFactory.get(Method).resolveGeneratedUrl(String urlTemplate, String interfaceBaseUrl, String[] pathParamNames, Object[] pathParamValues) Resolves a generated method's request URL from its (possibly relative) URL template, substituting@PathParams - the generated-code counterpart ofUrlResolver's ownresolveUrl, used when the method has no@Urlparameter (which bypasses this entirely; seerequireUrlParam(java.lang.Object, java.lang.String)).static Optional<PaginatedCallAdapter<?>>resolvePaginatedCallAdapter(Method method) Consults every registeredPaginatedCallAdapterFactory, in registration order, returning the first non-empty answer - the pagination-aware counterpart ofresolveCallAdapter(java.lang.reflect.Method).resolveValue(Object argValue, boolean required, String defaultValue, String paramName) Applies a query param or header value that has@QueryParam/@HeaderParam'srequired/defaultValuesemantics - shared by the reflective path'sapplyParams(kong.unirest.HttpRequest<?>, java.lang.reflect.Method, java.lang.Object[], com.shri.restinpeace.interceptor.RequestContext)and generated code, which calls this directly then applies the result itself (applyQueryValue(kong.unirest.HttpRequest<?>, java.lang.String, java.lang.Object)for a query param;request.headerReplace(name, String.valueOf(value))- a plain public Unirest call - for a header param, so no separate "generated header param" method is needed).static voidsetDefaultCache(Cache cache) Sets the shared default cache.static voidsetDefaultCacheKeyIncludesQueryString(boolean includeQueryString) Sets whether the cache key includes the request's query string.static voidsetDefaultNegativeCacheTtlMillis(long ttlMillis) Sets the shared default negative-cache TTL.static voidThe non-RIP-facing half ofRIP.useDaemonThreadsForAsync()- living here (rather than directly inRIP) so the daemon-thread setting can also be applied to aRipClientConfig-backed client's own dedicatedUnirestInstanceinbuildInstance(com.shri.restinpeace.RipClientConfig), not just the shared staticUnirestclient.
-
Constructor Details
-
RequestExecutor
public RequestExecutor()Creates a processor with no runtime base URL override. Cheap and stateless beyond the shared interceptor registry. -
RequestExecutor
Creates a processor that resolves every relative method URL againstbaseUrlOverrideinstead of the interface's@BaseUrl, for a base URL that's only known at runtime (e.g. per deployment environment). An absolute method URL still ignores this, same as it ignores@BaseUrl. Requests still go through the shared staticUnirestclient.- Parameters:
baseUrlOverride- the runtime base URL, ornullto fall back to the interface's@BaseUrl
-
RequestExecutor
Creates a processor from aRipClientConfig. Requests go through a dedicatedUnirestInstance- instead of the shared staticUnirestclient - wheneverconfigsets a connect/read timeout, a proxy, or anobjectMapper, since those settings live on a client instance, not per request.- Parameters:
config- the per-client settings
-
-
Method Details
-
useDaemonThreadsForAsync
public static void useDaemonThreadsForAsync()The non-RIP-facing half ofRIP.useDaemonThreadsForAsync()- living here (rather than directly inRIP) so the daemon-thread setting can also be applied to aRipClientConfig-backed client's own dedicatedUnirestInstanceinbuildInstance(com.shri.restinpeace.RipClientConfig), not just the shared staticUnirestclient. Sets a static flag first so everyRequestExecutor(RipClientConfig)constructed from this point on picks it up inbuildInstance(com.shri.restinpeace.RipClientConfig)too - a config'd client built *before* this is called keeps its own async client as constructed, the same "call once at startup, before building any client" requirement every other global RIP setting already has. -
addInterceptor
Registers a global interceptor applied to every request/response made through RIP. SeeRIP.addInterceptor(RequestInterceptor).- Parameters:
interceptor- the interceptor to register
-
removeInterceptor
Removes one previously registered global interceptor by identity. SeeRIP.removeInterceptor(RequestInterceptor).- Parameters:
interceptor- the interceptor to remove
-
clearInterceptors
public static void clearInterceptors()Removes all registered interceptors. -
addCallAdapterFactory
Registers a globalCallAdapterFactory, unless this exact instance (by reference, notequals) is already registered. SeeRIP.addCallAdapterFactory(CallAdapterFactory). Deliberately identity-based, notequals-based likeCopyOnWriteArrayList.addIfAbsent(E): two distinct factory instances that happen to compare equal (a factory class overridingequals) must both still be registered, or the second one's claims would be silently lost.- Parameters:
factory- the factory to register
-
removeCallAdapterFactory
Removes one previously registeredCallAdapterFactoryby identity, notequals- seeaddCallAdapterFactory(com.shri.restinpeace.CallAdapterFactory)'s own reasoning for why. SeeRIP.removeCallAdapterFactory(CallAdapterFactory).- Parameters:
factory- the factory to remove
-
clearCallAdapterFactories
public static void clearCallAdapterFactories()Removes all registeredCallAdapterFactorys. -
resolveCallAdapter
Consults every registeredCallAdapterFactory, in registration order, returning the first non-empty answer - seeCallAdapterFactory.get(Method). Public (not package-private, unlike most of this registry) soReflectiveRestClientValidatorcan validate a claimed adapter'sCallAdapter.responseBodyType()atRIP.getClient(...)time - the same cross-package needPaginationStrategyresolution already has.- Parameters:
method- the interface method being dispatched or validated- Returns:
- the first registered factory's non-empty answer, or
Optional.empty()if none claimsmethod
-
addPaginatedCallAdapterFactory
Registers a globalPaginatedCallAdapterFactory, unless this exact instance is already registered - identity-based, notequals-based, for the same reasonaddCallAdapterFactory(com.shri.restinpeace.CallAdapterFactory)is. SeeRIP.addPaginatedCallAdapterFactory(PaginatedCallAdapterFactory).- Parameters:
factory- the factory to register
-
removePaginatedCallAdapterFactory
Removes one previously registeredPaginatedCallAdapterFactoryby identity. SeeRIP.removePaginatedCallAdapterFactory(PaginatedCallAdapterFactory).- Parameters:
factory- the factory to remove
-
clearPaginatedCallAdapterFactories
public static void clearPaginatedCallAdapterFactories()Removes all registeredPaginatedCallAdapterFactorys. -
resolvePaginatedCallAdapter
Consults every registeredPaginatedCallAdapterFactory, in registration order, returning the first non-empty answer - the pagination-aware counterpart ofresolveCallAdapter(java.lang.reflect.Method). Public for the same cross-package validation need.- Parameters:
method- the@Paginatedmethod being dispatched or validated- Returns:
- the first registered factory's non-empty answer, or
Optional.empty()if none claimsmethod
-
setDefaultCache
Sets the shared default cache. SeeRIP.setCache(Cache).- Parameters:
cache- the shared default cache, ornullto disable it
-
setDefaultCacheKeyIncludesQueryString
public static void setDefaultCacheKeyIncludesQueryString(boolean includeQueryString) Sets whether the cache key includes the request's query string. SeeRIP.setCacheKeyIncludesQueryString(boolean).- Parameters:
includeQueryString- whether the cache key includes the query string
-
setDefaultNegativeCacheTtlMillis
public static void setDefaultNegativeCacheTtlMillis(long ttlMillis) Sets the shared default negative-cache TTL. SeeRIP.setNegativeCacheTtlMillis(long).- Parameters:
ttlMillis- how long a confirmed404stays negatively cached, in milliseconds; must be positive
-
markNoCache
Marks the current call as never cacheable, regardless of anyCacheconfigured for its client - the generated-code counterpart of the reflective path's own@NoCachecheck. Also used directly by compile-time-generated code for a@NoCachemethod.- Parameters:
context- the call's context, as passed to every otherfinishGenerated*/applyGenerated*method
-
processRestRequest
Executes the given@RestClientmethod call and returns its result.- Parameters:
method- the interface method that was calledhttpMethod- the HTTP method it maps toargs- the call's argument values, in declaration order- Returns:
- the call's result: the raw body, a deserialized object, either
wrapped in a
RipResponsefor its status/headers, aCompletableFutureof any of those, ornullforvoidmethods
-
resolveGeneratedUrl
public String resolveGeneratedUrl(String urlTemplate, String interfaceBaseUrl, String[] pathParamNames, Object[] pathParamValues) Resolves a generated method's request URL from its (possibly relative) URL template, substituting@PathParams - the generated-code counterpart ofUrlResolver's ownresolveUrl, used when the method has no@Urlparameter (which bypasses this entirely; seerequireUrlParam(java.lang.Object, java.lang.String)).- Parameters:
urlTemplate- the method's declared URL, possibly relative and/or containing{name}path param placeholdersinterfaceBaseUrl- the interface's@BaseUrl, ornullif it has nonepathParamNames- the names of every@PathParamon the methodpathParamValues- the corresponding argument values, in the same order- Returns:
- the fully-resolved request URL
-
requireUrlParam
The generated-code counterpart of a method annotated@Url:valueused verbatim as the request URL, bypassingresolveGeneratedUrl(java.lang.String, java.lang.String, java.lang.String[], java.lang.Object[])(and everything it would otherwise resolve -@BaseUrl, a runtime base URL,@PathParam) entirely, mirroringUrlResolver's ownresolveUrlParam.- Parameters:
value- the@Urlparameter's argument valuemethodDescription- the interface and method name, for the exception message ifvalueis missing- Returns:
valueas aString
-
createGeneratedRequest
public kong.unirest.HttpRequest<?> createGeneratedRequest(HTTPMethod httpMethod, String url, int connectMillis, int readMillis) Builds the request and applies its@Timeout(if any) - the generated-code counterpart ofcreateRequest(HTTPMethod, String)plusapplyTimeout(HttpRequest, Method), taking@Timeout's values as literals (or-1, its own "unset" default, for a method with none) instead of a reflective lookup.- Parameters:
httpMethod- the HTTP method to issueurl- the fully-resolved request URLconnectMillis-@Timeout'sconnectMillis, or-1if unsetreadMillis-@Timeout'sreadMillis, or-1if unset- Returns:
- the built, not-yet-executed request
-
applyGeneratedHeaders
The generated-code counterpart ofapplyFixedHeaders(kong.unirest.HttpRequest<?>, java.lang.reflect.Method), taking@Headers' entries as a literal.- Parameters:
request- the request to apply the headers toheaderEntries-@Headers'"Name: Value"entries
-
resolveValue
public Object resolveValue(Object argValue, boolean required, String defaultValue, String paramName) Applies a query param or header value that has@QueryParam/@HeaderParam'srequired/defaultValuesemantics - shared by the reflective path'sapplyParams(kong.unirest.HttpRequest<?>, java.lang.reflect.Method, java.lang.Object[], com.shri.restinpeace.interceptor.RequestContext)and generated code, which calls this directly then applies the result itself (applyQueryValue(kong.unirest.HttpRequest<?>, java.lang.String, java.lang.Object)for a query param;request.headerReplace(name, String.valueOf(value))- a plain public Unirest call - for a header param, so no separate "generated header param" method is needed).- Parameters:
argValue- the parameter's argument value, possiblynullrequired-@QueryParam/@HeaderParam'srequireddefaultValue-@QueryParam/@HeaderParam'sdefaultValueparamName- the query/header name, for the exception message ifrequiredand no value or default is available- Returns:
argValueif non-null, elsedefaultValueif set, elsenull(or a thrown exception ifrequired)
-
applyGeneratedBodyIfPresent
public kong.unirest.HttpRequest<?> applyGeneratedBodyIfPresent(kong.unirest.HttpRequest<?> request, Object value, RequestContext context) The generated-code counterpart ofapplyBody(kong.unirest.HttpRequest<?>, java.lang.reflect.Method, java.lang.Object, com.shri.restinpeace.interceptor.RequestContext), applying a@Bodyvalue only if it's non-null.- Parameters:
request- the request to apply the body tovalue- the@Bodyparameter's argument value, ornullcontext- this call's context - the body, once known, is stashed on it viaRequestContext.setBody(java.lang.String)for an interceptor to read- Returns:
request, with the body applied ifvaluewas non-null
-
finishGeneratedSync
public Object finishGeneratedSync(kong.unirest.HttpRequest<?> request, RequestContext context, Class<?> returnType, Class<?> errorType, boolean hasRetry, int retryTimes, long retryDelayMillis, double retryBackoffMultiplier, double retryJitterFactor, int[] retryOnStatus) Executes and decodes a sync request whose return type isvoid,String, or a POJO - the generated-code counterpart of the plain (non-byte[]/File/RipResponse/CompletableFuture) branch ofprocessRestRequest(java.lang.reflect.Method, com.shri.restinpeace.constant.HTTPMethod, java.lang.Object[]), applying registered interceptors first.- Parameters:
request- the request to executecontext- the interceptor/logging context for this callreturnType- the method's declared return type to decode intoerrorType- the class to decode a non-2xx response's body into, ornullfor nonehasRetry- whether the method is annotated@RetryretryTimes-@Retry'stimes, meaningless ifhasRetryisfalseretryDelayMillis-@Retry'sdelayMillis, meaningless ifhasRetryisfalseretryBackoffMultiplier-@Retry'sbackoffMultiplier, meaningless ifhasRetryisfalseretryJitterFactor-@Retry'sjitterFactor, meaningless ifhasRetryisfalseretryOnStatus-@Retry'sretryOnStatus, meaningless ifhasRetryisfalse- Returns:
- the decoded body, or
nullfor avoidmethod
-
finishGeneratedSyncBytes
public byte[] finishGeneratedSyncBytes(kong.unirest.HttpRequest<?> request, RequestContext context, Class<?> errorType, boolean hasRetry, int retryTimes, long retryDelayMillis, double retryBackoffMultiplier, double retryJitterFactor, int[] retryOnStatus) The generated-code counterpart ofprocessRestRequest(java.lang.reflect.Method, com.shri.restinpeace.constant.HTTPMethod, java.lang.Object[])'sbyte[]-return branch.- Parameters:
request- the request to executecontext- the interceptor/logging context for this callerrorType- the class to decode a non-2xx response's body into, ornullfor nonehasRetry- whether the method is annotated@RetryretryTimes-@Retry'stimes, meaningless ifhasRetryisfalseretryDelayMillis-@Retry'sdelayMillis, meaningless ifhasRetryisfalseretryBackoffMultiplier-@Retry'sbackoffMultiplier, meaningless ifhasRetryisfalseretryJitterFactor-@Retry'sjitterFactor, meaningless ifhasRetryisfalseretryOnStatus-@Retry'sretryOnStatus, meaningless ifhasRetryisfalse- Returns:
- the response body's raw bytes
-
finishGeneratedSyncFile
public File finishGeneratedSyncFile(kong.unirest.HttpRequest<?> request, RequestContext context, File destination, Class<?> errorType, boolean hasRetry, int retryTimes, long retryDelayMillis, double retryBackoffMultiplier, double retryJitterFactor, int[] retryOnStatus) The generated-code counterpart ofprocessRestRequest(java.lang.reflect.Method, com.shri.restinpeace.constant.HTTPMethod, java.lang.Object[])'sFile-return branch.- Parameters:
request- the request to executecontext- the interceptor/logging context for this calldestination- the file to write the response body intoerrorType- the class to decode a non-2xx response's body into, ornullfor nonehasRetry- whether the method is annotated@RetryretryTimes-@Retry'stimes, meaningless ifhasRetryisfalseretryDelayMillis-@Retry'sdelayMillis, meaningless ifhasRetryisfalseretryBackoffMultiplier-@Retry'sbackoffMultiplier, meaningless ifhasRetryisfalseretryJitterFactor-@Retry'sjitterFactor, meaningless ifhasRetryisfalseretryOnStatus-@Retry'sretryOnStatus, meaningless ifhasRetryisfalse- Returns:
destination, with the response body written into it
-
finishGeneratedSyncRipResponse
public RipResponse<?> finishGeneratedSyncRipResponse(kong.unirest.HttpRequest<?> request, RequestContext context, Class<?> innerType, Class<?> errorType, boolean hasRetry, int retryTimes, long retryDelayMillis, double retryBackoffMultiplier, double retryJitterFactor, int[] retryOnStatus) The generated-code counterpart ofprocessRestRequest(java.lang.reflect.Method, com.shri.restinpeace.constant.HTTPMethod, java.lang.Object[])'sRipResponse<T>-return branch for aString/POJOT-innerTypeisT. Erased toRipResponse<?>; generated code casts the result to its own exactRipResponse<T>return type.- Parameters:
request- the request to executecontext- the interceptor/logging context for this callinnerType- the class to decodeTintoerrorType- the class to decode a non-2xx response's body into, ornullfor nonehasRetry- whether the method is annotated@RetryretryTimes-@Retry'stimes, meaningless ifhasRetryisfalseretryDelayMillis-@Retry'sdelayMillis, meaningless ifhasRetryisfalseretryBackoffMultiplier-@Retry'sbackoffMultiplier, meaningless ifhasRetryisfalseretryJitterFactor-@Retry'sjitterFactor, meaningless ifhasRetryisfalseretryOnStatus-@Retry'sretryOnStatus, meaningless ifhasRetryisfalse- Returns:
- the response wrapped with its status code and headers
-
finishGeneratedSyncRipResponseBytes
public RipResponse<byte[]> finishGeneratedSyncRipResponseBytes(kong.unirest.HttpRequest<?> request, RequestContext context, Class<?> errorType, boolean hasRetry, int retryTimes, long retryDelayMillis, double retryBackoffMultiplier, double retryJitterFactor, int[] retryOnStatus) Thebyte[]-wrapped counterpart offinishGeneratedSyncRipResponse(kong.unirest.HttpRequest<?>, com.shri.restinpeace.interceptor.RequestContext, java.lang.Class<?>, java.lang.Class<?>, boolean, int, long, double, double, int[]), for aRipResponse<byte[]>return type.- Parameters:
request- the request to executecontext- the interceptor/logging context for this callerrorType- the class to decode a non-2xx response's body into, ornullfor nonehasRetry- whether the method is annotated@RetryretryTimes-@Retry'stimes, meaningless ifhasRetryisfalseretryDelayMillis-@Retry'sdelayMillis, meaningless ifhasRetryisfalseretryBackoffMultiplier-@Retry'sbackoffMultiplier, meaningless ifhasRetryisfalseretryJitterFactor-@Retry'sjitterFactor, meaningless ifhasRetryisfalseretryOnStatus-@Retry'sretryOnStatus, meaningless ifhasRetryisfalse- Returns:
- the response's raw bytes, wrapped with its status code and headers
-
finishGeneratedAsync
public CompletableFuture<?> finishGeneratedAsync(kong.unirest.HttpRequest<?> request, RequestContext context, Class<?> returnType, Class<?> errorType, boolean hasRetry, int retryTimes, long retryDelayMillis, double retryBackoffMultiplier, double retryJitterFactor, int[] retryOnStatus) The generated-code counterpart ofprocessAsync(kong.unirest.HttpRequest<?>, java.lang.reflect.Method, java.lang.Object[], com.shri.restinpeace.interceptor.RequestContext)'s plain (non-byte[]/File/RipResponse) branch.- Parameters:
request- the request to executecontext- the interceptor/logging context for this callreturnType- the class to decode into, once the future completeserrorType- the class to decode a non-2xx response's body into, ornullfor nonehasRetry- whether the method is annotated@RetryretryTimes-@Retry'stimes, meaningless ifhasRetryisfalseretryDelayMillis-@Retry'sdelayMillis, meaningless ifhasRetryisfalseretryBackoffMultiplier-@Retry'sbackoffMultiplier, meaningless ifhasRetryisfalseretryJitterFactor-@Retry'sjitterFactor, meaningless ifhasRetryisfalseretryOnStatus-@Retry'sretryOnStatus, meaningless ifhasRetryisfalse- Returns:
- a future of the decoded body, or of
nullfor avoidmethod
-
finishGeneratedAsyncBytes
public CompletableFuture<byte[]> finishGeneratedAsyncBytes(kong.unirest.HttpRequest<?> request, RequestContext context, Class<?> errorType, boolean hasRetry, int retryTimes, long retryDelayMillis, double retryBackoffMultiplier, double retryJitterFactor, int[] retryOnStatus) The generated-code counterpart ofprocessAsync(kong.unirest.HttpRequest<?>, java.lang.reflect.Method, java.lang.Object[], com.shri.restinpeace.interceptor.RequestContext)'sbyte[]-inner-type branch.- Parameters:
request- the request to executecontext- the interceptor/logging context for this callerrorType- the class to decode a non-2xx response's body into, ornullfor nonehasRetry- whether the method is annotated@RetryretryTimes-@Retry'stimes, meaningless ifhasRetryisfalseretryDelayMillis-@Retry'sdelayMillis, meaningless ifhasRetryisfalseretryBackoffMultiplier-@Retry'sbackoffMultiplier, meaningless ifhasRetryisfalseretryJitterFactor-@Retry'sjitterFactor, meaningless ifhasRetryisfalseretryOnStatus-@Retry'sretryOnStatus, meaningless ifhasRetryisfalse- Returns:
- a future of the response body's raw bytes
-
finishGeneratedAsyncFile
public CompletableFuture<File> finishGeneratedAsyncFile(kong.unirest.HttpRequest<?> request, RequestContext context, File destination, Class<?> errorType, boolean hasRetry, int retryTimes, long retryDelayMillis, double retryBackoffMultiplier, double retryJitterFactor, int[] retryOnStatus) The generated-code counterpart ofprocessAsync(kong.unirest.HttpRequest<?>, java.lang.reflect.Method, java.lang.Object[], com.shri.restinpeace.interceptor.RequestContext)'sFile-inner-type branch.- Parameters:
request- the request to executecontext- the interceptor/logging context for this calldestination- the file to write the response body intoerrorType- the class to decode a non-2xx response's body into, ornullfor nonehasRetry- whether the method is annotated@RetryretryTimes-@Retry'stimes, meaningless ifhasRetryisfalseretryDelayMillis-@Retry'sdelayMillis, meaningless ifhasRetryisfalseretryBackoffMultiplier-@Retry'sbackoffMultiplier, meaningless ifhasRetryisfalseretryJitterFactor-@Retry'sjitterFactor, meaningless ifhasRetryisfalseretryOnStatus-@Retry'sretryOnStatus, meaningless ifhasRetryisfalse- Returns:
- a future of
destination, with the response body written into it
-
finishGeneratedAsyncRipResponse
public CompletableFuture<RipResponse<?>> finishGeneratedAsyncRipResponse(kong.unirest.HttpRequest<?> request, RequestContext context, Class<?> innerType, Class<?> errorType, boolean hasRetry, int retryTimes, long retryDelayMillis, double retryBackoffMultiplier, double retryJitterFactor, int[] retryOnStatus) The generated-code counterpart ofprocessAsync(kong.unirest.HttpRequest<?>, java.lang.reflect.Method, java.lang.Object[], com.shri.restinpeace.interceptor.RequestContext)'sRipResponse<T>-inner-type branch for aString/POJOT. Erased toCompletableFuture<RipResponse<?>>; generated code casts the result to its own exactCompletableFuture<RipResponse<T>>return type.- Parameters:
request- the request to executecontext- the interceptor/logging context for this callinnerType- the class to decodeTintoerrorType- the class to decode a non-2xx response's body into, ornullfor nonehasRetry- whether the method is annotated@RetryretryTimes-@Retry'stimes, meaningless ifhasRetryisfalseretryDelayMillis-@Retry'sdelayMillis, meaningless ifhasRetryisfalseretryBackoffMultiplier-@Retry'sbackoffMultiplier, meaningless ifhasRetryisfalseretryJitterFactor-@Retry'sjitterFactor, meaningless ifhasRetryisfalseretryOnStatus-@Retry'sretryOnStatus, meaningless ifhasRetryisfalse- Returns:
- a future of the response wrapped with its status code and headers
-
finishGeneratedAsyncRipResponseBytes
public CompletableFuture<RipResponse<byte[]>> finishGeneratedAsyncRipResponseBytes(kong.unirest.HttpRequest<?> request, RequestContext context, Class<?> errorType, boolean hasRetry, int retryTimes, long retryDelayMillis, double retryBackoffMultiplier, double retryJitterFactor, int[] retryOnStatus) Thebyte[]-wrapped counterpart offinishGeneratedAsyncRipResponse(kong.unirest.HttpRequest<?>, com.shri.restinpeace.interceptor.RequestContext, java.lang.Class<?>, java.lang.Class<?>, boolean, int, long, double, double, int[]), for aCompletableFuture<RipResponse<byte[]>>return type.- Parameters:
request- the request to executecontext- the interceptor/logging context for this callerrorType- the class to decode a non-2xx response's body into, ornullfor nonehasRetry- whether the method is annotated@RetryretryTimes-@Retry'stimes, meaningless ifhasRetryisfalseretryDelayMillis-@Retry'sdelayMillis, meaningless ifhasRetryisfalseretryBackoffMultiplier-@Retry'sbackoffMultiplier, meaningless ifhasRetryisfalseretryJitterFactor-@Retry'sjitterFactor, meaningless ifhasRetryisfalseretryOnStatus-@Retry'sretryOnStatus, meaningless ifhasRetryisfalse- Returns:
- a future of the response's raw bytes, wrapped with its status code and headers
-
applyIdempotencyKeyIfNeeded
public void applyIdempotencyKeyIfNeeded(kong.unirest.HttpRequest<?> request, boolean idempotent) Sends a freshly generatedIdempotency-Keyheader whenidempotentis true - called once per call, before any attempt is made, so every retry of that call (which re-sends the samerequestobject) carries the identical value. Also used directly by compile-time-generated code for a@Retry(idempotent = true)method.- Parameters:
request- the request to add the header toidempotent-@Retry'sidempotent
-
applyDownloadMonitor
public void applyDownloadMonitor(kong.unirest.HttpRequest<?> request, DownloadProgressListener listener) Also used directly by compile-time-generated code for aDownloadProgressListenerparameter.- Parameters:
request- the request to monitorlistener- the listener to notify, ornullfor none
-
applyUploadMonitor
public void applyUploadMonitor(kong.unirest.MultipartBody multipartBody, UploadProgressListener listener) Also used directly by compile-time-generated code for anUploadProgressListenerparameter.- Parameters:
multipartBody- the multipart body to monitorlistener- the listener to notify (callers only invoke this once a non-nulllistener argument is confirmed)
-
beginGeneratedMultipart
public kong.unirest.MultipartBody beginGeneratedMultipart(kong.unirest.HttpRequest<?> request) The generated-code counterpart of the reflective path's own((HttpRequestWithBody) request).multiPartContent()call for a@Multipartmethod - seeapplyParams(kong.unirest.HttpRequest<?>, java.lang.reflect.Method, java.lang.Object[], com.shri.restinpeace.interceptor.RequestContext).- Parameters:
request- the request to convert to a multipart body- Returns:
request, as aMultipartBody
-
applyPartMap
Also used directly by compile-time-generated code for a@PartMapparameter.- Parameters:
multipartBody- the multipart body to add parts topartMap- the@PartMapparameter's argument value; anull-valued entry is skipped
-
applyPartValue
public void applyPartValue(kong.unirest.MultipartBody multipartBody, String name, String fileName, Object value) Also used directly by compile-time-generated code for a@Partparameter.- Parameters:
multipartBody- the multipart body to add the part toname- the part's field namefileName- the file name to send aFile/byte[]/InputStreampart under, or empty to usename(or, for aFile, its own name)value- the part's value - aString,File,byte[],InputStream, or aPartValuewrapping one of those with its own file name
-
appendFormFieldMap
Also used directly by compile-time-generated code for a@FieldMapparameter.- Parameters:
formFields- the accumulator to append encodedname=valuepairs tofieldMap- the@FieldMapparameter's argument value; anull-valued entry is skipped
-
appendFormField
Appends one@Field/@FieldMapentry to a@FormUrlEncodedmethod's accumulated body. Also used directly by compile-time-generated code for a@Fieldparameter.- Parameters:
formFields- the accumulator to append encodedname=valuepairs toname- the field namevalue- the field's value; aCollectionis repeated once per non-nullelement, any other value once viaString.valueOf(...)
-
applyFormUrlEncodedBody
public kong.unirest.HttpRequest<?> applyFormUrlEncodedBody(kong.unirest.HttpRequest<?> request, List<String> formFields) Finalizes a@FormUrlEncodedmethod's accumulatedname=valuepairs into the request's body - the generated-code counterpart of the reflective path's own finalization inapplyParams(kong.unirest.HttpRequest<?>, java.lang.reflect.Method, java.lang.Object[], com.shri.restinpeace.interceptor.RequestContext).- Parameters:
request- the request to apply the encoded body toformFields- the accumulated encodedname=valuepairs- Returns:
request, with the encoded body applied
-
applyQueryMap
Also used directly by compile-time-generated code for a@QueryMapparameter.- Parameters:
request- the request to add query params toqueryMap- the@QueryMapparameter's argument value; anull-valued entry is skipped
-
applyQueryValue
Adds a query param, repeating it once per element - instead of once with a single mangledtoString()value - whenvalueis aCollection(e.g. aList<String>of tags producing?tag=a&tag=b), matching Unirest's ownqueryString(String, Collection)overload thatObject-typed dispatch would otherwise never reach. Also used directly by compile-time-generated code for a@QueryParam.- Parameters:
request- the request to add the query param toname- the query param's namevalue- the query param's value; aCollectionis repeated once per element, any other value once viatoString()
-
applyHeaderMap
Also used directly by compile-time-generated code for a@HeaderMapparameter.- Parameters:
request- the request to add headers toheaderMap- the@HeaderMapparameter's argument value; anull-valued entry is skipped. ACollectionvalue adds one header per element under the same name, matchingapplyQueryValue(kong.unirest.HttpRequest<?>, java.lang.String, java.lang.Object)'s own handling of aCollectionvalue, instead of one header with a single mangledtoString()value.
-