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

@@ -1,29 +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.amqp;
/**
* Pre-defined names and prefixes to be used for setting and/or retrieving AMQP
* MessageProperties from/to integration Message Headers.
* @deprecated in favor of {@link org.springframework.amqp.support.AmqpHeaders}.
* Will be removed in a future release.
*
* @author Mark Fisher
*/
@Deprecated
public abstract class AmqpHeaders extends org.springframework.amqp.support.AmqpHeaders {
}

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.
@@ -18,6 +18,7 @@ package org.springframework.integration.amqp.config;
import org.w3c.dom.Element;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.ParserContext;
@@ -33,6 +34,7 @@ import org.springframework.util.StringUtils;
* @author Mark Fisher
* @author Oleg Zhurakousky
* @author Gary Russell
* @author Artem Bilan
* @since 2.1
*/
public class AmqpOutboundChannelAdapterParser extends AbstractOutboundChannelAdapterParser {
@@ -51,15 +53,28 @@ public class AmqpOutboundChannelAdapterParser extends AbstractOutboundChannelAda
}
builder.addConstructorArgReference(amqpTemplateRef);
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "exchange-name", true);
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "exchange-name-expression");
BeanDefinition exchangeNameExpression =
IntegrationNamespaceUtils.createExpressionDefIfAttributeDefined("exchange-name-expression", element);
if (exchangeNameExpression != null) {
builder.addPropertyValue("exchangeNameExpression", exchangeNameExpression);
}
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "routing-key", true);
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "routing-key-expression");
BeanDefinition routingKeyExpression =
IntegrationNamespaceUtils.createExpressionDefIfAttributeDefined("routing-key-expression", element);
if (routingKeyExpression != null) {
builder.addPropertyValue("routingKeyExpression", routingKeyExpression);
}
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "default-delivery-mode");
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "lazy-connect");
IntegrationNamespaceUtils.configureHeaderMapper(element, builder, parserContext, DefaultAmqpHeaderMapper.class, null);
IntegrationNamespaceUtils.configureHeaderMapper(element, builder, parserContext,
DefaultAmqpHeaderMapper.class, null);
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "confirm-correlation-expression");
BeanDefinition confirmCorrelationExpression =
IntegrationNamespaceUtils.createExpressionDefIfAttributeDefined("confirm-correlation-expression", element);
if (confirmCorrelationExpression != null) {
builder.addPropertyValue("confirmCorrelationExpression", confirmCorrelationExpression);
}
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "confirm-ack-channel");
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "confirm-nack-channel");
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "return-channel");

View File

@@ -15,6 +15,7 @@ package org.springframework.integration.amqp.config;
import org.w3c.dom.Element;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.integration.amqp.outbound.AmqpOutboundEndpoint;
@@ -50,10 +51,18 @@ public class AmqpOutboundGatewayParser extends AbstractConsumerEndpointParser {
}
builder.addConstructorArgReference(amqpTemplateRef);
builder.addPropertyValue("expectReply", true);
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "exchange-name");
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "exchange-name-expression");
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "routing-key");
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "routing-key-expression");
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "exchange-name", true);
BeanDefinition exchangeNameExpression =
IntegrationNamespaceUtils.createExpressionDefIfAttributeDefined("exchange-name-expression", element);
if (exchangeNameExpression != null) {
builder.addPropertyValue("exchangeNameExpression", exchangeNameExpression);
}
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "routing-key", true);
BeanDefinition routingKeyExpression =
IntegrationNamespaceUtils.createExpressionDefIfAttributeDefined("routing-key-expression", element);
if (routingKeyExpression != null) {
builder.addPropertyValue("routingKeyExpression", routingKeyExpression);
}
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "reply-timeout", "sendTimeout");
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "requires-reply");
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "default-delivery-mode");
@@ -61,7 +70,12 @@ public class AmqpOutboundGatewayParser extends AbstractConsumerEndpointParser {
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "reply-channel", "outputChannel");
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "return-channel");
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "confirm-correlation-expression");
BeanDefinition confirmCorrelationExpression =
IntegrationNamespaceUtils.createExpressionDefIfAttributeDefined("confirm-correlation-expression", element);
if (confirmCorrelationExpression != null) {
builder.addPropertyValue("confirmCorrelationExpression", confirmCorrelationExpression);
}
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "confirm-ack-channel");
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "confirm-nack-channel");

View File

@@ -33,9 +33,6 @@ import org.springframework.context.ApplicationListener;
import org.springframework.context.Lifecycle;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.expression.Expression;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.SpelParserConfiguration;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.integration.amqp.support.AmqpHeaderMapper;
import org.springframework.integration.amqp.support.DefaultAmqpHeaderMapper;
import org.springframework.integration.channel.NullChannel;
@@ -60,10 +57,6 @@ public class AmqpOutboundEndpoint extends AbstractReplyProducingMessageHandler
implements RabbitTemplate.ConfirmCallback, ReturnCallback,
ApplicationListener<ContextRefreshedEvent>, Lifecycle {
private static final ExpressionParser expressionParser =
new SpelExpressionParser(new SpelParserConfiguration(true, true));
private final AmqpTemplate amqpTemplate;
private volatile boolean expectReply;
@@ -112,22 +105,29 @@ public class AmqpOutboundEndpoint extends AbstractReplyProducingMessageHandler
}
/**
* @deprecated in favor of {@link #setExpressionExchangeName}. Will be changed in a future release
* to use an {@link Expression} parameter.
* @param exchangeNameExpression the expression to set.
* @param exchangeNameExpression the expression to use.
* @since 4.3
*/
@Deprecated
public void setExchangeNameExpression(String exchangeNameExpression) {
Assert.hasText(exchangeNameExpression);
this.exchangeNameExpression = expressionParser.parseExpression(exchangeNameExpression);
public void setExchangeNameExpression(Expression exchangeNameExpression) {
this.exchangeNameExpression = exchangeNameExpression;
}
/**
* Temporary, will be changed to {@link #setExchangeNameExpression} in a future release.
* @param exchangeNameExpression the expression to set.
* @param exchangeNameExpression the String in SpEL syntax.
* @since 4.3
*/
public void setExchangeNameExpressionString(String exchangeNameExpression) {
Assert.hasText(exchangeNameExpression, "'exchangeNameExpression' must not be empty");
this.exchangeNameExpression = EXPRESSION_PARSER.parseExpression(exchangeNameExpression);
}
/**
* @param exchangeNameExpression the expression to set.
* @deprecated in favor of {@link #setExchangeNameExpression}.
*/
@Deprecated
public void setExpressionExchangeName(Expression exchangeNameExpression) {
this.exchangeNameExpression = exchangeNameExpression;
setExchangeNameExpression(exchangeNameExpression);
}
public void setRoutingKey(String routingKey) {
@@ -136,22 +136,29 @@ public class AmqpOutboundEndpoint extends AbstractReplyProducingMessageHandler
}
/**
* @deprecated in favor of {@link #setExpressionRoutingKey}. Will be changed in a future release
* to use an {@link Expression} parameter.
* @param routingKeyExpression the expression to set.
* @param routingKeyExpression the expression to use.
* @since 4.3
*/
@Deprecated
public void setRoutingKeyExpression(String routingKeyExpression) {
Assert.hasText(routingKeyExpression);
setExpressionRoutingKey(expressionParser.parseExpression(routingKeyExpression));
public void setRoutingKeyExpression(Expression routingKeyExpression) {
this.routingKeyExpression = routingKeyExpression;
}
/**
* Temporary, will be changed to {@code setRoutingKeyExpression} in a future release.
* @param routingKeyExpression the expression to set.
* @param routingKeyExpression the String in SpEL syntax.
* @since 4.3
*/
public void setRoutingKeyExpressionString(String routingKeyExpression) {
Assert.hasText(routingKeyExpression, "'routingKeyExpression' must not be empty");
this.routingKeyExpression = EXPRESSION_PARSER.parseExpression(routingKeyExpression);
}
/**
* @param routingKeyExpression the expression to set.
* @deprecated in favor of {@link #setRoutingKeyExpression}.
*/
@Deprecated
public void setExpressionRoutingKey(Expression routingKeyExpression) {
this.routingKeyExpression = routingKeyExpression;
setRoutingKeyExpression(routingKeyExpression);
}
public void setExpectReply(boolean expectReply) {
@@ -159,22 +166,29 @@ public class AmqpOutboundEndpoint extends AbstractReplyProducingMessageHandler
}
/**
* @deprecated in favor of {@link #setExpressionConfirmCorrelation}. Will be changed in a future release
* to use {@link Expression} parameter.
* @param confirmCorrelationExpression the expression to set.
* @param confirmCorrelationExpression the expression to use.
* @since 4.3
*/
@Deprecated
public void setConfirmCorrelationExpression(String confirmCorrelationExpression) {
Assert.hasText(confirmCorrelationExpression);
setExpressionConfirmCorrelation(expressionParser.parseExpression(confirmCorrelationExpression));
public void setConfirmCorrelationExpression(Expression confirmCorrelationExpression) {
this.confirmCorrelationExpression = confirmCorrelationExpression;
}
/**
* Temporary, will be changed to {@code setConfirmCorrelationExpression} in a future release.
* @param confirmCorrelationExpression the expression to set.
* @param confirmCorrelationExpression the String in SpEL syntax.
* @since 4.3
*/
public void setConfirmCorrelationExpressionString(String confirmCorrelationExpression) {
Assert.hasText(confirmCorrelationExpression, "'confirmCorrelationExpression' must not be empty");
this.confirmCorrelationExpression = EXPRESSION_PARSER.parseExpression(confirmCorrelationExpression);
}
/**
* @param confirmCorrelationExpression the expression to set.
* @deprecated in favor of {@link #setConfirmCorrelationExpression}.
*/
@Deprecated
public void setExpressionConfirmCorrelation(Expression confirmCorrelationExpression) {
this.confirmCorrelationExpression = confirmCorrelationExpression;
setConfirmCorrelationExpression(this.confirmCorrelationExpression);
}
public void setConfirmAckChannel(MessageChannel ackChannel) {

View File

@@ -254,7 +254,7 @@ public class AmqpOutboundChannelAdapterParserTests {
}
@Test
public void testInt2773WithDefaultAmqpTemplateExchangeAndRoutingLey() throws IOException {
public void testInt2773WithDefaultAmqpTemplateExchangeAndRoutingKey() throws IOException {
ConnectionFactory connectionFactory = context.getBean(ConnectionFactory.class);
Connection mockConnection = mock(Connection.class);
Channel mockChannel = mock(Channel.class);

View File

@@ -33,6 +33,8 @@ import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.support.StandardEvaluationContext;
import org.springframework.integration.amqp.outbound.AmqpOutboundEndpoint;
import org.springframework.integration.config.IntegrationEvaluationContextFactoryBean;
@@ -54,6 +56,8 @@ import org.springframework.util.ClassUtils;
*/
public class OutboundGatewayTests {
private static final ExpressionParser PARSER = new SpelExpressionParser();
private final ClassPathXmlApplicationContext context =
new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-context.xml", getClass());
@@ -77,7 +81,7 @@ public class OutboundGatewayTests {
}
@Test
@SuppressWarnings({"unchecked", "deprecation"})
@SuppressWarnings("unchecked")
public void testExpressionsBeanResolver() throws Exception {
ApplicationContext context = mock(ApplicationContext.class);
doAnswer(new Answer<Object>() {
@@ -100,9 +104,9 @@ public class OutboundGatewayTests {
.thenReturn(evalContext);
RabbitTemplate template = mock(RabbitTemplate.class);
AmqpOutboundEndpoint endpoint = new AmqpOutboundEndpoint(template);
endpoint.setRoutingKeyExpression("@foo");
endpoint.setExchangeNameExpression("@bar");
endpoint.setConfirmCorrelationExpression("@baz");
endpoint.setRoutingKeyExpression(PARSER.parseExpression("@foo"));
endpoint.setExchangeNameExpression(PARSER.parseExpression("@bar"));
endpoint.setConfirmCorrelationExpressionString("@baz");
endpoint.setBeanFactory(context);
endpoint.afterPropertiesSet();
Message<?> message = new GenericMessage<String>("Hello, world!");

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)

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 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.
@@ -29,6 +29,7 @@ import org.springframework.integration.event.inbound.ApplicationEventListeningMe
* @author Oleg Zhurakousky
* @author Mark Fisher
* @author Gary Russell
* @author Artem Bilan
* @since 2.0
*/
public class EventInboundChannelAdapterParser extends AbstractChannelAdapterParser {
@@ -38,9 +39,10 @@ public class EventInboundChannelAdapterParser extends AbstractChannelAdapterPars
BeanDefinitionBuilder adapterBuilder = BeanDefinitionBuilder
.rootBeanDefinition(ApplicationEventListeningMessageProducer.class);
adapterBuilder.addPropertyReference("outputChannel", channelName);
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(adapterBuilder, element, "error-channel", "errorChannel");
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(adapterBuilder, element, "error-channel");
IntegrationNamespaceUtils.setValueIfAttributeDefined(adapterBuilder, element, "event-types");
IntegrationNamespaceUtils.setValueIfAttributeDefined(adapterBuilder, element, "payload-expression");
IntegrationNamespaceUtils.setValueIfAttributeDefined(adapterBuilder, element, "payload-expression",
"payloadExpressionString");
return adapterBuilder.getBeanDefinition();
}

View File

@@ -44,6 +44,7 @@ import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.support.GenericApplicationContext;
import org.springframework.core.ResolvableType;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHandlingException;
import org.springframework.integration.channel.DirectChannel;
@@ -61,6 +62,8 @@ import org.springframework.integration.test.util.TestUtils;
*/
public class ApplicationEventListeningMessageProducerTests {
private static final SpelExpressionParser PARSER = new SpelExpressionParser();
@Test
public void anyApplicationEventSentByDefault() {
QueueChannel channel = new QueueChannel();
@@ -135,11 +138,10 @@ public class ApplicationEventListeningMessageProducerTests {
}
@Test
@SuppressWarnings("deprecation")
public void payloadExpressionEvaluatedAgainstApplicationEvent() {
QueueChannel channel = new QueueChannel();
ApplicationEventListeningMessageProducer adapter = new ApplicationEventListeningMessageProducer();
adapter.setPayloadExpression("'received: ' + source");
adapter.setPayloadExpression(PARSER.parseExpression("'received: ' + source"));
adapter.setOutputChannel(channel);
GenericApplicationContext ctx = TestUtils.createTestApplicationContext();

View File

@@ -21,7 +21,6 @@ import org.w3c.dom.Element;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.integration.config.ExpressionFactoryBean;
import org.springframework.integration.config.xml.AbstractConsumerEndpointParser;
import org.springframework.integration.config.xml.IntegrationNamespaceUtils;
import org.springframework.integration.file.filters.RegexPatternFileListFilter;
@@ -74,15 +73,11 @@ public abstract class AbstractRemoteFileOutboundGatewayParser extends AbstractCo
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "auto-create-local-directory");
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "order");
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "rename-expression");
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "rename-expression",
"renameExpressionString");
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "requires-reply");
String localFileGeneratorExpression = element.getAttribute("local-filename-generator-expression");
if (StringUtils.hasText(localFileGeneratorExpression)) {
BeanDefinitionBuilder localFileGeneratorExpressionBuilder =
BeanDefinitionBuilder.genericBeanDefinition(ExpressionFactoryBean.class);
localFileGeneratorExpressionBuilder.addConstructorArgValue(localFileGeneratorExpression);
builder.addPropertyValue("localFilenameGeneratorExpression", localFileGeneratorExpressionBuilder.getBeanDefinition());
}
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "local-filename-generator-expression",
"localFilenameGeneratorExpressionString");
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "mode", "fileExistsMode");
return builder;
}

View File

@@ -374,30 +374,49 @@ public abstract class AbstractRemoteFileOutboundGateway<F> extends AbstractReply
}
/**
* @deprecated in favor of {@link #setExpressionRename}. Will be changed in a future release
* to use an {@link Expression} parameter.
* @param expression the expression to set.
* @param renameExpression the expression to use.
* @since 4.3
*/
@Deprecated
public void setRenameExpression(String expression) {
Assert.notNull(expression, "'expression' cannot be null");
setExpressionRename(new SpelExpressionParser().parseExpression(expression));
public void setRenameExpression(Expression renameExpression) {
this.renameProcessor = new ExpressionEvaluatingMessageProcessor<String>(renameExpression);
}
/**
* Temporary, will be changed to {@link #setRenameExpression} in a future release.
* @param expression the expression to set.
* @param renameExpression the String in SpEL syntax.
* @since 4.3
*/
public void setExpressionRename(Expression expression) {
Assert.notNull(expression, "'expression' cannot be null");
this.renameProcessor = new ExpressionEvaluatingMessageProcessor<String>(expression);
public void setRenameExpressionString(String renameExpression) {
Assert.hasText(renameExpression, "'renameExpression' cannot be empty");
setRenameExpression(EXPRESSION_PARSER.parseExpression(renameExpression));
}
/**
* @param expression the expression to set.
* @deprecated in favor of {@link #setRenameExpression}.
*/
@Deprecated
public void setExpressionRename(Expression expression) {
setRenameExpression(expression);
}
/**
* @param localFilenameGeneratorExpression the expression to use.
* @since 3.0
*/
public void setLocalFilenameGeneratorExpression(Expression localFilenameGeneratorExpression) {
Assert.notNull(localFilenameGeneratorExpression, "'localFilenameGeneratorExpression' must not be null");
this.localFilenameGeneratorExpression = localFilenameGeneratorExpression;
}
/**
* @param localFilenameGeneratorExpression the String in SpEL syntax.
* @since 4.3
*/
public void setLocalFilenameGeneratorExpressionString(String localFilenameGeneratorExpression) {
Assert.hasText(localFilenameGeneratorExpression, "'localFilenameGeneratorExpression' must not be empty");
this.localFilenameGeneratorExpression = EXPRESSION_PARSER.parseExpression(localFilenameGeneratorExpression);
}
/**
* Determine the action to take when using GET and MGET operations when the file
* already exists locally, or PUT and MPUT when the file exists on the remote

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.
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.file.remote.gateway;
import static org.hamcrest.Matchers.anyOf;
@@ -57,6 +58,7 @@ import org.mockito.stubbing.Answer;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.expression.common.LiteralExpression;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.integration.file.FileHeaders;
import org.springframework.integration.file.filters.AbstractSimplePatternFileListFilter;
import org.springframework.integration.file.remote.AbstractFileInfo;
@@ -74,12 +76,15 @@ import org.springframework.messaging.support.GenericMessage;
/**
* @author Gary Russell
* @author liujiong
* @author Liu Jiong
* @author Artem Bilan
* @since 2.1
*/
@SuppressWarnings("rawtypes")
public class RemoteFileOutboundGatewayTests {
private static final SpelExpressionParser PARSER = new SpelExpressionParser();
private final String tmpDir = System.getProperty("java.io.tmpdir");
@Rule
@@ -278,12 +283,11 @@ public class RemoteFileOutboundGatewayTests {
}
@Test
@SuppressWarnings("deprecation")
public void testMoveWithExpression() throws Exception {
SessionFactory sessionFactory = mock(SessionFactory.class);
TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway
(sessionFactory, "mv", "payload");
gw.setRenameExpression("payload.substring(1)");
gw.setRenameExpression(PARSER.parseExpression("payload.substring(1)"));
gw.afterPropertiesSet();
Session<?> session = mock(Session.class);
final AtomicReference<String> args = new AtomicReference<String>();
@@ -304,12 +308,11 @@ public class RemoteFileOutboundGatewayTests {
}
@Test
@SuppressWarnings("deprecation")
public void testMoveWithMkDirs() throws Exception {
SessionFactory sessionFactory = mock(SessionFactory.class);
TestRemoteFileOutboundGateway gw = new TestRemoteFileOutboundGateway
(sessionFactory, "mv", "payload");
gw.setRenameExpression("'foo/bar/baz'");
gw.setRenameExpression(PARSER.parseExpression("'foo/bar/baz'"));
gw.afterPropertiesSet();
Session<?> session = mock(Session.class);
final AtomicReference<String> args = new AtomicReference<String>();
@@ -1009,214 +1012,216 @@ public class RemoteFileOutboundGatewayTests {
equalTo("foo/baz.txt"), equalTo("foo/qux.txt"), equalTo("foo/" + dir1.getName() + "/" + file3.getName())));
}
}
abstract static class TestSession implements Session<TestLsEntry> {
abstract class TestSession implements org.springframework.integration.file.remote.session.Session<TestLsEntry> {
private boolean open;
private boolean open;
@Override
public boolean remove(String path) throws IOException {
return false;
@Override
public boolean remove(String path) throws IOException {
return false;
}
@Override
public TestLsEntry[] list(String path) throws IOException {
return null;
}
@Override
public void read(String source, OutputStream outputStream)
throws IOException {
}
@Override
public void write(InputStream inputStream, String destination)
throws IOException {
}
@Override
public void append(InputStream inputStream, String destination)
throws IOException {
}
@Override
public boolean mkdir(String directory) throws IOException {
return true;
}
@Override
public boolean rmdir(String directory) throws IOException {
return true;
}
@Override
public void rename(String pathFrom, String pathTo)
throws IOException {
}
@Override
public void close() {
open = false;
}
@Override
public boolean isOpen() {
return open;
}
@Override
public boolean exists(String path) throws IOException {
return true;
}
@Override
public String[] listNames(String path) throws IOException {
return null;
}
@Override
public InputStream readRaw(String source) throws IOException {
return null;
}
@Override
public boolean finalizeRaw() throws IOException {
return false;
}
@Override
public Object getClientInstance() {
return null;
}
}
@Override
public TestLsEntry[] list(String path) throws IOException {
return null;
static class TestRemoteFileOutboundGateway extends AbstractRemoteFileOutboundGateway<TestLsEntry> {
@SuppressWarnings({"rawtypes", "unchecked"})
public TestRemoteFileOutboundGateway(SessionFactory sessionFactory,
String command, String expression) {
super(sessionFactory, Command.toCommand(command), expression);
this.setBeanFactory(mock(BeanFactory.class));
}
public TestRemoteFileOutboundGateway(RemoteFileTemplate<TestLsEntry> remoteFileTemplate, String command,
String expression) {
super(remoteFileTemplate, command, expression);
this.setBeanFactory(mock(BeanFactory.class));
}
@Override
protected boolean isDirectory(TestLsEntry file) {
return file.isDirectory();
}
@Override
protected boolean isLink(TestLsEntry file) {
return file.isLink();
}
@Override
protected String getFilename(TestLsEntry file) {
return file.getFilename();
}
@Override
protected String getFilename(AbstractFileInfo<TestLsEntry> file) {
return file.getFilename();
}
@Override
protected long getModified(TestLsEntry file) {
return file.getModified();
}
@Override
protected List<AbstractFileInfo<TestLsEntry>> asFileInfoList(
Collection<TestLsEntry> files) {
return new ArrayList<AbstractFileInfo<TestLsEntry>>(files);
}
@Override
protected TestLsEntry enhanceNameWithSubDirectory(TestLsEntry file, String directory) {
file.setFilename(directory + file.getFilename());
return file;
}
}
@Override
public void read(String source, OutputStream outputStream)
throws IOException {
static class TestLsEntry extends AbstractFileInfo<TestLsEntry> {
private volatile String filename;
private final long size;
private final boolean dir;
private final boolean link;
private final long modified;
private final String permissions;
public TestLsEntry(String filename, long size, boolean dir, boolean link,
long modified, String permissions) {
this.filename = filename;
this.size = size;
this.dir = dir;
this.link = link;
this.modified = modified;
this.permissions = permissions;
}
@Override
public boolean isDirectory() {
return this.dir;
}
@Override
public long getModified() {
return this.modified;
}
@Override
public String getFilename() {
return this.filename;
}
@Override
public boolean isLink() {
return this.link;
}
@Override
public long getSize() {
return this.size;
}
@Override
public String getPermissions() {
return this.permissions;
}
@Override
public TestLsEntry getFileInfo() {
return this;
}
public void setFilename(String filename) {
this.filename = filename;
}
}
@Override
public void write(InputStream inputStream, String destination)
throws IOException {
}
static class TestPatternFilter extends AbstractSimplePatternFileListFilter<TestLsEntry> {
@Override
public void append(InputStream inputStream, String destination)
throws IOException {
}
public TestPatternFilter(String path) {
super(path);
}
@Override
public boolean mkdir(String directory) throws IOException {
return true;
}
@Override
protected String getFilename(TestLsEntry file) {
return file.getFilename();
}
@Override
public boolean rmdir(String directory) throws IOException {
return true;
}
@Override
public void rename(String pathFrom, String pathTo)
throws IOException {
}
@Override
public void close() {
open = false;
}
@Override
public boolean isOpen() {
return open;
}
@Override
public boolean exists(String path) throws IOException {
return true;
}
@Override
public String[] listNames(String path) throws IOException {
return null;
}
@Override
public InputStream readRaw(String source) throws IOException {
return null;
}
@Override
public boolean finalizeRaw() throws IOException {
return false;
}
@Override
public Object getClientInstance() {
return null;
}
}
class TestRemoteFileOutboundGateway extends AbstractRemoteFileOutboundGateway<TestLsEntry> {
@SuppressWarnings({"rawtypes", "unchecked"})
public TestRemoteFileOutboundGateway(SessionFactory sessionFactory,
String command, String expression) {
super(sessionFactory, Command.toCommand(command), expression);
this.setBeanFactory(mock(BeanFactory.class));
}
public TestRemoteFileOutboundGateway(RemoteFileTemplate<TestLsEntry> remoteFileTemplate, String command,
String expression) {
super(remoteFileTemplate, command, expression);
this.setBeanFactory(mock(BeanFactory.class));
}
@Override
protected boolean isDirectory(TestLsEntry file) {
return file.isDirectory();
}
@Override
protected boolean isLink(TestLsEntry file) {
return file.isLink();
}
@Override
protected String getFilename(TestLsEntry file) {
return file.getFilename();
}
@Override
protected String getFilename(AbstractFileInfo<TestLsEntry> file) {
return file.getFilename();
}
@Override
protected long getModified(TestLsEntry file) {
return file.getModified();
}
@Override
protected List<AbstractFileInfo<TestLsEntry>> asFileInfoList(
Collection<TestLsEntry> files) {
return new ArrayList<AbstractFileInfo<TestLsEntry>>(files);
}
@Override
protected TestLsEntry enhanceNameWithSubDirectory(TestLsEntry file, String directory) {
file.setFilename(directory + file.getFilename());
return file;
}
}
class TestLsEntry extends AbstractFileInfo<TestLsEntry> {
private volatile String filename;
private final long size;
private final boolean dir;
private final boolean link;
private final long modified;
private final String permissions;
public TestLsEntry(String filename, long size, boolean dir, boolean link,
long modified, String permissions) {
this.filename = filename;
this.size = size;
this.dir = dir;
this.link = link;
this.modified = modified;
this.permissions = permissions;
}
@Override
public boolean isDirectory() {
return this.dir;
}
@Override
public long getModified() {
return this.modified;
}
@Override
public String getFilename() {
return this.filename;
}
@Override
public boolean isLink() {
return this.link;
}
@Override
public long getSize() {
return this.size;
}
@Override
public String getPermissions() {
return this.permissions;
}
@Override
public TestLsEntry getFileInfo() {
return this;
}
public void setFilename(String filename) {
this.filename = filename;
}
}
class TestPatternFilter extends AbstractSimplePatternFileListFilter<TestLsEntry> {
public TestPatternFilter(String path) {
super(path);
}
@Override
protected String getFilename(TestLsEntry file) {
return file.getFilename();
}
}

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. You may obtain a copy of the License at
@@ -10,6 +10,7 @@
* 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.gemfire.config.xml;
import org.w3c.dom.Element;
@@ -25,6 +26,7 @@ import org.springframework.integration.gemfire.inbound.ContinuousQueryMessagePro
* @author David Turanski
* @author Dan Oxlade
* @author Gary Russell
* @author Artem Bilan
* @since 2.1
*
*/
@@ -43,8 +45,6 @@ public class GemfireCqInboundChannelAdapterParser extends AbstractChannelAdapter
private static final String QUERY_ATTRIBUTE = "query";
private static final String PAYLOAD_EXPRESSION_PROPERTY = "payloadExpression";
private static final String EXPRESSION_ATTRIBUTE = "expression";
private static final String SUPPORTED_EVENT_TYPES_PROPERTY = "supportedEventTypes";
@@ -53,11 +53,11 @@ public class GemfireCqInboundChannelAdapterParser extends AbstractChannelAdapter
@Override
protected AbstractBeanDefinition doParse(Element element, ParserContext parserContext, String channelName) {
BeanDefinitionBuilder continuousQueryMesageProducer =
BeanDefinitionBuilder continuousQueryMessageProducer =
BeanDefinitionBuilder.genericBeanDefinition(ContinuousQueryMessageProducer.class);
IntegrationNamespaceUtils.setValueIfAttributeDefined(continuousQueryMesageProducer, element,
EXPRESSION_ATTRIBUTE, PAYLOAD_EXPRESSION_PROPERTY);
IntegrationNamespaceUtils.setValueIfAttributeDefined(continuousQueryMesageProducer, element,
IntegrationNamespaceUtils.setValueIfAttributeDefined(continuousQueryMessageProducer, element,
EXPRESSION_ATTRIBUTE, "payloadExpressionString");
IntegrationNamespaceUtils.setValueIfAttributeDefined(continuousQueryMessageProducer, element,
QUERY_EVENTS_ATTRIBUTE, SUPPORTED_EVENT_TYPES_PROPERTY);
if (!element.hasAttribute(QUERY_LISTENER_CONTAINER_ATTRIBUTE)) {
@@ -69,16 +69,16 @@ public class GemfireCqInboundChannelAdapterParser extends AbstractChannelAdapter
parserContext.getReaderContext().error("'" + QUERY_ATTRIBUTE + "' attribute is required.", element);
}
continuousQueryMesageProducer.addConstructorArgReference(element.getAttribute(QUERY_LISTENER_CONTAINER_ATTRIBUTE));
continuousQueryMesageProducer.addConstructorArgValue(element.getAttribute(QUERY_ATTRIBUTE));
continuousQueryMessageProducer.addConstructorArgReference(element.getAttribute(QUERY_LISTENER_CONTAINER_ATTRIBUTE));
continuousQueryMessageProducer.addConstructorArgValue(element.getAttribute(QUERY_ATTRIBUTE));
continuousQueryMesageProducer.addPropertyReference(OUTPUT_CHANNEL_PROPERTY, channelName);
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(continuousQueryMesageProducer, element,
continuousQueryMessageProducer.addPropertyReference(OUTPUT_CHANNEL_PROPERTY, channelName);
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(continuousQueryMessageProducer, element,
ERROR_CHANNEL_ATTRIBUTE);
IntegrationNamespaceUtils.setValueIfAttributeDefined(continuousQueryMesageProducer, element, QUERY_NAME_ATTRIBUTE);
IntegrationNamespaceUtils.setValueIfAttributeDefined(continuousQueryMesageProducer, element, DURABLE_ATTRIBUTE);
return continuousQueryMesageProducer.getBeanDefinition();
IntegrationNamespaceUtils.setValueIfAttributeDefined(continuousQueryMessageProducer, element, QUERY_NAME_ATTRIBUTE);
IntegrationNamespaceUtils.setValueIfAttributeDefined(continuousQueryMessageProducer, element, DURABLE_ATTRIBUTE);
return continuousQueryMessageProducer.getBeanDefinition();
}
}

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. You may obtain a copy of the License at
@@ -25,6 +25,7 @@ import org.springframework.integration.gemfire.inbound.CacheListeningMessageProd
/**
* @author David Turanski
* @author Gary Russell
* @author Artem Bilan
* @since 2.1
*/
public class GemfireInboundChannelAdapterParser extends AbstractChannelAdapterParser {
@@ -35,8 +36,6 @@ public class GemfireInboundChannelAdapterParser extends AbstractChannelAdapterPa
private static final String REGION_ATTRIBUTE = "region";
private static final String PAYLOAD_EXPRESSION_PROPERTY = "payloadExpression";
private static final String EXPRESSION_ATTRIBUTE = "expression";
private static final String SUPPORTED_EVENT_TYPES_PROPERTY = "supportedEventTypes";
@@ -48,7 +47,7 @@ public class GemfireInboundChannelAdapterParser extends AbstractChannelAdapterPa
BeanDefinitionBuilder listeningMessageProducer =
BeanDefinitionBuilder.genericBeanDefinition(CacheListeningMessageProducer.class);
IntegrationNamespaceUtils.setValueIfAttributeDefined(listeningMessageProducer, element,
EXPRESSION_ATTRIBUTE, PAYLOAD_EXPRESSION_PROPERTY);
EXPRESSION_ATTRIBUTE, "payloadExpressionString");
IntegrationNamespaceUtils.setValueIfAttributeDefined(listeningMessageProducer, element,
CACHE_EVENTS_ATTRIBUTE, SUPPORTED_EVENT_TYPES_PROPERTY);

View File

@@ -27,6 +27,7 @@ import org.springframework.beans.factory.BeanFactory;
import org.springframework.data.gemfire.CacheFactoryBean;
import org.springframework.data.gemfire.RegionAttributesFactoryBean;
import org.springframework.data.gemfire.RegionFactoryBean;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.messaging.Message;
@@ -36,12 +37,14 @@ import com.gemstone.gemfire.cache.Region;
/**
* @author Mark Fisher
* @author Gary Russell
* @author Artem Bilan
* @since 2.1
*/
public class CacheListeningMessageProducerTests {
private static final SpelExpressionParser PARSER = new SpelExpressionParser();
@Test
@SuppressWarnings("deprecation")
public void receiveNewValuePayloadForCreateEvent() throws Exception {
CacheFactoryBean cacheFactoryBean = new CacheFactoryBean();
Cache cache = cacheFactoryBean.getObject();
@@ -55,7 +58,7 @@ public class CacheListeningMessageProducerTests {
Region<String, String> region = regionFactoryBean.getObject();
QueueChannel channel = new QueueChannel();
CacheListeningMessageProducer producer = new CacheListeningMessageProducer(region);
producer.setPayloadExpression("key + '=' + newValue");
producer.setPayloadExpression(PARSER.parseExpression("key + '=' + newValue"));
producer.setOutputChannel(channel);
producer.setBeanFactory(mock(BeanFactory.class));
producer.afterPropertiesSet();
@@ -68,7 +71,6 @@ public class CacheListeningMessageProducerTests {
}
@Test
@SuppressWarnings("deprecation")
public void receiveNewValuePayloadForUpdateEvent() throws Exception {
CacheFactoryBean cacheFactoryBean = new CacheFactoryBean();
Cache cache = cacheFactoryBean.getObject();
@@ -82,7 +84,7 @@ public class CacheListeningMessageProducerTests {
Region<String, String> region = regionFactoryBean.getObject();
QueueChannel channel = new QueueChannel();
CacheListeningMessageProducer producer = new CacheListeningMessageProducer(region);
producer.setPayloadExpression("newValue");
producer.setPayloadExpression(PARSER.parseExpression("newValue"));
producer.setOutputChannel(channel);
producer.setBeanFactory(mock(BeanFactory.class));
producer.afterPropertiesSet();
@@ -99,7 +101,6 @@ public class CacheListeningMessageProducerTests {
}
@Test
@SuppressWarnings("deprecation")
public void receiveOldValuePayloadForDestroyEvent() throws Exception {
CacheFactoryBean cacheFactoryBean = new CacheFactoryBean();
Cache cache = cacheFactoryBean.getObject();
@@ -114,7 +115,7 @@ public class CacheListeningMessageProducerTests {
QueueChannel channel = new QueueChannel();
CacheListeningMessageProducer producer = new CacheListeningMessageProducer(region);
producer.setSupportedEventTypes(EventType.DESTROYED);
producer.setPayloadExpression("oldValue");
producer.setPayloadExpression(PARSER.parseExpression("oldValue"));
producer.setOutputChannel(channel);
producer.setBeanFactory(mock(BeanFactory.class));
producer.afterPropertiesSet();
@@ -129,7 +130,6 @@ public class CacheListeningMessageProducerTests {
}
@Test
@SuppressWarnings("deprecation")
public void receiveOldValuePayloadForInvalidateEvent() throws Exception {
CacheFactoryBean cacheFactoryBean = new CacheFactoryBean();
Cache cache = cacheFactoryBean.getObject();
@@ -144,7 +144,7 @@ public class CacheListeningMessageProducerTests {
QueueChannel channel = new QueueChannel();
CacheListeningMessageProducer producer = new CacheListeningMessageProducer(region);
producer.setSupportedEventTypes(EventType.INVALIDATED);
producer.setPayloadExpression("key + ' was ' + oldValue");
producer.setPayloadExpression(PARSER.parseExpression("key + ' was ' + oldValue"));
producer.setOutputChannel(channel);
producer.setBeanFactory(mock(BeanFactory.class));
producer.afterPropertiesSet();
@@ -164,4 +164,5 @@ public class CacheListeningMessageProducerTests {
attributesFactoryBean.afterPropertiesSet();
regionFactoryBean.setAttributes(attributesFactoryBean.getObject());
}
}

View File

@@ -16,16 +16,17 @@ package org.springframework.integration.gemfire.inbound;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.data.gemfire.listener.ContinuousQueryListenerContainer;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHandler;
import org.springframework.messaging.MessagingException;
import org.junit.Before;
import org.junit.Test;
import com.gemstone.gemfire.cache.Operation;
import com.gemstone.gemfire.cache.query.CqEvent;
import com.gemstone.gemfire.cache.query.CqQuery;
@@ -38,6 +39,8 @@ import com.gemstone.gemfire.cache.query.internal.CqQueryImpl;
*/
public class ContinuousQueryMessageProducerTests {
private static final SpelExpressionParser PARSER = new SpelExpressionParser();
ContinuousQueryListenerContainer queryListenerContainer;
ContinuousQueryMessageProducer cqMessageProducer;
@@ -87,10 +90,9 @@ public class ContinuousQueryMessageProducerTests {
}
@Test
@SuppressWarnings("deprecation")
public void testPayloadExpression() {
CqEvent cqEvent = event(Operation.CREATE, "hello");
cqMessageProducer.setPayloadExpression("newValue.toUpperCase() + ', WORLD'");
cqMessageProducer.setPayloadExpression(PARSER.parseExpression("newValue.toUpperCase() + ', WORLD'"));
cqMessageProducer.afterPropertiesSet();
cqMessageProducer.onEvent(cqEvent);
@@ -100,7 +102,7 @@ public class ContinuousQueryMessageProducerTests {
CqEvent event(final Operation operation, final Object value) {
CqEvent event = new CqEvent() {
return new CqEvent() {
final CqQuery cq = new CqQueryImpl();
@@ -139,8 +141,6 @@ public class ContinuousQueryMessageProducerTests {
}
};
return event;
}
private static class CqMessageHandler implements MessageHandler {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2011 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. You may obtain a copy of the License at
@@ -24,6 +24,7 @@ import org.springframework.messaging.MessagingException;
import org.springframework.messaging.MessageHandler;
import org.springframework.messaging.SubscribableChannel;
import org.springframework.messaging.support.ErrorMessage;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@@ -36,7 +37,9 @@ import com.gemstone.gemfire.internal.cache.DistributedRegion;
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
@DirtiesContext
public class GemfireInboundChannelAdapterTests {
@Autowired
SubscribableChannel channel1;
@@ -58,8 +61,6 @@ public class GemfireInboundChannelAdapterTests {
@Autowired
DistributedRegion region3;
@Test
public void testGemfireInboundChannelAdapterWithExpression() {
@@ -96,23 +97,27 @@ public class GemfireInboundChannelAdapterTests {
region3.put("payload", "payload");
assertEquals(1, errorHandler.count);
}
static class ErrorHandler implements MessageHandler {
public int count = 0;
public void handleMessage(Message<?> message) throws MessagingException {
assertTrue(message instanceof ErrorMessage);
count++;
}
}
static class EventHandler implements MessageHandler {
public Object event = null;
public void handleMessage(Message<?> message) throws MessagingException {
event = message.getPayload();
}
}
}

View File

@@ -432,14 +432,6 @@ public class UnicastSendingMessageHandler extends
this.taskExecutor.execute(this);
}
/**
* @deprecated Use stop() instead.
*/
@Deprecated
public void shutDown() {
this.stop();
}
private void closeSocketIfNeeded() {
if (socket != null) {
socket.close();

View File

@@ -24,7 +24,7 @@
<int:header-enricher>
<int:header name="delay" expression="9000"/>
</int:header-enricher>
<int:delayer id="foo" default-delay="0" delay-header-name="delay"/>
<int:delayer id="foo" default-delay="0" expression="headers.delay"/>
<int:transformer expression="payload"/>
</int:chain>

View File

@@ -26,7 +26,7 @@
<int:header-enricher>
<int:header name="delay" expression="new java.util.Random().nextInt(3000)"/>
</int:header-enricher>
<int:delayer id="foo" default-delay="0" delay-header-name="delay"/>
<int:delayer id="foo" default-delay="0" expression="headers.delay"/>
<int:transformer expression="payload"/>
</int:chain>

View File

@@ -27,7 +27,7 @@
<int:header-enricher>
<int:header name="delay" expression="new java.util.Random().nextInt(3000)"/>
</int:header-enricher>
<int:delayer id="foo" default-delay="0" delay-header-name="delay"/>
<int:delayer id="foo" default-delay="0" expression="headers.delay"/>
<int:transformer expression="payload"/>
</int:chain>

View File

@@ -27,7 +27,7 @@
<int:header-enricher>
<int:header name="delay" expression="new java.util.Random().nextInt(3000)"/>
</int:header-enricher>
<int:delayer id="foo" default-delay="0" delay-header-name="delay"/>
<int:delayer id="foo" default-delay="0" expression="headers.delay"/>
<int:transformer expression="payload"/>
</int:chain>

View File

@@ -26,7 +26,7 @@
<int:header-enricher>
<int:header name="delay" expression="new java.util.Random().nextInt(3000)"/>
</int:header-enricher>
<int:delayer id="foo" default-delay="0" delay-header-name="delay"/>
<int:delayer id="foo" default-delay="0" expression="headers.delay"/>
<int:transformer expression="payload"/>
</int:chain>

View File

@@ -28,7 +28,7 @@
<int:header-enricher>
<int:header name="delay" expression="new java.util.Random().nextInt(3000)"/>
</int:header-enricher>
<int:delayer id="foo" default-delay="0" delay-header-name="delay"/>
<int:delayer id="foo" default-delay="0" expression="headers.delay"/>
<int:transformer expression="payload"/>
</int:chain>

View File

@@ -26,7 +26,7 @@
<int:header-enricher>
<int:header name="delay" expression="new java.util.Random().nextInt(3000)"/>
</int:header-enricher>
<int:delayer id="foo" default-delay="0" delay-header-name="delay"/>
<int:delayer id="foo" default-delay="0" expression="headers.delay"/>
<int:transformer expression="payload"/>
</int:chain>

View File

@@ -27,7 +27,7 @@
<int:header-enricher>
<int:header name="delay" expression="new java.util.Random().nextInt(3000)"/>
</int:header-enricher>
<int:delayer id="foo" default-delay="0" delay-header-name="delay"/>
<int:delayer id="foo" default-delay="0" expression="headers.delay"/>
<int:transformer expression="payload"/>
</int:chain>

View File

@@ -28,7 +28,7 @@
<int:header-enricher>
<int:header name="delay" expression="new java.util.Random().nextInt(3000)"/>
</int:header-enricher>
<int:delayer id="foo" default-delay="0" delay-header-name="delay"/>
<int:delayer id="foo" default-delay="0" expression="headers.delay"/>
<int:transformer expression="payload"/>
</int:chain>

View File

@@ -28,7 +28,7 @@
<int:header-enricher>
<int:header name="delay" expression="new java.util.Random().nextInt(3000)"/>
</int:header-enricher>
<int:delayer id="foo" default-delay="0" delay-header-name="delay"/>
<int:delayer id="foo" default-delay="0" expression="headers.delay"/>
<int:transformer expression="payload"/>
</int:chain>

View File

@@ -27,7 +27,7 @@
<int:header-enricher>
<int:header name="delay" expression="new java.util.Random().nextInt(3000)"/>
</int:header-enricher>
<int:delayer id="foo" default-delay="0" delay-header-name="delay"/>
<int:delayer id="foo" default-delay="0" expression="headers.delay"/>
<int:transformer expression="payload"/>
</int:chain>

View File

@@ -29,7 +29,7 @@
<int:header-enricher>
<int:header name="delay" expression="new java.util.Random().nextInt(3000)"/>
</int:header-enricher>
<int:delayer id="foo" default-delay="0" delay-header-name="delay"/>
<int:delayer id="foo" default-delay="0" expression="headers.delay"/>
<int:transformer expression="payload"/>
</int:chain>

View File

@@ -29,7 +29,7 @@
<int:header-enricher>
<int:header name="delay" expression="0"/>
</int:header-enricher>
<int:delayer id="foo" default-delay="0" delay-header-name="delay"/>
<int:delayer id="foo" default-delay="0" expression="headers.delay"/>
<int:transformer expression="payload"/>
</int:chain>

View File

@@ -28,7 +28,7 @@
<int:header-enricher>
<int:header name="delay" expression="new java.util.Random().nextInt(3000)"/>
</int:header-enricher>
<int:delayer id="foo" default-delay="0" delay-header-name="delay"/>
<int:delayer id="foo" default-delay="0" expression="headers.delay"/>
<int:transformer expression="payload"/>
</int:chain>

View File

@@ -37,7 +37,7 @@
<int:header-enricher>
<int:header name="delay" expression="0"/>
</int:header-enricher>
<int:delayer id="foo" default-delay="0" delay-header-name="delay"/>
<int:delayer id="foo" default-delay="0" expression="headers.delay"/>
<int:transformer expression="payload"/>
</int:chain>

View File

@@ -38,7 +38,7 @@
<int:header-enricher>
<int:header name="delay" expression="new java.util.Random().nextInt(3000)"/>
</int:header-enricher>
<int:delayer id="foo" default-delay="0" delay-header-name="delay"/>
<int:delayer id="foo" default-delay="0" expression="headers.delay"/>
<int:transformer expression="payload"/>
</int:chain>

View File

@@ -29,7 +29,7 @@
<int:header-enricher>
<int:header name="delay" expression="new java.util.Random().nextInt(3000)"/>
</int:header-enricher>
<int:delayer id="foo" default-delay="0" delay-header-name="delay"/>
<int:delayer id="foo" default-delay="0" expression="headers.delay"/>
<int:transformer expression="payload"/>
</int:chain>

View File

@@ -29,7 +29,7 @@
<int:header-enricher>
<int:header name="delay" expression="new java.util.Random().nextInt(3000)"/>
</int:header-enricher>
<int:delayer id="foo" default-delay="0" delay-header-name="delay"/>
<int:delayer id="foo" default-delay="0" expression="headers.delay"/>
<int:transformer expression="payload"/>
</int:chain>

View File

@@ -29,7 +29,7 @@
<int:header-enricher>
<int:header name="delay" expression="new java.util.Random().nextInt(3000)"/>
</int:header-enricher>
<int:delayer id="foo" default-delay="0" delay-header-name="delay"/>
<int:delayer id="foo" default-delay="0" expression="headers.delay"/>
<int:transformer expression="payload"/>
</int:chain>

View File

@@ -25,7 +25,6 @@ import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.integration.config.xml.AbstractPollingInboundChannelAdapterParser;
import org.springframework.integration.config.xml.IntegrationNamespaceUtils;
import org.springframework.integration.jpa.inbound.JpaPollingChannelAdapter;
import org.springframework.util.StringUtils;
/**
* The JPA Inbound Channel adapter parser
@@ -45,22 +44,6 @@ public class JpaInboundChannelAdapterParser extends AbstractPollingInboundChanne
final BeanDefinitionBuilder jpaExecutorBuilder = JpaParserUtils.getJpaExecutorBuilder(element, parserContext);
String maxNumberOfResults = element.getAttribute("max-number-of-results");
boolean hasMaxNumberOfResults = StringUtils.hasText(maxNumberOfResults);
String maxResults = element.getAttribute("max-results");
boolean hasMaxResults = StringUtils.hasText(maxResults);
if (hasMaxNumberOfResults) {
parserContext.getReaderContext().warning("'max-number-of-results' is deprecated in favor of 'max-results'", element);
if (hasMaxResults) {
parserContext.getReaderContext().error("'max-number-of-results' and 'max-results' are mutually exclusive", element);
}
else {
element.setAttribute("max-results", maxNumberOfResults);
}
}
BeanDefinition definition = IntegrationNamespaceUtils
.createExpressionDefinitionFromValueOrExpression("max-results", "max-results-expression",
parserContext, element, false);

View File

@@ -27,7 +27,6 @@
<int:method name="getStudent" request-channel="getStudentChannel" />
<int:method name="getStudentWithException" request-channel="getStudentEndpointWithExceptionChannel"/>
<int:method name="getStudentWithParameters" request-channel="getStudentWithParametersChannel"/>
<int:method name="getAllStudentsDeprecated" request-channel="getAllStudentsChannel" />
<int:method name="getAllStudents" request-channel="getAllStudentsChannel" />
<int:method name="persistStudent" request-channel="persistStudentChannel" />
<int:method name="persistStudentUsingMerge" request-channel="persistStudentUsingMergeChannel" />

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. You may obtain a copy of the License at
@@ -115,11 +115,7 @@ public class JpaOutboundGatewayTests {
@Test
public void getAllStudents() {
List<StudentDomain> students = studentService.getAllStudentsDeprecated();
Assert.assertNotNull(students);
Assert.assertTrue(students.size() == 3);
students = studentService.getAllStudents();
List<StudentDomain> students = studentService.getAllStudents();
Assert.assertNotNull(students);
Assert.assertTrue(students.size() == 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. You may obtain a copy of the License at
@@ -32,10 +32,6 @@ public interface StudentService {
StudentDomain getStudent(Long id);
StudentDomain deleteStudent(StudentDomain student);
@SuppressWarnings("deprecation")
@org.springframework.integration.annotation.Payload("new java.util.Date()")
List<StudentDomain> getAllStudentsDeprecated();
@Payload("new java.util.Date()")
List<StudentDomain> getAllStudents();

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.
@@ -18,6 +18,7 @@ package org.springframework.integration.redis.config;
import org.w3c.dom.Element;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.integration.config.xml.AbstractConsumerEndpointParser;
@@ -70,7 +71,8 @@ public class RedisOutboundGatewayParser extends AbstractConsumerEndpointParser {
}
if (hasArgumentExpressions) {
BeanDefinitionBuilder argumentsBuilder = BeanDefinitionBuilder.genericBeanDefinition(ExpressionArgumentsStrategy.class)
BeanDefinitionBuilder argumentsBuilder =
BeanDefinitionBuilder.genericBeanDefinition(ExpressionArgumentsStrategy.class)
.addConstructorArgValue(argumentExpressions)
.addConstructorArgValue(element.getAttribute("use-command-variable"));
builder.addPropertyValue("argumentsStrategy", argumentsBuilder.getBeanDefinition());
@@ -85,9 +87,14 @@ public class RedisOutboundGatewayParser extends AbstractConsumerEndpointParser {
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "reply-channel", "outputChannel");
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "requires-reply");
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "reply-timeout", "sendTimeout");
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "command-expression");
BeanDefinition expressionDef =
IntegrationNamespaceUtils.createExpressionDefIfAttributeDefined("command-expression", element);
if (expressionDef != null) {
builder.addPropertyValue("commandExpression", expressionDef);
}
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "arguments-serializer");
return builder;
}
}

View File

@@ -72,22 +72,29 @@ public class RedisOutboundGateway extends AbstractReplyProducingMessageHandler {
}
/**
* @deprecated in favor of {@link #setExpressionCommand}. Will be changed in a future release
* to use an {@link Expression} parameter.
* @param commandExpression the expression to set.
* @param commandExpression the String in SpEL syntax.
* @since 4.3
*/
@Deprecated
public void setCommandExpression(String commandExpression) {
Assert.hasText(commandExpression, "'commandExpression' must not be an empty string");
setExpressionCommand(PARSER.parseExpression(commandExpression));
public void setCommandExpression(Expression commandExpression) {
this.commandExpression = commandExpression;
}
/**
* Temporary, will be changed to {@link #setCommandExpression} in a future release.
* @param commandExpression the expression to set.
* @param commandExpression the String in SpEL syntax.
* @since 4.3
*/
public void setCommandExpressionString(String commandExpression) {
Assert.hasText(commandExpression, "'commandExpression' must not be empty");
this.commandExpression = EXPRESSION_PARSER.parseExpression(commandExpression);
}
/**
* @param commandExpression the expression to set.
* @deprecated in favor of {@link #setCommandExpression}.
*/
@Deprecated
public void setExpressionCommand(Expression commandExpression) {
this.commandExpression = commandExpression;
setCommandExpression(commandExpression);
}
public void setArgumentsStrategy(ArgumentsStrategy argumentsStrategy) {

View File

@@ -66,17 +66,6 @@ public class RedisPublishingMessageHandler extends AbstractMessageHandler {
this.messageConverter = messageConverter;
}
/**
* @param defaultTopic The default topic.
*
* @deprecated in favor of {@link #setTopicExpression(Expression)} or {@link #setTopic(String)}
*/
@Deprecated
public void setDefaultTopic(String defaultTopic) {
Assert.hasText(defaultTopic, "'defaultTopic' must not be an empty string.");
this.setTopicExpression(new LiteralExpression(defaultTopic));
}
public void setTopic(String topic) {
Assert.hasText(topic, "'topic' must not be an empty string.");
this.setTopicExpression(new LiteralExpression(topic));

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.
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.redis.rules;
import org.junit.Assume;
@@ -40,6 +41,7 @@ public final class RedisAvailableRule implements MethodRule {
try {
connectionFactory = new JedisConnectionFactory();
connectionFactory.setPort(REDIS_PORT);
connectionFactory.setTimeout(10000);
connectionFactory.afterPropertiesSet();
connectionFactory.getConnection();
connectionFactoryResource.set(connectionFactory);

View File

@@ -1,147 +0,0 @@
/*
* Copyright 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.security.config;
import java.util.Map;
import java.util.regex.Pattern;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.integration.security.channel.ChannelSecurityInterceptor;
import org.springframework.integration.security.channel.ChannelSecurityMetadataSource;
import org.springframework.integration.security.channel.DefaultChannelAccessPolicy;
import org.springframework.security.access.AccessDecisionManager;
import org.springframework.security.access.intercept.AfterInvocationManager;
import org.springframework.security.access.intercept.RunAsManager;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.util.Assert;
/**
* The {@link FactoryBean} for {@code <security:secured-channels/>} JavaConfig variant to provide options
* for {@link ChannelSecurityInterceptor} beans.
*
* @author Artem Bilan
* @since 4.0
* @deprecated in favor of direct {@link ChannelSecurityInterceptor} usage and
* {@link org.springframework.integration.security.channel.SecuredChannel} annotation.
*/
@Deprecated
public class ChannelSecurityInterceptorFactoryBean implements FactoryBean<ChannelSecurityInterceptor>, BeanNameAware, BeanFactoryAware {
private final ChannelSecurityInterceptor interceptor = new ChannelSecurityInterceptor(new ChannelSecurityMetadataSource());
private BeanFactory beanFactory;
private String name;
@Override
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
this.beanFactory = beanFactory;
if (this.interceptor.getAuthenticationManager() == null && beanFactory.containsBean("authenticationManager")) {
this.interceptor.setAuthenticationManager(beanFactory.getBean("authenticationManager", AuthenticationManager.class));
}
if (this.interceptor.getAccessDecisionManager() == null && beanFactory.containsBean("accessDecisionManager")) {
this.interceptor.setAccessDecisionManager(beanFactory.getBean("accessDecisionManager", AccessDecisionManager.class));
}
}
@Override
public void setBeanName(String name) {
this.name = name;
}
public ChannelSecurityInterceptorFactoryBean setAccessDecisionManager(AccessDecisionManager accessDecisionManager) {
interceptor.setAccessDecisionManager(accessDecisionManager);
return this;
}
public ChannelSecurityInterceptorFactoryBean setAfterInvocationManager(AfterInvocationManager afterInvocationManager) {
interceptor.setAfterInvocationManager(afterInvocationManager);
return this;
}
public ChannelSecurityInterceptorFactoryBean setAlwaysReauthenticate(boolean alwaysReauthenticate) {
interceptor.setAlwaysReauthenticate(alwaysReauthenticate);
return this;
}
public ChannelSecurityInterceptorFactoryBean setAuthenticationManager(AuthenticationManager newManager) {
interceptor.setAuthenticationManager(newManager);
return this;
}
public ChannelSecurityInterceptorFactoryBean setPublishAuthorizationSuccess(boolean publishAuthorizationSuccess) {
interceptor.setPublishAuthorizationSuccess(publishAuthorizationSuccess);
return this;
}
public ChannelSecurityInterceptorFactoryBean setRejectPublicInvocations(boolean rejectPublicInvocations) {
interceptor.setRejectPublicInvocations(rejectPublicInvocations);
return this;
}
public ChannelSecurityInterceptorFactoryBean setRunAsManager(RunAsManager runAsManager) {
interceptor.setRunAsManager(runAsManager);
return this;
}
public ChannelSecurityInterceptorFactoryBean setValidateConfigAttributes(boolean validateConfigAttributes) {
interceptor.setValidateConfigAttributes(validateConfigAttributes);
return this;
}
public ChannelSecurityInterceptorFactoryBean accessPolicy(String pattern, String sendAccess) {
return this.accessPolicy(pattern, sendAccess, null);
}
public ChannelSecurityInterceptorFactoryBean accessPolicy(String pattern, String sendAccess, String receiveAccess) {
Assert.hasText(pattern);
((ChannelSecurityMetadataSource) interceptor.obtainSecurityMetadataSource())
.addPatternMapping(Pattern.compile(pattern), new DefaultChannelAccessPolicy(sendAccess, receiveAccess));
return this;
}
public ChannelSecurityInterceptorFactoryBean setAccessPolicies(Map<String, DefaultChannelAccessPolicy> accessPolicies) {
Assert.notNull(accessPolicies);
ChannelSecurityMetadataSource channelSecurityMetadataSource = (ChannelSecurityMetadataSource) interceptor.obtainSecurityMetadataSource();
for (Map.Entry<String, DefaultChannelAccessPolicy> entry : accessPolicies.entrySet()) {
channelSecurityMetadataSource.addPatternMapping(Pattern.compile(entry.getKey()), entry.getValue());
}
return this;
}
@Override
public ChannelSecurityInterceptor getObject() throws Exception {
((AutowireCapableBeanFactory) this.beanFactory).initializeBean(this.interceptor, this.name);
return this.interceptor;
}
@Override
public Class<?> getObjectType() {
return ChannelSecurityInterceptor.class;
}
@Override
public boolean isSingleton() {
return true;
}
}

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.
@@ -302,7 +302,7 @@ public class WebSocketServerTests {
public ApplicationListener<ApplicationEvent> webSocketEventListener() {
ApplicationEventListeningMessageProducer producer = new ApplicationEventListeningMessageProducer();
producer.setEventTypes(PayloadApplicationEvent.class);
producer.setExpressionPayload(new SpelExpressionParser().parseExpression("payload"));
producer.setPayloadExpression(new SpelExpressionParser().parseExpression("payload"));
producer.setOutputChannel(webSocketEvents());
return producer;
}

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.
@@ -17,7 +17,6 @@
package org.springframework.integration.xml;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
/**
@@ -44,15 +43,6 @@ public class AggregatedXmlMessageValidationException extends RuntimeException {
return message.toString();
}
/**
* @return The exception iterator.
* @deprecated in favor of #getExceptions
*/
@Deprecated
public Iterator<Throwable> exceptionIterator() {
return exceptions.iterator();
}
public List<Throwable> getExceptions() {
return Collections.unmodifiableList(exceptions);
}

View File

@@ -279,11 +279,10 @@ Below is a sample xml snippet that shows a sample usage of _inbound-channel-adap
auto-startup="true" <3>
query="select s from Student s" <4>
expect-single-result="true" <5>
max-number-of-results="" <6>
max-results="" <7>
max-results-expression="" <8>
delete-after-poll="true" <9>
flush-after-delete="true"> <10>
max-results="" <6>
max-results-expression="" <7>
delete-after-poll="true" <8>
flush-after-delete="true"> <9>
<int:poller fixed-rate="2000" >
<int:transactional propagation="REQUIRED" transaction-manager="transactionManager"/>
</int:poller>
@@ -309,29 +308,23 @@ If the value is set to `true`, the single entity retrieved is sent as the payloa
If, however, multiple results are returned after setting this to `true`, a `MessagingException` is thrown.
The value defaults to `false`.
<6> _Deprecated_.
Use `max-results` instead.
_Optional_.
<7> This non zero, non negative integer value tells the adapter not to select more than given number of rows on execution of the select operation.
<6> This non zero, non negative integer value tells the adapter not to select more than given number of rows on execution of the select operation.
By default, if this attribute is not set, all the possible records are selected by given query.
This attribute is mutually exclusive with `max-results-expression`.
_Optional_.
<8> An expression, mutually exclusive with `max-results`, that can be used to provide an expression that will be evaluated to find the maximum number of results in a result set.
<7> An expression, mutually exclusive with `max-results`, that can be used to provide an expression that will be evaluated to find the maximum number of results in a result set.
_Optional_.
<9> Set this value to `true` if you want to delete the rows received after execution of the query.
<8> Set this value to `true` if you want to delete the rows received after execution of the query.
Please ensure that the component is operating as part of a transaction.
Otherwise, you may encounter an Exception such as: _java.lang.IllegalArgumentException: Removing
a detached instance ..._
<10> Set this value to `true` if you want to the persistence context immediately after deleting received entities and if you don't want rely on the `EntityManager`'s flushMode.
<9> Set this value to `true` if you want to the persistence context immediately after deleting received entities and if you don't want rely on the `EntityManager`'s flushMode.
The default value is set to `false`.
@@ -844,11 +837,10 @@ _Optional_.
id=""
jpa-operations=""
jpa-query=""
max-number-of-results="" <3>
max-results="" <4>
max-results-expression="" <5>
first-result="" <6>
first-result-expression="" <7>
max-results="" <3>
max-results-expression="" <4>
first-result="" <5>
first-result-expression="" <6>
named-query=""
native-query=""
order=""
@@ -878,27 +870,22 @@ By default the value is `false`.
_Optional_.
<3> _Deprecated_.
Use `max-results` instead.
_Optional_.
<4> This non zero, non negative integer value tells the adapter not to select more than given number of rows on execution of the select operation.
<3> This non zero, non negative integer value tells the adapter not to select more than given number of rows on execution of the select operation.
By default, if this attribute is not set, all the possible records are selected by given query.
This attribute is mutually exclusive with `max-results-expression`.
_Optional_.
<5> An expression, mutually exclusive with `max-results`, that can be used to provide an expression that will be evaluated to find the maximum number of results in a result set.
<4> An expression, mutually exclusive with `max-results`, that can be used to provide an expression that will be evaluated to find the maximum number of results in a result set.
_Optional_.
<6> This non zero, non negative integer value tells the adapter the first record from which the results are to be retrieved This attribute is mutually exclusive to `first-result-expression`.
<5> This non zero, non negative integer value tells the adapter the first record from which the results are to be retrieved This attribute is mutually exclusive to `first-result-expression`.
This attribute is introduced since version 3.0.
_Optional_.
<7> This expression is evaluated against the message to find the position of first record in the result set to be retrieved This attribute is mutually exclusive to `first-result`.
<6> This expression is evaluated against the message to find the position of first record in the result set to be retrieved This attribute is mutually exclusive to `first-result`.
This attribute is introduced since version 3.0.
_Optional_.

View File

@@ -64,12 +64,8 @@ Where this is not the case references to the appropriate beans can be configured
----
Starting with _version 4.2_, the `@SecuredChannel` annotation is available, replacing the deprecated
`ChannelSecurityInterceptorFactoryBean`, which was introduced in _version 4.0_ for Java & Annotation
Starting with _version 4.2_, the `@SecuredChannel` annotation is available for Java & Annotation
configuration in `@Configuration` classes.
The `ChannelSecurityInterceptorFactoryBean` has been deprecated to
avoid the possibility of undesired early load for dependent beans from the `BeanFactory` during the `ApplicationContext` initialization
phase.
With the `@SecuredChannel` annotation, the Java configuration variant of the XML configuration above is: