diff --git a/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/AmqpHeaders.java b/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/AmqpHeaders.java deleted file mode 100644 index a3cc548ed6..0000000000 --- a/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/AmqpHeaders.java +++ /dev/null @@ -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 { -} diff --git a/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/config/AmqpOutboundChannelAdapterParser.java b/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/config/AmqpOutboundChannelAdapterParser.java index d1899cc825..7a2dac1fc1 100644 --- a/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/config/AmqpOutboundChannelAdapterParser.java +++ b/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/config/AmqpOutboundChannelAdapterParser.java @@ -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"); diff --git a/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/config/AmqpOutboundGatewayParser.java b/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/config/AmqpOutboundGatewayParser.java index 37d55941d5..28585c33e2 100644 --- a/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/config/AmqpOutboundGatewayParser.java +++ b/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/config/AmqpOutboundGatewayParser.java @@ -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"); diff --git a/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/outbound/AmqpOutboundEndpoint.java b/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/outbound/AmqpOutboundEndpoint.java index f5f9462cc2..71fb21b085 100644 --- a/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/outbound/AmqpOutboundEndpoint.java +++ b/spring-integration-amqp/src/main/java/org/springframework/integration/amqp/outbound/AmqpOutboundEndpoint.java @@ -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, 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) { diff --git a/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/config/AmqpOutboundChannelAdapterParserTests.java b/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/config/AmqpOutboundChannelAdapterParserTests.java index a67ccc0fde..73d6490899 100644 --- a/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/config/AmqpOutboundChannelAdapterParserTests.java +++ b/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/config/AmqpOutboundChannelAdapterParserTests.java @@ -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); diff --git a/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/config/OutboundGatewayTests.java b/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/config/OutboundGatewayTests.java index 7a5261df92..434e3484a3 100644 --- a/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/config/OutboundGatewayTests.java +++ b/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/config/OutboundGatewayTests.java @@ -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() { @@ -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("Hello, world!"); diff --git a/spring-integration-core/src/main/java/org/springframework/integration/MessageRejectedException.java b/spring-integration-core/src/main/java/org/springframework/integration/MessageRejectedException.java index e92b62d481..725c18cc4a 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/MessageRejectedException.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/MessageRejectedException.java @@ -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); } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/aggregator/ExpressionEvaluatingMessageListProcessor.java b/spring-integration-core/src/main/java/org/springframework/integration/aggregator/ExpressionEvaluatingMessageListProcessor.java index b1d80c47ab..6e970a58d3 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/aggregator/ExpressionEvaluatingMessageListProcessor.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/aggregator/ExpressionEvaluatingMessageListProcessor.java @@ -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); diff --git a/spring-integration-core/src/main/java/org/springframework/integration/aggregator/PassThroughMessageGroupProcessor.java b/spring-integration-core/src/main/java/org/springframework/integration/aggregator/PassThroughMessageGroupProcessor.java deleted file mode 100644 index 2d778c1822..0000000000 --- a/spring-integration-core/src/main/java/org/springframework/integration/aggregator/PassThroughMessageGroupProcessor.java +++ /dev/null @@ -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(); - } - -} diff --git a/spring-integration-core/src/main/java/org/springframework/integration/annotation/Header.java b/spring-integration-core/src/main/java/org/springframework/integration/annotation/Header.java deleted file mode 100644 index ce8bb48e20..0000000000 --- a/spring-integration-core/src/main/java/org/springframework/integration/annotation/Header.java +++ /dev/null @@ -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 true. - * - * @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; - -} diff --git a/spring-integration-core/src/main/java/org/springframework/integration/annotation/Headers.java b/spring-integration-core/src/main/java/org/springframework/integration/annotation/Headers.java deleted file mode 100644 index 8a67f7f13f..0000000000 --- a/spring-integration-core/src/main/java/org/springframework/integration/annotation/Headers.java +++ /dev/null @@ -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 { - -} diff --git a/spring-integration-core/src/main/java/org/springframework/integration/annotation/Payload.java b/spring-integration-core/src/main/java/org/springframework/integration/annotation/Payload.java deleted file mode 100644 index 79a947aec1..0000000000 --- a/spring-integration-core/src/main/java/org/springframework/integration/annotation/Payload.java +++ /dev/null @@ -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. - *

- * 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 ""; - -} diff --git a/spring-integration-core/src/main/java/org/springframework/integration/aop/MessagePublishingInterceptor.java b/spring-integration-core/src/main/java/org/springframework/integration/aop/MessagePublishingInterceptor.java index 71c2946419..53ae5e61f2 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/aop/MessagePublishingInterceptor.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/aop/MessagePublishingInterceptor.java @@ -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 diff --git a/spring-integration-core/src/main/java/org/springframework/integration/aop/MethodAnnotationPublisherMetadataSource.java b/spring-integration-core/src/main/java/org/springframework/integration/aop/MethodAnnotationPublisherMetadataSource.java index b466441afc..e53b419258 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/aop/MethodAnnotationPublisherMetadataSource.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/aop/MethodAnnotationPublisherMetadataSource.java @@ -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 getHeaderExpressions(Method method) { Map headerExpressions = new HashMap(); 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]; diff --git a/spring-integration-core/src/main/java/org/springframework/integration/aop/PublisherAnnotationAdvisor.java b/spring-integration-core/src/main/java/org/springframework/integration/aop/PublisherAnnotationAdvisor.java index 212670c46c..9466e65a9b 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/aop/PublisherAnnotationAdvisor.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/aop/PublisherAnnotationAdvisor.java @@ -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 diff --git a/spring-integration-core/src/main/java/org/springframework/integration/aop/PublisherAnnotationBeanPostProcessor.java b/spring-integration-core/src/main/java/org/springframework/integration/aop/PublisherAnnotationBeanPostProcessor.java index 5c0afe0aa9..6e342da4ff 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/aop/PublisherAnnotationBeanPostProcessor.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/aop/PublisherAnnotationBeanPostProcessor.java @@ -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 diff --git a/spring-integration-core/src/main/java/org/springframework/integration/channel/AbstractMessageChannel.java b/spring-integration-core/src/main/java/org/springframework/integration/channel/AbstractMessageChannel.java index 6530ac668f..4d4ba5505d 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/channel/AbstractMessageChannel.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/channel/AbstractMessageChannel.java @@ -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 diff --git a/spring-integration-core/src/main/java/org/springframework/integration/config/IntegrationRegistrar.java b/spring-integration-core/src/main/java/org/springframework/integration/config/IntegrationRegistrar.java index fc4f30439a..e67b925845 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/config/IntegrationRegistrar.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/config/IntegrationRegistrar.java @@ -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 }). */ @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); } } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/config/xml/DelayerParser.java b/spring-integration-core/src/main/java/org/springframework/integration/config/xml/DelayerParser.java index 107674c015..c2c1e823fa 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/config/xml/DelayerParser.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/config/xml/DelayerParser.java @@ -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 <delayer> 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"); diff --git a/spring-integration-core/src/main/java/org/springframework/integration/config/xml/PublishingInterceptorParser.java b/spring-integration-core/src/main/java/org/springframework/integration/config/xml/PublishingInterceptorParser.java index f2dc8a74ee..96b2a31739 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/config/xml/PublishingInterceptorParser.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/config/xml/PublishingInterceptorParser.java @@ -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

element", parserContext.extractSource(headerElement)); continue; diff --git a/spring-integration-core/src/main/java/org/springframework/integration/context/IntegrationObjectSupport.java b/spring-integration-core/src/main/java/org/springframework/integration/context/IntegrationObjectSupport.java index 2c566fcb3b..d65af4801f 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/context/IntegrationObjectSupport.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/context/IntegrationObjectSupport.java @@ -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 channelResolver; diff --git a/spring-integration-core/src/main/java/org/springframework/integration/endpoint/ExpressionMessageProducerSupport.java b/spring-integration-core/src/main/java/org/springframework/integration/endpoint/ExpressionMessageProducerSupport.java index 912c778580..3ec6c96f73 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/endpoint/ExpressionMessageProducerSupport.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/endpoint/ExpressionMessageProducerSupport.java @@ -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) { diff --git a/spring-integration-core/src/main/java/org/springframework/integration/expression/IntegrationEvaluationContextAware.java b/spring-integration-core/src/main/java/org/springframework/integration/expression/IntegrationEvaluationContextAware.java deleted file mode 100644 index 815c233109..0000000000 --- a/spring-integration-core/src/main/java/org/springframework/integration/expression/IntegrationEvaluationContextAware.java +++ /dev/null @@ -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} - *

- * 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); - -} diff --git a/spring-integration-core/src/main/java/org/springframework/integration/expression/IntegrationEvaluationContextAwareBeanPostProcessor.java b/spring-integration-core/src/main/java/org/springframework/integration/expression/IntegrationEvaluationContextAwareBeanPostProcessor.java deleted file mode 100644 index 2e118e1c29..0000000000 --- a/spring-integration-core/src/main/java/org/springframework/integration/expression/IntegrationEvaluationContextAwareBeanPostProcessor.java +++ /dev/null @@ -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 evaluationContextAwares = - new ArrayList(); - - 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; - } - -} diff --git a/spring-integration-core/src/main/java/org/springframework/integration/gateway/GatewayMethodInboundMessageMapper.java b/spring-integration-core/src/main/java/org/springframework/integration/gateway/GatewayMethodInboundMessageMapper.java index a2bfc00cdf..5eeb708c03 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/gateway/GatewayMethodInboundMessageMapper.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/gateway/GatewayMethodInboundMessageMapper.java @@ -244,13 +244,9 @@ class GatewayMethodInboundMessageMapper implements InboundMessageMapper toMessage(MethodArgsHolder holder) throws Exception { Object messageOrPayload = null; boolean foundPayloadAnnotation = false; @@ -280,8 +275,7 @@ class GatewayMethodInboundMessageMapper implements InboundMessageMapper 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(); } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/store/SimpleMessageStore.java b/spring-integration-core/src/main/java/org/springframework/integration/store/SimpleMessageStore.java index 927712b918..5278706d26 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/store/SimpleMessageStore.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/store/SimpleMessageStore.java @@ -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. diff --git a/spring-integration-core/src/main/java/org/springframework/integration/transformer/MessageTransformationException.java b/spring-integration-core/src/main/java/org/springframework/integration/transformer/MessageTransformationException.java index 326aa290e4..1e14f20e63 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/transformer/MessageTransformationException.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/transformer/MessageTransformationException.java @@ -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); } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/util/AbstractExpressionEvaluator.java b/spring-integration-core/src/main/java/org/springframework/integration/util/AbstractExpressionEvaluator.java index 86eea874f6..6daa7204c6 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/util/AbstractExpressionEvaluator.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/util/AbstractExpressionEvaluator.java @@ -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 evaluateExpression(String expression, Object input, Class expectedType) { - return this.expressionParser.parseExpression(expression) + return EXPRESSION_PARSER.parseExpression(expression) .getValue(this.getEvaluationContext(), input, expectedType); } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/util/MessagingAnnotationUtils.java b/spring-integration-core/src/main/java/org/springframework/integration/util/MessagingAnnotationUtils.java index e587faec37..e754d8159b 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/util/MessagingAnnotationUtils.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/util/MessagingAnnotationUtils.java @@ -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 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) { diff --git a/spring-integration-core/src/main/java/org/springframework/integration/util/MessagingMethodInvokerHelper.java b/spring-integration-core/src/main/java/org/springframework/integration/util/MessagingMethodInvokerHelper.java index 9ca108ecb3..e84122f639 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/util/MessagingMethodInvokerHelper.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/util/MessagingMethodInvokerHelper.java @@ -714,8 +714,7 @@ public class MessagingMethodInvokerHelper extends AbstractExpressionEvaluator MessagingAnnotationUtils.findMessagePartAnnotation(parameterAnnotations[i], true); if (mappingAnnotation != null) { Class 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 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)); } } diff --git a/spring-integration-core/src/main/resources/org/springframework/integration/config/xml/spring-integration-4.3.xsd b/spring-integration-core/src/main/resources/org/springframework/integration/config/xml/spring-integration-4.3.xsd index a4d7fae646..40642a928a 100644 --- a/spring-integration-core/src/main/resources/org/springframework/integration/config/xml/spring-integration-4.3.xsd +++ b/spring-integration-core/src/main/resources/org/springframework/integration/config/xml/spring-integration-4.3.xsd @@ -1612,19 +1612,6 @@ - - - - [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. - - - @@ -2499,11 +2486,7 @@ 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. @@ -2566,11 +2549,7 @@ 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. diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/DelayerParserTests-context.xml b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/DelayerParserTests-context.xml index 95864237e5..83788e4d9c 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/DelayerParserTests-context.xml +++ b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/DelayerParserTests-context.xml @@ -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"/> diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/DelayerParserTests.java b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/DelayerParserTests.java index 221f0ce46a..1f45aa680a 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/DelayerParserTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/DelayerParserTests.java @@ -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()); } diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/DelayerUsageTests-context.xml b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/DelayerUsageTests-context.xml index 952b965762..c1cf207ed8 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/DelayerUsageTests-context.xml +++ b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/DelayerUsageTests-context.xml @@ -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"/> diff --git a/spring-integration-core/src/test/java/org/springframework/integration/gateway/GatewayProxyMessageMappingTests.java b/spring-integration-core/src/test/java/org/springframework/integration/gateway/GatewayProxyMessageMappingTests.java index 0c978e4676..58d643ef59 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/gateway/GatewayProxyMessageMappingTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/gateway/GatewayProxyMessageMappingTests.java @@ -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 map); - @SuppressWarnings("deprecation") - void payloadAndHeaderMapWithAnnotationsDeprecated(@org.springframework.integration.annotation.Payload String s, - @org.springframework.integration.annotation.Headers Map map); - void payloadAndHeaderMapWithAnnotations(@Payload String s, @Headers Map map); void headerValuesAndPayloadWithAnnotations(@Header("k1") String x, @Payload String s, @Header("k2") String y); diff --git a/spring-integration-core/src/test/java/org/springframework/integration/handler/ServiceActivatorOnMockitoMockTests.java b/spring-integration-core/src/test/java/org/springframework/integration/handler/ServiceActivatorOnMockitoMockTests.java index 9c38380b11..955191d054 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/handler/ServiceActivatorOnMockitoMockTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/handler/ServiceActivatorOnMockitoMockTests.java @@ -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) diff --git a/spring-integration-event/src/main/java/org/springframework/integration/event/config/EventInboundChannelAdapterParser.java b/spring-integration-event/src/main/java/org/springframework/integration/event/config/EventInboundChannelAdapterParser.java index c747dd338d..cf7ffb65e1 100644 --- a/spring-integration-event/src/main/java/org/springframework/integration/event/config/EventInboundChannelAdapterParser.java +++ b/spring-integration-event/src/main/java/org/springframework/integration/event/config/EventInboundChannelAdapterParser.java @@ -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(); } diff --git a/spring-integration-event/src/test/java/org/springframework/integration/event/inbound/ApplicationEventListeningMessageProducerTests.java b/spring-integration-event/src/test/java/org/springframework/integration/event/inbound/ApplicationEventListeningMessageProducerTests.java index e622f006cf..741421fcc9 100644 --- a/spring-integration-event/src/test/java/org/springframework/integration/event/inbound/ApplicationEventListeningMessageProducerTests.java +++ b/spring-integration-event/src/test/java/org/springframework/integration/event/inbound/ApplicationEventListeningMessageProducerTests.java @@ -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(); diff --git a/spring-integration-file/src/main/java/org/springframework/integration/file/config/AbstractRemoteFileOutboundGatewayParser.java b/spring-integration-file/src/main/java/org/springframework/integration/file/config/AbstractRemoteFileOutboundGatewayParser.java index 1a14a4a198..35051df056 100644 --- a/spring-integration-file/src/main/java/org/springframework/integration/file/config/AbstractRemoteFileOutboundGatewayParser.java +++ b/spring-integration-file/src/main/java/org/springframework/integration/file/config/AbstractRemoteFileOutboundGatewayParser.java @@ -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; } diff --git a/spring-integration-file/src/main/java/org/springframework/integration/file/remote/gateway/AbstractRemoteFileOutboundGateway.java b/spring-integration-file/src/main/java/org/springframework/integration/file/remote/gateway/AbstractRemoteFileOutboundGateway.java index d5bd99eb46..6df184bc87 100644 --- a/spring-integration-file/src/main/java/org/springframework/integration/file/remote/gateway/AbstractRemoteFileOutboundGateway.java +++ b/spring-integration-file/src/main/java/org/springframework/integration/file/remote/gateway/AbstractRemoteFileOutboundGateway.java @@ -374,30 +374,49 @@ public abstract class AbstractRemoteFileOutboundGateway 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(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(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 diff --git a/spring-integration-file/src/test/java/org/springframework/integration/file/remote/gateway/RemoteFileOutboundGatewayTests.java b/spring-integration-file/src/test/java/org/springframework/integration/file/remote/gateway/RemoteFileOutboundGatewayTests.java index a29809d6c0..d4f6964bcb 100644 --- a/spring-integration-file/src/test/java/org/springframework/integration/file/remote/gateway/RemoteFileOutboundGatewayTests.java +++ b/spring-integration-file/src/test/java/org/springframework/integration/file/remote/gateway/RemoteFileOutboundGatewayTests.java @@ -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 args = new AtomicReference(); @@ -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 args = new AtomicReference(); @@ -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 { -abstract class TestSession implements org.springframework.integration.file.remote.session.Session { - - 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 { + + @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 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 file) { + return file.getFilename(); + } + + @Override + protected long getModified(TestLsEntry file) { + return file.getModified(); + } + + @Override + protected List> asFileInfoList( + Collection files) { + return new ArrayList>(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 { + + 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 { - @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 { - - @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 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 file) { - return file.getFilename(); - } - - @Override - protected long getModified(TestLsEntry file) { - return file.getModified(); - } - - @Override - protected List> asFileInfoList( - Collection files) { - return new ArrayList>(files); - } - - @Override - protected TestLsEntry enhanceNameWithSubDirectory(TestLsEntry file, String directory) { - file.setFilename(directory + file.getFilename()); - return file; - } - -} - -class TestLsEntry extends AbstractFileInfo { - - 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 { - - public TestPatternFilter(String path) { - super(path); - } - - @Override - protected String getFilename(TestLsEntry file) { - return file.getFilename(); } } diff --git a/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/config/xml/GemfireCqInboundChannelAdapterParser.java b/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/config/xml/GemfireCqInboundChannelAdapterParser.java index d4c427d4bd..ff5f00c68d 100644 --- a/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/config/xml/GemfireCqInboundChannelAdapterParser.java +++ b/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/config/xml/GemfireCqInboundChannelAdapterParser.java @@ -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(); } } diff --git a/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/config/xml/GemfireInboundChannelAdapterParser.java b/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/config/xml/GemfireInboundChannelAdapterParser.java index 5b0825314a..5e503f2eb3 100644 --- a/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/config/xml/GemfireInboundChannelAdapterParser.java +++ b/spring-integration-gemfire/src/main/java/org/springframework/integration/gemfire/config/xml/GemfireInboundChannelAdapterParser.java @@ -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); diff --git a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/inbound/CacheListeningMessageProducerTests.java b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/inbound/CacheListeningMessageProducerTests.java index 9693561811..80ae47502d 100644 --- a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/inbound/CacheListeningMessageProducerTests.java +++ b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/inbound/CacheListeningMessageProducerTests.java @@ -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 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 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()); } + } diff --git a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/inbound/ContinuousQueryMessageProducerTests.java b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/inbound/ContinuousQueryMessageProducerTests.java index 43ab235bff..7e0adc1c09 100644 --- a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/inbound/ContinuousQueryMessageProducerTests.java +++ b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/inbound/ContinuousQueryMessageProducerTests.java @@ -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 { diff --git a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/inbound/GemfireInboundChannelAdapterTests.java b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/inbound/GemfireInboundChannelAdapterTests.java index 5250f7e8c6..1efb864671 100644 --- a/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/inbound/GemfireInboundChannelAdapterTests.java +++ b/spring-integration-gemfire/src/test/java/org/springframework/integration/gemfire/inbound/GemfireInboundChannelAdapterTests.java @@ -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(); } + } } diff --git a/spring-integration-ip/src/main/java/org/springframework/integration/ip/udp/UnicastSendingMessageHandler.java b/spring-integration-ip/src/main/java/org/springframework/integration/ip/udp/UnicastSendingMessageHandler.java index e2fad624a9..29c6576550 100644 --- a/spring-integration-ip/src/main/java/org/springframework/integration/ip/udp/UnicastSendingMessageHandler.java +++ b/spring-integration-ip/src/main/java/org/springframework/integration/ip/udp/UnicastSendingMessageHandler.java @@ -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(); diff --git a/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/honor-timeout.xml b/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/honor-timeout.xml index 0b6fd2c6e2..1d6b6d0645 100644 --- a/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/honor-timeout.xml +++ b/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/honor-timeout.xml @@ -24,7 +24,7 @@ - + diff --git a/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-01.xml b/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-01.xml index b82f0ec195..98fd426d53 100644 --- a/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-01.xml +++ b/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-01.xml @@ -26,7 +26,7 @@ - + diff --git a/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-02.xml b/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-02.xml index d75e1e6a72..e83340c794 100644 --- a/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-02.xml +++ b/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-02.xml @@ -27,7 +27,7 @@ - + diff --git a/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-03.xml b/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-03.xml index 02f1c5679e..2d4ff9e50b 100644 --- a/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-03.xml +++ b/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-03.xml @@ -27,7 +27,7 @@ - + diff --git a/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-04.xml b/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-04.xml index 156fc56dc8..fe2c1c1f5f 100644 --- a/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-04.xml +++ b/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-04.xml @@ -26,7 +26,7 @@ - + diff --git a/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-05.xml b/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-05.xml index f03be6a588..6303d059c5 100644 --- a/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-05.xml +++ b/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-05.xml @@ -28,7 +28,7 @@ - + diff --git a/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-06.xml b/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-06.xml index 636c9f21d1..7fa2dd20b0 100644 --- a/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-06.xml +++ b/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-06.xml @@ -26,7 +26,7 @@ - + diff --git a/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-07.xml b/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-07.xml index a59b5ba63a..949cfc415d 100644 --- a/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-07.xml +++ b/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-07.xml @@ -27,7 +27,7 @@ - + diff --git a/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-08.xml b/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-08.xml index 5e71eb47b0..d37ed80f1a 100644 --- a/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-08.xml +++ b/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-08.xml @@ -28,7 +28,7 @@ - + diff --git a/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-09.xml b/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-09.xml index db79b81b8d..43c323d924 100644 --- a/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-09.xml +++ b/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-09.xml @@ -28,7 +28,7 @@ - + diff --git a/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-named-queue-01.xml b/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-named-queue-01.xml index 6fad0625ab..8228272a18 100644 --- a/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-named-queue-01.xml +++ b/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-named-queue-01.xml @@ -27,7 +27,7 @@ - + diff --git a/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-named-queue-02.xml b/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-named-queue-02.xml index 9469ab08e0..db0248500d 100644 --- a/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-named-queue-02.xml +++ b/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-named-queue-02.xml @@ -29,7 +29,7 @@ - + diff --git a/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-named-queue-02a.xml b/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-named-queue-02a.xml index c689aac67d..a4654b5d42 100644 --- a/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-named-queue-02a.xml +++ b/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-named-queue-02a.xml @@ -29,7 +29,7 @@ - + diff --git a/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-named-queue-03.xml b/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-named-queue-03.xml index a27b2324a8..ea65cf44ab 100644 --- a/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-named-queue-03.xml +++ b/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-named-queue-03.xml @@ -28,7 +28,7 @@ - + diff --git a/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-named-queue-03a.xml b/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-named-queue-03a.xml index 5990be1c34..b9a3f39036 100644 --- a/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-named-queue-03a.xml +++ b/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-named-queue-03a.xml @@ -37,7 +37,7 @@ - + diff --git a/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-named-queue-04.xml b/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-named-queue-04.xml index deb9a50c6c..f2f1106496 100644 --- a/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-named-queue-04.xml +++ b/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-named-queue-04.xml @@ -38,7 +38,7 @@ - + diff --git a/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-named-queue-05.xml b/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-named-queue-05.xml index 4e8079c4ab..cd79a528a0 100644 --- a/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-named-queue-05.xml +++ b/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-named-queue-05.xml @@ -29,7 +29,7 @@ - + diff --git a/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-named-queue-06.xml b/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-named-queue-06.xml index c84ee59835..587c38d3f7 100644 --- a/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-named-queue-06.xml +++ b/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-named-queue-06.xml @@ -29,7 +29,7 @@ - + diff --git a/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-named-queue-07.xml b/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-named-queue-07.xml index da10f2704e..0e79d0536b 100644 --- a/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-named-queue-07.xml +++ b/spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/pipeline-named-queue-07.xml @@ -29,7 +29,7 @@ - + diff --git a/spring-integration-jpa/src/main/java/org/springframework/integration/jpa/config/xml/JpaInboundChannelAdapterParser.java b/spring-integration-jpa/src/main/java/org/springframework/integration/jpa/config/xml/JpaInboundChannelAdapterParser.java index a17d594039..1f1a6c730e 100644 --- a/spring-integration-jpa/src/main/java/org/springframework/integration/jpa/config/xml/JpaInboundChannelAdapterParser.java +++ b/spring-integration-jpa/src/main/java/org/springframework/integration/jpa/config/xml/JpaInboundChannelAdapterParser.java @@ -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); diff --git a/spring-integration-jpa/src/test/java/org/springframework/integration/jpa/outbound/JpaOutboundGatewayTests-context.xml b/spring-integration-jpa/src/test/java/org/springframework/integration/jpa/outbound/JpaOutboundGatewayTests-context.xml index 7084b67f20..43cbd67b06 100644 --- a/spring-integration-jpa/src/test/java/org/springframework/integration/jpa/outbound/JpaOutboundGatewayTests-context.xml +++ b/spring-integration-jpa/src/test/java/org/springframework/integration/jpa/outbound/JpaOutboundGatewayTests-context.xml @@ -27,7 +27,6 @@ - diff --git a/spring-integration-jpa/src/test/java/org/springframework/integration/jpa/outbound/JpaOutboundGatewayTests.java b/spring-integration-jpa/src/test/java/org/springframework/integration/jpa/outbound/JpaOutboundGatewayTests.java index cdcef19f5b..8debc43eef 100644 --- a/spring-integration-jpa/src/test/java/org/springframework/integration/jpa/outbound/JpaOutboundGatewayTests.java +++ b/spring-integration-jpa/src/test/java/org/springframework/integration/jpa/outbound/JpaOutboundGatewayTests.java @@ -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 students = studentService.getAllStudentsDeprecated(); - Assert.assertNotNull(students); - Assert.assertTrue(students.size() == 3); - - students = studentService.getAllStudents(); + List students = studentService.getAllStudents(); Assert.assertNotNull(students); Assert.assertTrue(students.size() == 3); } diff --git a/spring-integration-jpa/src/test/java/org/springframework/integration/jpa/outbound/StudentService.java b/spring-integration-jpa/src/test/java/org/springframework/integration/jpa/outbound/StudentService.java index bd738be1e4..fb532fe9dc 100644 --- a/spring-integration-jpa/src/test/java/org/springframework/integration/jpa/outbound/StudentService.java +++ b/spring-integration-jpa/src/test/java/org/springframework/integration/jpa/outbound/StudentService.java @@ -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 getAllStudentsDeprecated(); - @Payload("new java.util.Date()") List getAllStudents(); diff --git a/spring-integration-redis/src/main/java/org/springframework/integration/redis/config/RedisOutboundGatewayParser.java b/spring-integration-redis/src/main/java/org/springframework/integration/redis/config/RedisOutboundGatewayParser.java index be34839e8c..f4593594b2 100644 --- a/spring-integration-redis/src/main/java/org/springframework/integration/redis/config/RedisOutboundGatewayParser.java +++ b/spring-integration-redis/src/main/java/org/springframework/integration/redis/config/RedisOutboundGatewayParser.java @@ -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; } + } diff --git a/spring-integration-redis/src/main/java/org/springframework/integration/redis/outbound/RedisOutboundGateway.java b/spring-integration-redis/src/main/java/org/springframework/integration/redis/outbound/RedisOutboundGateway.java index 9f003140c0..7c0dfbccb4 100644 --- a/spring-integration-redis/src/main/java/org/springframework/integration/redis/outbound/RedisOutboundGateway.java +++ b/spring-integration-redis/src/main/java/org/springframework/integration/redis/outbound/RedisOutboundGateway.java @@ -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) { diff --git a/spring-integration-redis/src/main/java/org/springframework/integration/redis/outbound/RedisPublishingMessageHandler.java b/spring-integration-redis/src/main/java/org/springframework/integration/redis/outbound/RedisPublishingMessageHandler.java index 9f07e9d83f..a2367004c1 100644 --- a/spring-integration-redis/src/main/java/org/springframework/integration/redis/outbound/RedisPublishingMessageHandler.java +++ b/spring-integration-redis/src/main/java/org/springframework/integration/redis/outbound/RedisPublishingMessageHandler.java @@ -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)); diff --git a/spring-integration-redis/src/test/java/org/springframework/integration/redis/rules/RedisAvailableRule.java b/spring-integration-redis/src/test/java/org/springframework/integration/redis/rules/RedisAvailableRule.java index 9b3e64ddcf..e152efbade 100644 --- a/spring-integration-redis/src/test/java/org/springframework/integration/redis/rules/RedisAvailableRule.java +++ b/spring-integration-redis/src/test/java/org/springframework/integration/redis/rules/RedisAvailableRule.java @@ -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); diff --git a/spring-integration-security/src/main/java/org/springframework/integration/security/config/ChannelSecurityInterceptorFactoryBean.java b/spring-integration-security/src/main/java/org/springframework/integration/security/config/ChannelSecurityInterceptorFactoryBean.java deleted file mode 100644 index f350b4cac3..0000000000 --- a/spring-integration-security/src/main/java/org/springframework/integration/security/config/ChannelSecurityInterceptorFactoryBean.java +++ /dev/null @@ -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 } 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, 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 accessPolicies) { - Assert.notNull(accessPolicies); - ChannelSecurityMetadataSource channelSecurityMetadataSource = (ChannelSecurityMetadataSource) interceptor.obtainSecurityMetadataSource(); - for (Map.Entry 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; - } - -} diff --git a/spring-integration-websocket/src/test/java/org/springframework/integration/websocket/server/WebSocketServerTests.java b/spring-integration-websocket/src/test/java/org/springframework/integration/websocket/server/WebSocketServerTests.java index 5cdcaddc6f..11e05ee360 100644 --- a/spring-integration-websocket/src/test/java/org/springframework/integration/websocket/server/WebSocketServerTests.java +++ b/spring-integration-websocket/src/test/java/org/springframework/integration/websocket/server/WebSocketServerTests.java @@ -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 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; } diff --git a/spring-integration-xml/src/main/java/org/springframework/integration/xml/AggregatedXmlMessageValidationException.java b/spring-integration-xml/src/main/java/org/springframework/integration/xml/AggregatedXmlMessageValidationException.java index 378126b8c3..35f1969355 100644 --- a/spring-integration-xml/src/main/java/org/springframework/integration/xml/AggregatedXmlMessageValidationException.java +++ b/spring-integration-xml/src/main/java/org/springframework/integration/xml/AggregatedXmlMessageValidationException.java @@ -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 exceptionIterator() { - return exceptions.iterator(); - } - public List getExceptions() { return Collections.unmodifiableList(exceptions); } diff --git a/src/reference/asciidoc/jpa.adoc b/src/reference/asciidoc/jpa.adoc index 2beb5a2c8c..c036f43778 100644 --- a/src/reference/asciidoc/jpa.adoc +++ b/src/reference/asciidoc/jpa.adoc @@ -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> @@ -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_. diff --git a/src/reference/asciidoc/security.adoc b/src/reference/asciidoc/security.adoc index a04eb13ca1..100f2e8f1b 100644 --- a/src/reference/asciidoc/security.adoc +++ b/src/reference/asciidoc/security.adoc @@ -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: