Class CachingResourcesPolicy
- java.lang.Object
-
- io.apiman.gateway.engine.policies.AbstractMappedPolicy<C>
-
- io.apiman.gateway.engine.policies.AbstractMappedDataPolicy<CachingResourcesConfig>
-
- io.apiman.gateway.engine.policies.CachingResourcesPolicy
-
- All Implemented Interfaces:
IDataPolicy,IPolicy
public class CachingResourcesPolicy extends AbstractMappedDataPolicy<CachingResourcesConfig> implements IDataPolicy
Policy that enables caching for back-end APIs responses.- Author:
- benjaminkihm@scheer-group.com
-
-
Constructor Summary
Constructors Constructor Description CachingResourcesPolicy()Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voiddoApply(ApiRequest request, IPolicyContext context, CachingResourcesConfig config, IPolicyChain<ApiRequest> chain)If the request is cached anIConnectorInterceptoris set in order to prevent the back-end connection to be established.protected voiddoApply(ApiResponse response, IPolicyContext context, CachingResourcesConfig config, IPolicyChain<ApiResponse> chain)Apply the policy to the response.Class<CachingResourcesConfig>getConfigurationClass()The class to use for JSON configuration deserializationprotected IReadWriteStream<ApiRequest>requestDataHandler(ApiRequest request, IPolicyContext context, CachingResourcesConfig policyConfiguration)Subclasses must implement this.protected IReadWriteStream<ApiResponse>responseDataHandler(ApiResponse response, IPolicyContext context, CachingResourcesConfig policyConfiguration)Subclasses must implement this.-
Methods inherited from class io.apiman.gateway.engine.policies.AbstractMappedDataPolicy
getRequestDataHandler, getResponseDataHandler
-
Methods inherited from class io.apiman.gateway.engine.policies.AbstractMappedPolicy
apply, apply, doProcessFailure, parseConfiguration, processFailure
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.apiman.gateway.engine.policy.IDataPolicy
getRequestDataHandler, getResponseDataHandler
-
Methods inherited from interface io.apiman.gateway.engine.policy.IPolicy
apply, apply, parseConfiguration, processFailure
-
-
-
-
Method Detail
-
getConfigurationClass
public Class<CachingResourcesConfig> getConfigurationClass()
Description copied from class:AbstractMappedPolicyThe class to use for JSON configuration deserialization- Specified by:
getConfigurationClassin classAbstractMappedPolicy<CachingResourcesConfig>- Returns:
- the class
- See Also:
AbstractMappedPolicy.getConfigurationClass()
-
doApply
protected void doApply(ApiRequest request, IPolicyContext context, CachingResourcesConfig config, IPolicyChain<ApiRequest> chain)
If the request is cached anIConnectorInterceptoris set in order to prevent the back-end connection to be established. Otherwise an emptyCachedResponsewill be added to the context, this will be used to cache the response once it has been received from the back-end API- Overrides:
doApplyin classAbstractMappedPolicy<CachingResourcesConfig>- Parameters:
request- the requestchain- the ordered policy chain- See Also:
AbstractMappedPolicy.doApply(io.apiman.gateway.engine.beans.ApiRequest, io.apiman.gateway.engine.policy.IPolicyContext, java.lang.Object, io.apiman.gateway.engine.policy.IPolicyChain)
-
doApply
protected void doApply(ApiResponse response, IPolicyContext context, CachingResourcesConfig config, IPolicyChain<ApiResponse> chain)
Description copied from class:AbstractMappedPolicyApply the policy to the response.Override this method to interact with or observe the response.
- Overrides:
doApplyin classAbstractMappedPolicy<CachingResourcesConfig>- Parameters:
response- the responsecontext- the policy contextconfig- the configuration (seeAbstractMappedPolicy.getConfigurationClass())chain- the ordered policy chain- See Also:
AbstractMappedPolicy.doApply(ApiResponse, IPolicyContext, Object, IPolicyChain)
-
requestDataHandler
protected IReadWriteStream<ApiRequest> requestDataHandler(ApiRequest request, IPolicyContext context, CachingResourcesConfig policyConfiguration)
Description copied from class:AbstractMappedDataPolicySubclasses must implement this.
-
responseDataHandler
protected IReadWriteStream<ApiResponse> responseDataHandler(ApiResponse response, IPolicyContext context, CachingResourcesConfig policyConfiguration)
Description copied from class:AbstractMappedDataPolicySubclasses must implement this.
-
-