Search in sources :

Example 1 with Chain

use of io.apiman.gateway.engine.policy.Chain in project apiman by apiman.

the class ApiRequestExecutorImpl method createRequestChain.

/**
 * Creates the chain used to apply policies in order to the api request.
 */
private Chain<ApiRequest> createRequestChain(IAsyncHandler<ApiRequest> requestHandler) {
    RequestChain chain = new RequestChain(policyImpls, context);
    chain.headHandler(requestHandler);
    chain.policyFailureHandler(failure -> {
        // It will likely not have been initialised, so create one.
        if (responseChain == null) {
            // Its response will not be used as we take the failure path only, so we just use an empty lambda.
            responseChain = createResponseChain((ignored) -> {
            });
        }
        responseChain.doFailure(failure);
    });
    chain.policyErrorHandler(policyErrorHandler);
    return chain;
}
Also used : Date(java.util.Date) IPayloadIO(io.apiman.gateway.engine.io.IPayloadIO) JsonPayloadIO(io.apiman.gateway.engine.io.JsonPayloadIO) ApiResponse(io.apiman.gateway.engine.beans.ApiResponse) IAsyncResult(io.apiman.gateway.engine.async.IAsyncResult) RequestChain(io.apiman.gateway.engine.policy.RequestChain) BytesPayloadIO(io.apiman.gateway.engine.io.BytesPayloadIO) IAsyncResultHandler(io.apiman.gateway.engine.async.IAsyncResultHandler) Map(java.util.Map) IApiConnector(io.apiman.gateway.engine.IApiConnector) GatewayConfigProperties(io.apiman.gateway.engine.GatewayConfigProperties) StrSubstitutor(org.apache.commons.lang3.text.StrSubstitutor) ISignalWriteStream(io.apiman.gateway.engine.io.ISignalWriteStream) RequestAbortedException(io.apiman.gateway.engine.beans.exceptions.RequestAbortedException) RequestMetric(io.apiman.gateway.engine.metrics.RequestMetric) IDataPolicy(io.apiman.gateway.engine.policy.IDataPolicy) Policy(io.apiman.gateway.engine.beans.Policy) Set(java.util.Set) PolicyFailure(io.apiman.gateway.engine.beans.PolicyFailure) IConnectorInterceptor(io.apiman.gateway.engine.policy.IConnectorInterceptor) List(java.util.List) IApimanBuffer(io.apiman.gateway.engine.io.IApimanBuffer) InvalidApiException(io.apiman.gateway.engine.beans.exceptions.InvalidApiException) Messages(io.apiman.gateway.engine.i18n.Messages) IRegistry(io.apiman.gateway.engine.IRegistry) Entry(java.util.Map.Entry) IApiConnection(io.apiman.gateway.engine.IApiConnection) Chain(io.apiman.gateway.engine.policy.Chain) IPolicy(io.apiman.gateway.engine.policy.IPolicy) IApiConnectionResponse(io.apiman.gateway.engine.IApiConnectionResponse) PolicyContextKeys(io.apiman.gateway.engine.policy.PolicyContextKeys) AsyncResultImpl(io.apiman.gateway.engine.async.AsyncResultImpl) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) PolicyWithConfiguration(io.apiman.gateway.engine.policy.PolicyWithConfiguration) HashSet(java.util.HashSet) ApimanStrLookup(io.apiman.common.util.ApimanStrLookup) SoapPayloadIO(io.apiman.gateway.engine.io.SoapPayloadIO) IConnectorConfig(io.apiman.gateway.engine.IConnectorConfig) IApiRequestExecutor(io.apiman.gateway.engine.IApiRequestExecutor) RequiredAuthType(io.apiman.gateway.engine.auth.RequiredAuthType) IBufferFactoryComponent(io.apiman.gateway.engine.components.IBufferFactoryComponent) StrLookup(org.apache.commons.lang3.text.StrLookup) IEngineResult(io.apiman.gateway.engine.IEngineResult) ByteBuffer(io.apiman.gateway.engine.io.ByteBuffer) InvalidContractException(io.apiman.gateway.engine.beans.exceptions.InvalidContractException) ApiRequest(io.apiman.gateway.engine.beans.ApiRequest) Api(io.apiman.gateway.engine.beans.Api) ResponseChain(io.apiman.gateway.engine.policy.ResponseChain) ApiNotFoundException(io.apiman.gateway.engine.beans.exceptions.ApiNotFoundException) IMetrics(io.apiman.gateway.engine.IMetrics) IConnectorFactory(io.apiman.gateway.engine.IConnectorFactory) IAsyncHandler(io.apiman.gateway.engine.async.IAsyncHandler) IPolicyContext(io.apiman.gateway.engine.policy.IPolicyContext) ApiContract(io.apiman.gateway.engine.beans.ApiContract) IPolicyFactory(io.apiman.gateway.engine.policy.IPolicyFactory) XmlPayloadIO(io.apiman.gateway.engine.io.XmlPayloadIO) RequestChain(io.apiman.gateway.engine.policy.RequestChain)

Aggregations

ApimanStrLookup (io.apiman.common.util.ApimanStrLookup)1 GatewayConfigProperties (io.apiman.gateway.engine.GatewayConfigProperties)1 IApiConnection (io.apiman.gateway.engine.IApiConnection)1 IApiConnectionResponse (io.apiman.gateway.engine.IApiConnectionResponse)1 IApiConnector (io.apiman.gateway.engine.IApiConnector)1 IApiRequestExecutor (io.apiman.gateway.engine.IApiRequestExecutor)1 IConnectorConfig (io.apiman.gateway.engine.IConnectorConfig)1 IConnectorFactory (io.apiman.gateway.engine.IConnectorFactory)1 IEngineResult (io.apiman.gateway.engine.IEngineResult)1 IMetrics (io.apiman.gateway.engine.IMetrics)1 IRegistry (io.apiman.gateway.engine.IRegistry)1 AsyncResultImpl (io.apiman.gateway.engine.async.AsyncResultImpl)1 IAsyncHandler (io.apiman.gateway.engine.async.IAsyncHandler)1 IAsyncResult (io.apiman.gateway.engine.async.IAsyncResult)1 IAsyncResultHandler (io.apiman.gateway.engine.async.IAsyncResultHandler)1 RequiredAuthType (io.apiman.gateway.engine.auth.RequiredAuthType)1 Api (io.apiman.gateway.engine.beans.Api)1 ApiContract (io.apiman.gateway.engine.beans.ApiContract)1 ApiRequest (io.apiman.gateway.engine.beans.ApiRequest)1 ApiResponse (io.apiman.gateway.engine.beans.ApiResponse)1