Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/* Copyright 2014 predic8 GmbH, www.predic8.com
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
package com.predic8.membrane.core.interceptor.flow;
import com.predic8.membrane.annot.*;
import com.predic8.membrane.core.*;
import com.predic8.membrane.core.exchange.*;
import com.predic8.membrane.core.http.*;
import com.predic8.membrane.core.interceptor.*;
import com.predic8.membrane.core.lang.groovy.*;
import com.predic8.membrane.core.lang.spel.*;
import org.slf4j.*;
import org.springframework.expression.*;
import org.springframework.expression.spel.standard.*;
import java.util.*;
import java.util.function.*;
import static com.predic8.membrane.core.interceptor.Interceptor.Flow.REQUEST;
import static com.predic8.membrane.core.interceptor.Interceptor.Flow.RESPONSE;
import static com.predic8.membrane.core.interceptor.Outcome.*;
import static com.predic8.membrane.core.interceptor.flow.ConditionalInterceptor.LanguageType.*;
import static com.predic8.membrane.core.lang.ScriptingUtils.createParameterBindings;
/**
* @description
* The "if" interceptor supports conditional execution of a group of executors.
*
*
*
* Note that this is a draft implementation only: Design decisions are still pending.
*
*
*
'evaluate condition only once': Should the condition be reevaluated once response handling has begun?
*
'evaluate condition always during request handling already' (even when 'if' is nested in 'response')
*
What happens to ABORT handling of interceptor A in <request><if test="..."><A /></if></response>
*
*/
@MCElement(name = "if")
public class ConditionalInterceptor extends AbstractFlowInterceptor {
private static final Logger log = LoggerFactory.getLogger(InterceptorFlowController.class);
// configuration
private String test;
private LanguageType language = GROOVY;
/**
* Spring Expression Language
*/
private Expression spelExpr;
// state
private final InterceptorFlowController interceptorFlowController = new InterceptorFlowController();
private Function