INT-3665: Remove Deprecations and Resolve Issues

https://jira.spring.io/browse/INT-3665

Fixes according Travis report

Introduce `...ExpressionString(String)` setter

Some further fixes and polishing

Address PR comments
This commit is contained in:
Artem Bilan
2015-08-13 16:10:36 -04:00
committed by Gary Russell
parent 84fdd98428
commit cf528c0b5d
81 changed files with 529 additions and 1168 deletions

View File

@@ -23,19 +23,11 @@ import org.springframework.messaging.MessageHandlingException;
* Exception that indicates a message has been rejected by a selector.
*
* @author Mark Fisher
* @author Artem Bilan
*/
@SuppressWarnings("serial")
public class MessageRejectedException extends MessageHandlingException {
/**
* @param failedMessage the failed {@link Message}
* @deprecated since 4.2 in favor of {@link #MessageRejectedException(Message, String)}
*/
@Deprecated
public MessageRejectedException(Message<?> failedMessage) {
super(failedMessage);
}
public MessageRejectedException(Message<?> failedMessage, String description) {
super(failedMessage, description);
}

View File

@@ -19,10 +19,7 @@ package org.springframework.integration.aggregator;
import java.util.Collection;
import org.springframework.expression.Expression;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.ParseException;
import org.springframework.expression.spel.SpelParserConfiguration;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.integration.util.AbstractExpressionEvaluator;
import org.springframework.messaging.Message;
@@ -35,8 +32,6 @@ import org.springframework.messaging.Message;
*/
public class ExpressionEvaluatingMessageListProcessor extends AbstractExpressionEvaluator implements MessageListProcessor {
private final ExpressionParser parser = new SpelExpressionParser(new SpelParserConfiguration(true, true));
private final Expression expression;
private volatile Class<?> expectedType = null;
@@ -52,7 +47,7 @@ public class ExpressionEvaluatingMessageListProcessor extends AbstractExpression
public ExpressionEvaluatingMessageListProcessor(String expression) {
try {
this.expression = parser.parseExpression(expression);
this.expression = EXPRESSION_PARSER.parseExpression(expression);
}
catch (ParseException e) {
throw new IllegalArgumentException("Failed to parse expression.", e);

View File

@@ -1,36 +0,0 @@
/*
* Copyright 2002-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.aggregator;
import org.springframework.integration.store.MessageGroup;
/**
* This implementation of MessageGroupProcessor will return all messages inside the group.
* This is useful if there is no requirement to process the messages, but they should just be
* blocked as a group until their ReleaseStrategy lets them pass through.
*
* @deprecated since 4.2; use {@link SimpleMessageGroupProcessor}
*
* @author Iwein Fuld
* @since 2.0.0
*/
@Deprecated
public class PassThroughMessageGroupProcessor implements MessageGroupProcessor {
@Override
public Object processMessageGroup(MessageGroup group) {
return group.getMessages();
}
}

View File

@@ -1,50 +0,0 @@
/*
* Copyright 2002-2010 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.annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Annotation indicating that a method parameter's value should be
* retrieved from the message headers. The value of the annotation
* can either be a header name (e.g., 'foo') or SpEL expression
* (e.g., 'payload.getCustomerId()') which is quite useful when
* the name of the header has to be dynamically computed. It also
* provides an optional 'required' property which
* specifies whether the attribute value must be available within
* the header. The default value for 'required' is <code>true</code>.
*
* @author Mark Fisher
*
* @deprecated since 4.1 in favor of {@link org.springframework.messaging.handler.annotation.Header}.
* Will be removed in a future release.
*/
@Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Deprecated
public @interface Header {
String value() default "";
boolean required() default true;
}

View File

@@ -1,41 +0,0 @@
/*
* Copyright 2002-2010 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.annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Annotation indicating that a method parameter's value should be mapped to or
* from the message headers. The annotated parameter must be assignable to
* {@link java.util.Map}, and all of the Map's keys must be Strings.
*
* @author Mark Fisher
*
* @deprecated since 4.1 in favor of {@link org.springframework.messaging.handler.annotation.Headers}.
* Will be removed in a future release.
*/
@Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Deprecated
public @interface Headers {
}

View File

@@ -1,51 +0,0 @@
/*
* Copyright 2002-2014 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.annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* This annotation allows you to specify a SpEL expression indicating that a method
* parameter's value should be mapped from the payload of a Message. The expression
* will be evaluated against the payload object as the root context. The annotated
* parameter type must match or be convertible from the evaluation result.
* <p>
* Example: void foo(@Payload("city.name") String cityName) - will map the value of
* the 'name' property of the 'city' property of the payload object.
*
* @author Oleg Zhurakousky
* @since 2.0
*
* @deprecated since 4.1 in favor of {@link org.springframework.messaging.handler.annotation.Payload}.
* Will be removed in a future release.
*/
@Target({ElementType.PARAMETER, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Deprecated
public @interface Payload {
/**
* @return The expression for matching against nested properties of the payload.
*/
String value() default "";
}

View File

@@ -89,16 +89,6 @@ public class MessagePublishingInterceptor implements MethodInterceptor, BeanFact
this.metadataSource = metadataSource;
}
/**
* @deprecated Use {@link #setDefaultChannelName(String)}.
* @param defaultChannel the default channel.
*/
@Deprecated
public void setDefaultChannel(MessageChannel defaultChannel) {
this.messagingTemplate.setDefaultDestination(defaultChannel);
this.defaultChannelName = null;
}
/**
* @param defaultChannelName the default channel name.
* @since 4.0.3

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-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.
@@ -72,14 +72,9 @@ public class MethodAnnotationPublisherMetadataSource implements PublisherMetadat
return (StringUtils.hasText(channelName) ? channelName : null);
}
@SuppressWarnings("deprecation")
public String getPayloadExpression(Method method) {
String payloadExpression = null;
Annotation methodPayloadAnnotation =
AnnotationUtils.findAnnotation(method, org.springframework.integration.annotation.Payload.class);
if (methodPayloadAnnotation == null) {
methodPayloadAnnotation = AnnotationUtils.findAnnotation(method, Payload.class);
}
Annotation methodPayloadAnnotation = AnnotationUtils.findAnnotation(method, Payload.class);
if (methodPayloadAnnotation != null) {
payloadExpression = getAnnotationValue(methodPayloadAnnotation, null, String.class);
@@ -92,8 +87,7 @@ public class MethodAnnotationPublisherMetadataSource implements PublisherMetadat
for (int i = 0; i < annotationArray.length; i++) {
Annotation[] parameterAnnotations = annotationArray[i];
for (Annotation currentAnnotation : parameterAnnotations) {
if (org.springframework.integration.annotation.Payload.class.equals(currentAnnotation.annotationType())
|| Payload.class.equals(currentAnnotation.annotationType())) {
if (Payload.class.equals(currentAnnotation.annotationType())) {
Assert.state(payloadExpression == null,
"@Payload can be used at most once on a @Publisher method, " +
"either at method-level or on a single parameter");
@@ -112,7 +106,6 @@ public class MethodAnnotationPublisherMetadataSource implements PublisherMetadat
return payloadExpression;
}
@SuppressWarnings("deprecation")
public Map<String, String> getHeaderExpressions(Method method) {
Map<String, String> headerExpressions = new HashMap<String, String>();
String[] parameterNames = this.parameterNameDiscoverer.getParameterNames(method);
@@ -120,8 +113,7 @@ public class MethodAnnotationPublisherMetadataSource implements PublisherMetadat
for (int i = 0; i < annotationArray.length; i++) {
Annotation[] parameterAnnotations = annotationArray[i];
for (Annotation currentAnnotation : parameterAnnotations) {
if (org.springframework.integration.annotation.Header.class.equals(currentAnnotation.annotationType())
|| Header.class.equals(currentAnnotation.annotationType())) {
if (Header.class.equals(currentAnnotation.annotationType())) {
String name = getAnnotationValue(currentAnnotation, null, String.class);
if (!StringUtils.hasText(name)) {
name = parameterNames[i];

View File

@@ -37,7 +37,6 @@ import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.integration.annotation.Publisher;
import org.springframework.integration.support.channel.BeanFactoryChannelResolver;
import org.springframework.messaging.MessageChannel;
import org.springframework.util.Assert;
/**
@@ -69,15 +68,6 @@ public class PublisherAnnotationAdvisor extends AbstractPointcutAdvisor implemen
}
/**
* @deprecated Use {@link #setDefaultChannelName(String)}.
* @param defaultChannel the default channel.
*/
@Deprecated
public void setDefaultChannel(MessageChannel defaultChannel) {
this.interceptor.setDefaultChannel(defaultChannel);
}
/**
* @param defaultChannelName the default channel name.
* @since 4.0.3

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-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.
@@ -28,7 +28,6 @@ import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.core.Ordered;
import org.springframework.integration.annotation.Publisher;
import org.springframework.messaging.MessageChannel;
import org.springframework.util.ClassUtils;
/**
@@ -37,14 +36,13 @@ import org.springframework.util.ClassUtils;
* @author Oleg Zhurakousky
* @author Mark Fisher
* @author Gary Russell
* @author Artem Bilan
* @since 2.0
*/
@SuppressWarnings("serial")
public class PublisherAnnotationBeanPostProcessor extends ProxyConfig
implements BeanPostProcessor, BeanClassLoaderAware, BeanFactoryAware, InitializingBean, Ordered {
private volatile MessageChannel defaultChannel;
private volatile String defaultChannelName;
private volatile PublisherAnnotationAdvisor advisor;
@@ -55,18 +53,6 @@ public class PublisherAnnotationBeanPostProcessor extends ProxyConfig
private volatile ClassLoader beanClassLoader = ClassUtils.getDefaultClassLoader();
/**
* Set the default channel where Messages should be sent if the annotation
* itself does not provide a channel.
* @param defaultChannel The default channel.
* @deprecated Use {@link #setDefaultChannelName(String)}
*/
@Deprecated
public void setDefaultChannel(MessageChannel defaultChannel){
this.defaultChannel = defaultChannel;
}
/**
* Set the default channel where Messages should be sent if the annotation
* itself does not provide a channel.
@@ -101,12 +87,7 @@ public class PublisherAnnotationBeanPostProcessor extends ProxyConfig
public void afterPropertiesSet(){
this.advisor = new PublisherAnnotationAdvisor();
this.advisor.setBeanFactory(this.beanFactory);
if (this.defaultChannel != null) {
this.advisor.setDefaultChannel(this.defaultChannel);
}
else {
this.advisor.setDefaultChannelName(this.defaultChannelName);
}
this.advisor.setDefaultChannelName(this.defaultChannelName);
}
@Override

View File

@@ -27,7 +27,6 @@ import java.util.concurrent.CopyOnWriteArrayList;
import org.apache.commons.logging.Log;
import org.springframework.core.OrderComparator;
import org.springframework.core.convert.ConversionService;
import org.springframework.integration.context.IntegrationContextUtils;
import org.springframework.integration.context.IntegrationObjectSupport;
import org.springframework.integration.history.MessageHistory;
@@ -197,24 +196,6 @@ public abstract class AbstractMessageChannel extends IntegrationObjectSupport
this.interceptors.add(index, interceptor);
}
/**
* Specify the {@link ConversionService} to use when trying to convert to
* one of this channel's supported datatypes for a Message whose payload
* does not already match. If this property is not set explicitly but
* the channel is managed within a context, it will attempt to locate a
* bean named "integrationConversionService" defined within that context.
*
* @param conversionService The conversion service.
* @deprecated No longer used; see {@link DefaultDatatypeChannelMessageConverter}.
*/
@Deprecated
@Override
public void setConversionService(ConversionService conversionService) {
if (logger.isWarnEnabled()) {
logger.warn("The conversion service is no longer used; see setMessageConverter()");
}
}
/**
* Specify the {@link MessageConverter} to use when trying to convert to
* one of this channel's supported datatypes (in order) for a Message whose payload

View File

@@ -36,7 +36,6 @@ import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.BeanDefinitionReaderUtils;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.ManagedSet;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
@@ -86,11 +85,9 @@ public class IntegrationRegistrar implements ImportBeanDefinitionRegistrar, Bean
* to register the messaging annotation post processors (for {@code <int:annotation-config/>}).
*/
@Override
@SuppressWarnings("deprecation")
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
this.registerImplicitChannelCreator(registry);
this.registerIntegrationConfigurationBeanFactoryPostProcessor(registry);
//TODO remove this line in the 4.3
this.registerIntegrationEvaluationContext(registry);
this.registerIntegrationProperties(registry);
this.registerHeaderChannelRegistry(registry);
@@ -175,15 +172,9 @@ public class IntegrationRegistrar implements ImportBeanDefinitionRegistrar, Bean
}
/**
* Register {@link IntegrationEvaluationContextFactoryBean} bean
* and {@code IntegrationEvaluationContextAwareBeanPostProcessor}, if necessary.
* Register {@link IntegrationEvaluationContextFactoryBean} bean, if necessary.
* @param registry The {@link BeanDefinitionRegistry} to register additional {@link BeanDefinition}s.
* @deprecated since 4.2 in favor of {@link IntegrationContextUtils#getEvaluationContext}
* direct usage from the {@code afterPropertiesSet} implementation.
* Will be removed in the next release.
*/
@Deprecated
@SuppressWarnings("deprecation")
private void registerIntegrationEvaluationContext(BeanDefinitionRegistry registry) {
if (!registry.containsBeanDefinition(IntegrationContextUtils.INTEGRATION_EVALUATION_CONTEXT_BEAN_NAME)) {
BeanDefinitionBuilder integrationEvaluationContextBuilder = BeanDefinitionBuilder
@@ -196,10 +187,6 @@ public class IntegrationRegistrar implements ImportBeanDefinitionRegistrar, Bean
BeanDefinitionReaderUtils.registerBeanDefinition(integrationEvaluationContextHolder,
registry);
RootBeanDefinition integrationEvalContextBPP =
new RootBeanDefinition(org.springframework.integration.expression.IntegrationEvaluationContextAwareBeanPostProcessor.class);
BeanDefinitionReaderUtils.registerWithGeneratedName(integrationEvalContextBPP, registry);
}
}

View File

@@ -16,6 +16,8 @@
package org.springframework.integration.config.xml;
import org.w3c.dom.Element;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.integration.config.ExpressionFactoryBean;
@@ -23,7 +25,6 @@ import org.springframework.integration.expression.DynamicExpression;
import org.springframework.integration.handler.DelayHandler;
import org.springframework.util.StringUtils;
import org.springframework.util.xml.DomUtils;
import org.w3c.dom.Element;
/**
* Parser for the &lt;delayer&gt; element.
@@ -44,23 +45,21 @@ public class DelayerParser extends AbstractConsumerEndpointParser {
}
String defaultDelay = element.getAttribute("default-delay");
String delayHeaderName = element.getAttribute("delay-header-name");
String expression = element.getAttribute(EXPRESSION_ATTRIBUTE);
Element expressionElement = DomUtils.getChildElementByTagName(element, "expression");
boolean hasDefaultDelay = StringUtils.hasText(defaultDelay);
boolean hasDelayHeaderName = StringUtils.hasText(delayHeaderName);
boolean hasExpression = StringUtils.hasText(expression);
boolean hasExpressionElement = expressionElement != null;
if (!(hasDefaultDelay | hasDelayHeaderName | hasExpression | hasExpressionElement)) {
if (!(hasDefaultDelay | hasExpression | hasExpressionElement)) {
parserContext.getReaderContext()
.error("The 'default-delay' or 'delay-header-name', or 'expression' attributes, or 'expression' sub-element should be provided.", element);
.error("The 'default-delay' or 'expression' attributes, or 'expression' sub-element should be provided.", element);
}
if ((hasDelayHeaderName & (hasExpression | hasExpressionElement)) | (hasExpression & hasExpressionElement)) {
if (hasExpression & hasExpressionElement) {
parserContext.getReaderContext()
.error("'delay-header-name', 'expression' attribute and 'expression' sub-element are mutually exclusive.", element);
.error("'expression' attribute and 'expression' sub-element are mutually exclusive.", element);
}
builder.addConstructorArgValue(id + ".messageGroupId");
@@ -92,10 +91,6 @@ public class DelayerParser extends AbstractConsumerEndpointParser {
builder.addPropertyValue("delayExpression", expressionBuilder.getBeanDefinition());
}
if (hasDelayHeaderName) {
builder.addPropertyValue("delayHeaderName", delayHeaderName);
}
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "message-store");
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "send-timeout");
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "ignore-expression-failures");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-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.
@@ -42,6 +42,7 @@ import org.springframework.util.xml.DomUtils;
* @author Oleg Zhurakousky
* @author Mark Fisher
* @author Gary Russell
* @author Artem Bilan
* @since 2.0
*/
public class PublishingInterceptorParser extends AbstractBeanDefinitionParser {
@@ -70,7 +71,7 @@ public class PublishingInterceptorParser extends AbstractBeanDefinitionParser {
element.getAttribute("default-channel") : IntegrationContextUtils.NULL_CHANNEL_BEAN_NAME;
rootBuilder.addConstructorArgValue(spelSourceBuilder.getBeanDefinition());
rootBuilder.addPropertyReference("channelResolver", chResolverName);
rootBuilder.addPropertyReference("defaultChannel", defaultChannel);
rootBuilder.addPropertyValue("defaultChannelName", defaultChannel);
return rootBuilder.getBeanDefinition();
}
@@ -104,7 +105,7 @@ public class PublishingInterceptorParser extends AbstractBeanDefinitionParser {
String expression = headerElement.getAttribute("expression");
boolean hasValue = StringUtils.hasText(value);
boolean hasExpression = StringUtils.hasText(expression);
if (!(hasValue ^ hasExpression)) {
if (hasValue == hasExpression) {
parserContext.getReaderContext().error("exactly one of 'value' or 'expression' is required on the <header> element",
parserContext.extractSource(headerElement));
continue;

View File

@@ -33,6 +33,8 @@ import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.core.convert.ConversionService;
import org.springframework.core.convert.support.DefaultConversionService;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.integration.support.DefaultMessageBuilderFactory;
import org.springframework.integration.support.MessageBuilderFactory;
import org.springframework.integration.support.channel.BeanFactoryChannelResolver;
@@ -68,6 +70,8 @@ public abstract class IntegrationObjectSupport implements BeanNameAware, NamedCo
*/
protected final Log logger = LogFactory.getLog(getClass());
protected final ExpressionParser EXPRESSION_PARSER = new SpelExpressionParser();
private final ConversionService defaultConversionService = new DefaultConversionService();
private volatile DestinationResolver<MessageChannel> channelResolver;

View File

@@ -15,7 +15,6 @@ package org.springframework.integration.endpoint;
import org.springframework.expression.EvaluationContext;
import org.springframework.expression.Expression;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.integration.expression.ExpressionUtils;
import org.springframework.util.Assert;
@@ -31,29 +30,34 @@ import org.springframework.util.Assert;
*/
public abstract class ExpressionMessageProducerSupport extends MessageProducerSupport {
private static final SpelExpressionParser PARSER = new SpelExpressionParser();
private volatile Expression payloadExpression;
private volatile EvaluationContext evaluationContext;
/**
* @deprecated in favor of {@link #setExpressionPayload}. Will be changed in a future release
* to use an {@link Expression} parameter.
* @param payloadExpression the expression to set.
* @param payloadExpression the expression to use.
* @since 4.3
*/
@Deprecated
public void setPayloadExpression(String payloadExpression) {
Assert.hasText(payloadExpression);
setExpressionPayload(PARSER.parseExpression(payloadExpression));
public void setPayloadExpression(Expression payloadExpression) {
this.payloadExpression = payloadExpression;
}
/**
* Temporary, will be changed to {@link #setPayloadExpression} in a future release.
* @param payloadExpression the expression to set.
* @param payloadExpression the String in SpEL syntax.
* @since 4.3
*/
public void setPayloadExpressionString(String payloadExpression) {
Assert.hasText(payloadExpression, "'payloadExpression' must not be empty");
this.payloadExpression = EXPRESSION_PARSER.parseExpression(payloadExpression);
}
/**
* @param payloadExpression the expression to set.
* @deprecated in favor of {@link #setPayloadExpression}.
*/
@Deprecated
public void setExpressionPayload(Expression payloadExpression) {
this.payloadExpression = payloadExpression;
setPayloadExpression(payloadExpression);
}
public void setIntegrationEvaluationContext(EvaluationContext evaluationContext) {

View File

@@ -1,46 +0,0 @@
/*
* Copyright 2013 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.expression;
import org.springframework.expression.EvaluationContext;
import org.springframework.integration.context.IntegrationContextUtils;
/**
* Interface to be implemented by beans that wish to be aware of their
* owning integration {@link EvaluationContext}, which is the result of
* {@link org.springframework.integration.config.IntegrationEvaluationContextFactoryBean}
* <p>
* The {@link #setIntegrationEvaluationContext} is invoked from
* the {@code IntegrationEvaluationContextAwareBeanPostProcessor#afterSingletonsInstantiated()},
* not during standard {@code postProcessBefore(After)Initialization} to avoid any
* {@code BeanFactory} early access during integration {@link EvaluationContext} retrieval.
* Therefore, if it is necessary to use {@link EvaluationContext} in the {@code afterPropertiesSet()},
* the {@code IntegrationContextUtils.getEvaluationContext(this.beanFactory)} should be used instead
* of this interface implementation.
*
* @author Artem Bilan
* @since 3.0
* @deprecated since 4.2 in favor of {@link IntegrationContextUtils#getEvaluationContext}
* direct usage from the {@code afterPropertiesSet} implementation.
* Will be removed in the next release.
*/
@Deprecated
public interface IntegrationEvaluationContextAware {
void setIntegrationEvaluationContext(EvaluationContext evaluationContext);
}

View File

@@ -1,80 +0,0 @@
/*
* Copyright 2013-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.expression;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.SmartInitializingSingleton;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.core.Ordered;
import org.springframework.expression.spel.support.StandardEvaluationContext;
import org.springframework.integration.context.IntegrationContextUtils;
/**
* @author Artem Bilan
* @author Gary Russell
* @since 3.0
* @deprecated since 4.2 in favor of {@link IntegrationContextUtils#getEvaluationContext}
* direct usage from the {@code afterPropertiesSet} implementation.
* Will be removed in the next release.
*/
@Deprecated
@SuppressWarnings("deprecation")
public class IntegrationEvaluationContextAwareBeanPostProcessor
implements BeanPostProcessor, Ordered, BeanFactoryAware, SmartInitializingSingleton {
private final List<IntegrationEvaluationContextAware> evaluationContextAwares =
new ArrayList<IntegrationEvaluationContextAware>();
private volatile BeanFactory beanFactory;
@Override
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
this.beanFactory = beanFactory;
}
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
if (bean instanceof IntegrationEvaluationContextAware) {
this.evaluationContextAwares.add((IntegrationEvaluationContextAware) bean);
}
return bean;
}
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
return bean;
}
@Override
public void afterSingletonsInstantiated() {
StandardEvaluationContext evaluationContext = IntegrationContextUtils.getEvaluationContext(this.beanFactory);
for (IntegrationEvaluationContextAware evaluationContextAware : this.evaluationContextAwares) {
evaluationContextAware.setIntegrationEvaluationContext(evaluationContext);
}
}
@Override
public int getOrder() {
return LOWEST_PRECEDENCE;
}
}

View File

@@ -244,13 +244,9 @@ class GatewayMethodInboundMessageMapper implements InboundMessageMapper<Object[]
return parameterList;
}
@SuppressWarnings("deprecation")
private static Expression parsePayloadExpression(Method method) {
Expression expression = null;
Annotation payload = method.getAnnotation(org.springframework.integration.annotation.Payload.class);
if (payload == null) {
payload = method.getAnnotation(Payload.class);
}
Annotation payload = method.getAnnotation(Payload.class);
if (payload != null) {
String expressionString = (String) AnnotationUtils.getValue(payload);
Assert.hasText(expressionString,
@@ -263,7 +259,6 @@ class GatewayMethodInboundMessageMapper implements InboundMessageMapper<Object[]
public class DefaultMethodArgsMessageMapper implements MethodArgsMessageMapper {
@Override
@SuppressWarnings("deprecation")
public Message<?> toMessage(MethodArgsHolder holder) throws Exception {
Object messageOrPayload = null;
boolean foundPayloadAnnotation = false;
@@ -280,8 +275,7 @@ class GatewayMethodInboundMessageMapper implements InboundMessageMapper<Object[]
Annotation annotation =
MessagingAnnotationUtils.findMessagePartAnnotation(methodParameter.getParameterAnnotations(), false);
if (annotation != null) {
if (annotation.annotationType().equals(org.springframework.integration.annotation.Payload.class)
|| annotation.annotationType().equals(Payload.class)) {
if (annotation.annotationType().equals(Payload.class)) {
if (messageOrPayload != null) {
GatewayMethodInboundMessageMapper.this.throwExceptionForMultipleMessageOrPayloadParameters(methodParameter);
}
@@ -295,8 +289,7 @@ class GatewayMethodInboundMessageMapper implements InboundMessageMapper<Object[]
}
foundPayloadAnnotation = true;
}
else if (annotation.annotationType().equals(org.springframework.integration.annotation.Header.class)
|| annotation.annotationType().equals(Header.class)) {
else if (annotation.annotationType().equals(Header.class)) {
String headerName =
GatewayMethodInboundMessageMapper.this.determineHeaderName(annotation, methodParameter);
if ((Boolean) AnnotationUtils.getValue(annotation, "required") && argumentValue == null) {
@@ -305,8 +298,7 @@ class GatewayMethodInboundMessageMapper implements InboundMessageMapper<Object[]
}
headers.put(headerName, argumentValue);
}
else if (annotation.annotationType().equals(org.springframework.integration.annotation.Headers.class)
|| annotation.annotationType().equals(Headers.class)) {
else if (annotation.annotationType().equals(Headers.class)) {
if (argumentValue != null) {
if (!(argumentValue instanceof Map)) {
throw new IllegalArgumentException("@Headers annotation is only valid for Map-typed parameters");

View File

@@ -399,10 +399,7 @@ public class GatewayProxyFactoryBean extends AbstractEndpoint
boolean shouldReply = returnType != void.class;
int paramCount = method.getParameterTypes().length;
Object response = null;
@SuppressWarnings("deprecation")
boolean hasPayloadExpression =
method.isAnnotationPresent(org.springframework.integration.annotation.Payload.class)
|| method.isAnnotationPresent(Payload.class);
boolean hasPayloadExpression = method.isAnnotationPresent(Payload.class);
if (!hasPayloadExpression && this.methodMetadataMap != null) {
// check for the method metadata next
GatewayMethodMetadata metadata = this.methodMetadataMap.get(method.getName());

View File

@@ -94,8 +94,6 @@ public class DelayHandler extends AbstractReplyProducingMessageHandler implement
private volatile boolean ignoreExpressionFailures = true;
private volatile String delayHeaderName;
private volatile MessageGroupStore messageStore;
private volatile List<Advice> delayedAdviceChain;
@@ -144,19 +142,6 @@ public class DelayHandler extends AbstractReplyProducingMessageHandler implement
this.defaultDelay = defaultDelay;
}
/**
* Specify the name of the header that should be checked for a delay period
* (in milliseconds) or a Date to delay until. If this property is set, any
* such header value will take precedence over this handler's default delay.
* @deprecated in favor of {@link #delayExpression}
*
* @param delayHeaderName The name of the header.
*/
@Deprecated
public void setDelayHeaderName(String delayHeaderName) {
this.delayHeaderName = delayHeaderName;
}
/**
* Specify the {@link Expression} that should be checked for a delay period
* (in milliseconds) or a Date to delay until. If this property is set, the
@@ -221,12 +206,6 @@ public class DelayHandler extends AbstractReplyProducingMessageHandler implement
else {
Assert.isInstanceOf(MessageStore.class, this.messageStore);
}
if (this.delayHeaderName != null) {
logger.warn("'delayHeaderName' is deprecated in favor of 'delayExpression'");
if (this.delayExpression == null) {
this.delayExpression = expressionParser.parseExpression("headers['" + this.delayHeaderName + "']");
}
}
this.evaluationContext = ExpressionUtils.createStandardEvaluationContext(this.getBeanFactory());
this.releaseHandler = this.createReleaseMessageTask();
}

View File

@@ -107,21 +107,6 @@ public class SimpleMessageStore extends AbstractMessageGroupStore
this(0);
}
/**
* Factory method to return a simple message store that does not
* copy the group in {@link #getMessageGroup(Object)}.
* @param capacity the capacity (0 for unlimited).
* @return the store.
* @since 4.0.1
* @deprecated in 4.1 - copyOnGet is now false by default.
*/
@Deprecated
public static SimpleMessageStore fastMessageStore(int capacity) {
SimpleMessageStore store = new SimpleMessageStore(capacity);
store.setCopyOnGet(false);
return store;
}
/**
* Set to false to disable copying the group in {@link #getMessageGroup(Object)}.
* Starting with 4.1, this is false by default.

View File

@@ -36,16 +36,6 @@ public class MessageTransformationException extends MessagingException {
super(message, description);
}
/**
* @param message the failed {@link Message}
* @param cause the cause {@link Throwable}
* @deprecated since 4.2 in favor of {@link #MessageTransformationException(Message, String, Throwable)}.
*/
@Deprecated
public MessageTransformationException(Message<?> message, Throwable cause) {
this(message, cause.getMessage(), cause);
}
public MessageTransformationException(String description, Throwable cause) {
super(description, cause);
}

View File

@@ -46,12 +46,12 @@ public abstract class AbstractExpressionEvaluator implements BeanFactoryAware, I
protected final Log logger = LogFactory.getLog(this.getClass());
private volatile StandardEvaluationContext evaluationContext;
private final ExpressionParser expressionParser = new SpelExpressionParser();
protected static final ExpressionParser EXPRESSION_PARSER = new SpelExpressionParser();
private final BeanFactoryTypeConverter typeConverter = new BeanFactoryTypeConverter();
private volatile StandardEvaluationContext evaluationContext;
private volatile BeanFactory beanFactory;
private volatile MessageBuilderFactory messageBuilderFactory = new DefaultMessageBuilderFactory();
@@ -146,7 +146,7 @@ public abstract class AbstractExpressionEvaluator implements BeanFactoryAware, I
}
protected <T> T evaluateExpression(String expression, Object input, Class<T> expectedType) {
return this.expressionParser.parseExpression(expression)
return EXPRESSION_PARSER.parseExpression(expression)
.getValue(this.getEvaluationContext(), input, expectedType);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014 the original author or authors.
* 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.
@@ -113,11 +113,8 @@ public final class MessagingAnnotationUtils {
Annotation match = null;
for (Annotation annotation : annotations) {
Class<? extends Annotation> type = annotation.annotationType();
if (type.equals(org.springframework.integration.annotation.Payload.class)
|| type.equals(Payload.class)
|| type.equals(org.springframework.integration.annotation.Header.class)
if (type.equals(Payload.class)
|| type.equals(Header.class)
|| type.equals(org.springframework.integration.annotation.Headers.class)
|| type.equals(Headers.class)
|| (payloads && type.equals(Payloads.class))) {
if (match != null) {

View File

@@ -714,8 +714,7 @@ public class MessagingMethodInvokerHelper<T> extends AbstractExpressionEvaluator
MessagingAnnotationUtils.findMessagePartAnnotation(parameterAnnotations[i], true);
if (mappingAnnotation != null) {
Class<? extends Annotation> annotationType = mappingAnnotation.annotationType();
if (annotationType.equals(org.springframework.integration.annotation.Payload.class)
|| annotationType.equals(Payload.class)) {
if (annotationType.equals(Payload.class)) {
sb.append("payload");
String qualifierExpression = (String) AnnotationUtils.getValue(mappingAnnotation);
if (StringUtils.hasText(qualifierExpression)) {
@@ -736,14 +735,12 @@ public class MessagingMethodInvokerHelper<T> extends AbstractExpressionEvaluator
this.setExclusiveTargetParameterType(parameterTypeDescriptor, methodParameter);
}
}
else if (annotationType.equals(org.springframework.integration.annotation.Headers.class)
|| annotationType.equals(Headers.class)) {
else if (annotationType.equals(Headers.class)) {
Assert.isTrue(Map.class.isAssignableFrom(parameterType),
"The @Headers annotation can only be applied to a Map-typed parameter.");
sb.append("headers");
}
else if (annotationType.equals(org.springframework.integration.annotation.Header.class)
|| annotationType.equals(Header.class)) {
else if (annotationType.equals(Header.class)) {
sb.append(this.determineHeaderExpression(mappingAnnotation, methodParameter));
}
}

View File

@@ -1612,19 +1612,6 @@
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="delay-header-name" type="xsd:string">
<xsd:annotation>
<xsd:documentation>
[DEPRECATED]Specify the name of the header that should contain the delay value.
This value can either
represent the number of milliseconds to delay counting from the current
time or it can be an
absolute Date until
which the Message should be delayed.
This attribute is deprecated in favor of an 'expression' attribute or sub-element.
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="scheduler" type="xsd:string">
<xsd:annotation>
<xsd:documentation>
@@ -2499,11 +2486,7 @@
<xsd:annotation>
<xsd:documentation>
Optional reference to a JsonObjectMapper instance.
By default, a JsonObjectMapper that uses a Jackson 2 ObjectMapper, or Jackson ObjectMapper
implementation is used, depending on the jars on the classpath.
Note: for backward compatibility, this attribute can take a reference to the Jackson 1 ObjectMapper bean.
This Jackson 1 ObjectMapper backward compatibility is deprecated
and will be removed in the Spring Integration 3.1 or above.
By default, a JsonObjectMapper that uses a Jackson 2 ObjectMapper.
</xsd:documentation>
<xsd:appinfo>
<tool:annotation kind="ref">
@@ -2566,11 +2549,7 @@
<xsd:annotation>
<xsd:documentation>
Optional reference to a JsonObjectMapper instance.
By default, a JsonObjectMapper that uses a Jackson 2 ObjectMapper, or Jackson ObjectMapper
implementation is used, depending on the jars on the classpath.
Note: for backward compatibility this attribute can take a reference to the Jackson 1 ObjectMapper bean.
This Jackson 1 ObjectMapper backward compatibility is deprecated
and will be removed in the Spring Integration 3.1 or above.
By default, a JsonObjectMapper that uses a Jackson 2 ObjectMapper.
</xsd:documentation>
<xsd:appinfo>
<tool:annotation kind="ref">

View File

@@ -20,7 +20,7 @@
input-channel="input"
output-channel="output"
default-delay="1234"
delay-header-name="foo"
expression="headers.foo"
order="99"
send-timeout="987"/>

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-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.
@@ -68,10 +68,9 @@ public class DelayerParserTests {
assertEquals(99, delayHandler.getOrder());
assertEquals(context.getBean("output"), TestUtils.getPropertyValue(delayHandler, "outputChannel"));
assertEquals(new Long(1234), TestUtils.getPropertyValue(delayHandler, "defaultDelay", Long.class));
assertEquals("foo", TestUtils.getPropertyValue(delayHandler, "delayHeaderName"));
//INT-2243
assertNotNull(TestUtils.getPropertyValue(delayHandler, "delayExpression"));
assertEquals("headers['foo']", TestUtils.getPropertyValue(delayHandler, "delayExpression", Expression.class).getExpressionString());
assertEquals("headers.foo", TestUtils.getPropertyValue(delayHandler, "delayExpression", Expression.class).getExpressionString());
assertEquals(new Long(987), TestUtils.getPropertyValue(delayHandler, "messagingTemplate.sendTimeout", Long.class));
assertNull(TestUtils.getPropertyValue(delayHandler, "taskScheduler"));
}
@@ -141,7 +140,6 @@ public class DelayerParserTests {
@Test
public void testInt2243Expression() {
DelayHandler delayHandler = context.getBean("delayerWithExpression.handler", DelayHandler.class);
assertNull(TestUtils.getPropertyValue(delayHandler, "delayHeaderName"));
assertEquals("100", TestUtils.getPropertyValue(delayHandler, "delayExpression", Expression.class).getExpressionString());
assertFalse(TestUtils.getPropertyValue(delayHandler, "ignoreExpressionFailures", Boolean.class));
}
@@ -149,7 +147,6 @@ public class DelayerParserTests {
@Test
public void testInt2243ExpressionSubElement() {
DelayHandler delayHandler = context.getBean("delayerWithExpressionSubElement.handler", DelayHandler.class);
assertNull(TestUtils.getPropertyValue(delayHandler, "delayHeaderName"));
assertEquals("headers.timestamp + 1000", TestUtils.getPropertyValue(delayHandler, "delayExpression", Expression.class).getExpressionString());
}

View File

@@ -18,7 +18,7 @@
input-channel="inputA"
output-channel="outputA"
default-delay="1000"
delay-header-name="foo"
expression="headers.foo"
order="99"
send-timeout="1000"/>

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-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.
@@ -215,10 +215,6 @@ public class GatewayProxyMessageMappingTests {
void payloadAndHeaderMapWithoutAnnotations(String s, Map<String, Object> map);
@SuppressWarnings("deprecation")
void payloadAndHeaderMapWithAnnotationsDeprecated(@org.springframework.integration.annotation.Payload String s,
@org.springframework.integration.annotation.Headers Map<String, Object> map);
void payloadAndHeaderMapWithAnnotations(@Payload String s, @Headers Map<String, Object> map);
void headerValuesAndPayloadWithAnnotations(@Header("k1") String x, @Payload String s, @Header("k2") String y);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-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.
@@ -34,6 +34,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* @author Iwein Fuld
* @author Gunnar Hillert
* @author Artem Bilan
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)