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-2015 the original author or authors.
*
* 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 org.springframework.integration.dsl;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import org.springframework.expression.Expression;
import org.springframework.integration.context.IntegrationContextUtils;
import org.springframework.integration.dsl.core.IntegrationComponentSpec;
import org.springframework.integration.dsl.support.BeanNameMessageProcessor;
import org.springframework.integration.dsl.support.Consumer;
import org.springframework.integration.dsl.support.Function;
import org.springframework.integration.dsl.support.FunctionExpression;
import org.springframework.integration.dsl.support.MapBuilder;
import org.springframework.integration.dsl.support.StringStringMapBuilder;
import org.springframework.integration.handler.ExpressionEvaluatingMessageProcessor;
import org.springframework.integration.handler.MessageProcessor;
import org.springframework.integration.transformer.HeaderEnricher;
import org.springframework.integration.transformer.support.AbstractHeaderValueMessageProcessor;
import org.springframework.integration.transformer.support.ExpressionEvaluatingHeaderValueMessageProcessor;
import org.springframework.integration.transformer.support.HeaderValueMessageProcessor;
import org.springframework.integration.transformer.support.StaticHeaderValueMessageProcessor;
import org.springframework.messaging.Message;
import org.springframework.util.Assert;
/**
* An {@link IntegrationComponentSpec} for a {@link HeaderEnricher}.
*
* @author Artem Bilan
* @author Gary Russell
*/
public class HeaderEnricherSpec extends IntegrationComponentSpec {
private final Map> headerToAdd = new HashMap>();
private final HeaderEnricher headerEnricher = new HeaderEnricher(headerToAdd);
HeaderEnricherSpec() {
}
/**
* Determine the default action to take when setting individual header specifications
* without an explicit 'overwrite' argument.
* @param defaultOverwrite the defaultOverwrite.
* @return the header enricher spec.
* @see HeaderEnricher#setDefaultOverwrite(boolean)
*/
public HeaderEnricherSpec defaultOverwrite(boolean defaultOverwrite) {
this.headerEnricher.setDefaultOverwrite(defaultOverwrite);
return _this();
}
/**
* @param shouldSkipNulls the shouldSkipNulls.
* @return the header enricher spec.
* @see HeaderEnricher#setShouldSkipNulls(boolean)
*/
public HeaderEnricherSpec shouldSkipNulls(boolean shouldSkipNulls) {
this.headerEnricher.setShouldSkipNulls(shouldSkipNulls);
return _this();
}
/**
* Configure an optional custom {@link MessageProcessor} for the enricher. The
* processor must return a {@link Map} of header names and values. They will be added
* to the inbound message headers before evaluating the individual configured header
* specifications.
* @param messageProcessor the messageProcessor.
* @return the header enricher spec.
* @see HeaderEnricher#setMessageProcessor(MessageProcessor)
*/
public HeaderEnricherSpec messageProcessor(MessageProcessor> messageProcessor) {
this.headerEnricher.setMessageProcessor(messageProcessor);
return _this();
}
/**
* Configure an {@link ExpressionEvaluatingMessageProcessor} that evaluates to a
* {@link Map} of additional headers. They will be added to the inbound message
* headers before evaluating the individual configured header specifications.
* @param expression the expression.
* @return the header enricher spec.
* @see #messageProcessor(MessageProcessor)
*/
public HeaderEnricherSpec messageProcessor(String expression) {
return messageProcessor(new ExpressionEvaluatingMessageProcessor