INT-3262 JDK8 Javadoc Commit

Increase receive timeout for `Jsr223TransformerTests#testInt3162ScriptExecutorThreadSafety`.

JIRA: https://jira.springsource.org/browse/INT-3262
JIRA: https://jira.springsource.org/browse/INT-3263
This commit is contained in:
Gary Russell
2014-01-15 19:14:53 +02:00
committed by Artem Bilan
parent 66efb34342
commit c45b708341
249 changed files with 2265 additions and 985 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2011 the original author or authors.
* 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.
@@ -17,8 +17,8 @@
package org.springframework.integration.amqp.channel;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.messaging.Message;
import org.springframework.integration.channel.AbstractMessageChannel;
import org.springframework.messaging.Message;
import org.springframework.util.Assert;
/**
@@ -39,6 +39,8 @@ public abstract class AbstractAmqpChannel extends AbstractMessageChannel {
/**
* Subclasses may override this method to return an Exchange name.
* By default, Messages will be sent to the no-name Direct Exchange.
*
* @return The exchange name.
*/
protected String getExchangeName() {
return "";
@@ -47,6 +49,8 @@ public abstract class AbstractAmqpChannel extends AbstractMessageChannel {
/**
* Subclasses may override this method to return a routing key.
* By default, there will be no routing key (empty string).
*
* @return The routing key.
*/
protected String getRoutingKey() {
return "";

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* 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.
@@ -78,7 +78,7 @@ abstract class AbstractSubscribableAmqpChannel extends AbstractAmqpChannel imple
/**
* Specify the maximum number of subscribers supported by the
* channel's dispatcher (if it is an {@link AbstractDispatcher}).
* @param maxSubscribers
* @param maxSubscribers The maximum number of subscribers allowed.
*/
public void setMaxSubscribers(int maxSubscribers) {
this.maxSubscribers = maxSubscribers;
@@ -87,10 +87,12 @@ abstract class AbstractSubscribableAmqpChannel extends AbstractAmqpChannel imple
}
}
@Override
public boolean subscribe(MessageHandler handler) {
return this.dispatcher.addHandler(handler);
}
@Override
public boolean unsubscribe(MessageHandler handler) {
return this.dispatcher.removeHandler(handler);
}
@@ -148,6 +150,7 @@ abstract class AbstractSubscribableAmqpChannel extends AbstractAmqpChannel imple
}
@Override
public void onMessage(org.springframework.amqp.core.Message message) {
Message<?> messageToSend = null;
try {
@@ -186,36 +189,43 @@ abstract class AbstractSubscribableAmqpChannel extends AbstractAmqpChannel imple
* SmartLifecycle implementation (delegates to the MessageListener container)
*/
@Override
public boolean isAutoStartup() {
return (this.container != null) ? this.container.isAutoStartup() : false;
}
@Override
public int getPhase() {
return (this.container != null) ? this.container.getPhase() : 0;
}
@Override
public boolean isRunning() {
return (this.container != null) ? this.container.isRunning() : false;
}
@Override
public void start() {
if (this.container != null) {
this.container.start();
}
}
@Override
public void stop() {
if (this.container != null) {
this.container.stop();
}
}
@Override
public void stop(Runnable callback) {
if (this.container != null) {
this.container.stop(callback);
}
}
@Override
public void destroy() throws Exception {
if (this.container != null) {
this.container.destroy();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* 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.
@@ -41,6 +41,8 @@ public class PointToPointSubscribableAmqpChannel extends AbstractSubscribableAmq
/**
* Provide a Queue name to be used. If this is not provided,
* the Queue's name will be the same as the channel name.
*
* @param queueName The queue name.
*/
public void setQueueName(String queueName) {
this.queueName = queueName;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2011 the original author or authors.
* 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.
@@ -21,16 +21,16 @@ import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.rabbit.core.RabbitAdmin;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.Message;
import org.springframework.messaging.PollableChannel;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.util.Assert;
/**
* A {@link PollableChannel} implementation that is backed by an AMQP Queue.
* Messages will be sent to the default (no-name) exchange with that Queue's
* name as the routing key.
*
*
* @author Mark Fisher
* @since 2.1
*/
@@ -54,6 +54,8 @@ public class PollableAmqpChannel extends AbstractAmqpChannel implements Pollable
* Provide an explicitly configured queue name. If this is not provided, then a Queue will be created
* implicitly with the channelName as its name. The implicit creation will require that either an AmqpAdmin
* instance has been provided or that the configured AmqpTemplate is an instance of RabbitTemplate.
*
* @param queueName The queue name.
*/
public void setQueueName(String queueName) {
this.queueName = queueName;
@@ -63,6 +65,8 @@ public class PollableAmqpChannel extends AbstractAmqpChannel implements Pollable
* Provide an instance of AmqpAdmin for implicitly declaring Queues if the queueName is not provided.
* When providing a RabbitTemplate implementation, this is not strictly necessary since a RabbitAdmin
* instance can be created from the template's ConnectionFactory reference.
*
* @param amqpAdmin The amqp admin.
*/
public void setAmqpAdmin(AmqpAdmin amqpAdmin) {
this.amqpAdmin = amqpAdmin;
@@ -73,7 +77,7 @@ public class PollableAmqpChannel extends AbstractAmqpChannel implements Pollable
AmqpTemplate amqpTemplate = this.getAmqpTemplate();
if (this.queueName == null) {
if (this.amqpAdmin == null && amqpTemplate instanceof RabbitTemplate) {
this.amqpAdmin = new RabbitAdmin(((RabbitTemplate) amqpTemplate).getConnectionFactory());
this.amqpAdmin = new RabbitAdmin(((RabbitTemplate) amqpTemplate).getConnectionFactory());
}
Assert.notNull(this.amqpAdmin,
"If no queueName is configured explicitly, an AmqpAdmin instance must be provided, " +
@@ -88,6 +92,7 @@ public class PollableAmqpChannel extends AbstractAmqpChannel implements Pollable
return this.queueName;
}
@Override
public Message<?> receive() {
if (!this.getInterceptors().preReceive(this)) {
return null;
@@ -106,6 +111,7 @@ public class PollableAmqpChannel extends AbstractAmqpChannel implements Pollable
return this.getInterceptors().postReceive(replyMessage, this) ;
}
@Override
public Message<?> receive(long timeout) {
if (logger.isInfoEnabled()) {
logger.info("Calling receive with a timeout value on PollableAmqpChannel. " +

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* 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.
@@ -46,6 +46,8 @@ public class PublishSubscribeAmqpChannel extends AbstractSubscribableAmqpChannel
* FanoutExchange will be declared implicitly, and its name will be the same
* as the channel name prefixed by "si.fanout.". In either case, an effectively
* anonymous Queue will be declared automatically.
*
* @param exchange The fanout exchange.
*/
public void setExchange(FanoutExchange exchange) {
this.exchange = exchange;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* 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.
@@ -149,6 +149,8 @@ public class AmqpChannelFactoryBean extends AbstractFactoryBean<AbstractAmqpChan
* is not needed for the message-driven (Subscribable) channels
* since those are able to create a RabbitAdmin instance using
* the underlying listener container's ConnectionFactory.
*
* @param amqpAdmin The amqp admin.
*/
public void setAmqpAdmin(AmqpAdmin amqpAdmin) {
this.amqpAdmin = amqpAdmin;
@@ -158,6 +160,8 @@ public class AmqpChannelFactoryBean extends AbstractFactoryBean<AbstractAmqpChan
* Set the FanoutExchange to use. This is only relevant for
* publish-subscribe-channels, and even then if not provided,
* a FanoutExchange will be implicitly created.
*
* @param exchange The fanout exchange.
*/
public void setExchange(FanoutExchange exchange) {
this.exchange = exchange;
@@ -167,6 +171,8 @@ public class AmqpChannelFactoryBean extends AbstractFactoryBean<AbstractAmqpChan
* Set the Queue name to use. This is only relevant for
* point-to-point channels, even then if not provided,
* a Queue will be implicitly created.
*
* @param queueName The queue name.
*/
public void setQueueName(String queueName) {
this.queueName = queueName;

View File

@@ -28,6 +28,7 @@ import org.springframework.messaging.MessageHandlingException;
public class MessageRejectedException extends MessageHandlingException {
/**
* @param failedMessage The failed message.
* @deprecated since 4.0 in favor of {@code MessageRejectedException(Message, String)}
*/
@Deprecated

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* 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
@@ -20,6 +20,7 @@ import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.integration.IntegrationMessageHeaderAccessor;
import org.springframework.integration.store.MessageGroup;
import org.springframework.integration.support.MessageBuilder;
@@ -40,6 +41,7 @@ public abstract class AbstractAggregatingMessageGroupProcessor implements Messag
private final Log logger = LogFactory.getLog(this.getClass());
@Override
public final Object processMessageGroup(MessageGroup group) {
Assert.notNull(group, "MessageGroup must not be null");
@@ -60,6 +62,9 @@ public abstract class AbstractAggregatingMessageGroupProcessor implements Messag
* This default implementation simply returns all headers that have no conflicts among the group. An absent header
* on one or more Messages within the group is not considered a conflict. Subclasses may override this method with
* more advanced conflict-resolution strategies if necessary.
*
* @param group The message group.
* @return The aggregated headers.
*/
protected Map<String, Object> aggregateHeaders(MessageGroup group) {
Map<String, Object> aggregatedHeaders = new HashMap<String, Object>();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* 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
@@ -26,6 +26,7 @@ import org.springframework.beans.factory.BeanFactory;
import org.springframework.integration.IntegrationMessageHeaderAccessor;
import org.springframework.integration.channel.NullChannel;
import org.springframework.integration.core.MessageProducer;
import org.springframework.integration.core.MessagingTemplate;
import org.springframework.integration.handler.AbstractMessageHandler;
import org.springframework.integration.store.MessageGroup;
import org.springframework.integration.store.MessageGroupStore;
@@ -33,14 +34,12 @@ import org.springframework.integration.store.MessageGroupStore.MessageGroupCallb
import org.springframework.integration.store.MessageStore;
import org.springframework.integration.store.SimpleMessageGroup;
import org.springframework.integration.store.SimpleMessageStore;
import org.springframework.integration.support.converter.SimpleMessageConverter;
import org.springframework.integration.util.DefaultLockRegistry;
import org.springframework.integration.util.LockRegistry;
import org.springframework.integration.util.UUIDConverter;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessagingException;
import org.springframework.integration.core.MessagingTemplate;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
@@ -257,8 +256,8 @@ public abstract class AbstractCorrelatingMessageHandler extends AbstractMessageH
/**
* Allows you to provide additional logic that needs to be performed after the MessageGroup was released.
* @param group
* @param completedMessages
* @param group The group.
* @param completedMessages The completed messages.
*/
protected abstract void afterRelease(MessageGroup group, Collection<Message<?>> completedMessages);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* 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
@@ -15,9 +15,9 @@ package org.springframework.integration.aggregator;
import java.util.Collection;
import org.springframework.messaging.Message;
import org.springframework.integration.store.MessageGroup;
import org.springframework.integration.store.MessageGroupStore;
import org.springframework.messaging.Message;
/**
* Aggregator specific implementation of {@link AbstractCorrelatingMessageHandler}.
@@ -46,7 +46,9 @@ public class AggregatingMessageHandler extends AbstractCorrelatingMessageHandler
}
/**
* Will set the 'expireGroupsUponCompletion' flag
* Will set the 'expireGroupsUponCompletion' flag.
*
* @param expireGroupsUponCompletion true when groups should be expired on completion.
*
* @see #afterRelease
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* 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
@@ -20,12 +20,12 @@ import java.util.concurrent.ConcurrentMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.messaging.Message;
import org.springframework.integration.core.MessageSource;
import org.springframework.integration.handler.AbstractMessageHandler;
import org.springframework.integration.store.MessageGroup;
import org.springframework.integration.store.MessageGroupStore;
import org.springframework.integration.store.SimpleMessageStore;
import org.springframework.messaging.Message;
/**
* This Endpoint serves as a barrier for messages that should not be processed yet. The decision when a message can be
@@ -70,6 +70,8 @@ public class CorrelatingMessageBarrier extends AbstractMessageHandler implements
/**
* Set the CorrelationStrategy to be used to determine the correlation key for incoming messages
*
* @param correlationStrategy The correlation strategy.
*/
public void setCorrelationStrategy(CorrelationStrategy correlationStrategy) {
this.correlationStrategy = correlationStrategy;
@@ -77,6 +79,8 @@ public class CorrelatingMessageBarrier extends AbstractMessageHandler implements
/**
* Set the ReleaseStrategy that should be used when deciding if a group in this barrier may be released.
*
* @param releaseStrategy The release strategy.
*/
public void setReleaseStrategy(ReleaseStrategy releaseStrategy) {
this.releaseStrategy = releaseStrategy;
@@ -100,6 +104,7 @@ public class CorrelatingMessageBarrier extends AbstractMessageHandler implements
}
@Override
public Message<Object> receive() {
for (Object key : correlationLocks.keySet()) {
Object lock = getLock(key);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* 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.
@@ -31,6 +31,8 @@ public interface CorrelationStrategy {
* Find the correlation key for the given message. If no key can be determined the strategy should not return
* <code>null</code>, but throw an exception.
*
* @param message The message.
* @return The correlation key.
*/
Object getCorrelationKey(Message<?> message);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* 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.
@@ -23,13 +23,13 @@ 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.messaging.Message;
import org.springframework.integration.util.AbstractExpressionEvaluator;
import org.springframework.messaging.Message;
/**
* A base class for aggregators that evaluates a SpEL expression with the message list as the root object within the
* evaluation context.
*
*
* @author Dave Syer
* @since 2.0
*/
@@ -40,9 +40,11 @@ public class ExpressionEvaluatingMessageListProcessor extends AbstractExpression
private final Expression expression;
private volatile Class<?> expectedType = null;
/**
* Set the result type expected from evaluation of the expression.
*
* @param expectedType The expected type.
*/
public void setExpectedType(Class<?> expectedType) {
this.expectedType = expectedType;
@@ -61,6 +63,7 @@ public class ExpressionEvaluatingMessageListProcessor extends AbstractExpression
* Processes the Message by evaluating the expression with that Message as the root object. The expression
* evaluation result Object will be returned.
*/
@Override
public Object process(Collection<? extends Message<?>> messages) {
return this.evaluateExpression(this.expression, messages, this.expectedType);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* 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
@@ -29,6 +29,9 @@ public interface MessageGroupProcessor {
* group, while a resequencing processor will return all messages whose preceding sequence has been satisfied.
* <p>
* If a multiple messages are returned the return value must be a Collection&lt;Message&gt;.
*
* @param group The message group.
* @return The result of processing the group.
*/
Object processMessageGroup(MessageGroup group);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2011 the original author or authors.
* 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.
@@ -24,9 +24,10 @@ import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.messaging.Message;
import org.springframework.integration.IntegrationMessageHeaderAccessor;
import org.springframework.integration.store.MessageGroup;
import org.springframework.messaging.Message;
/**
* An implementation of {@link ReleaseStrategy} that simply compares the current size of the message list to the
@@ -58,12 +59,13 @@ public class SequenceSizeReleaseStrategy implements ReleaseStrategy {
* Flag that determines if partial sequences are allowed. If true then as soon as enough messages arrive that can be
* ordered they will be released, provided they all have sequence numbers greater than those already released.
*
* @param releasePartialSequences
* @param releasePartialSequences true when partial sequences should be released.
*/
public void setReleasePartialSequences(boolean releasePartialSequences) {
this.releasePartialSequences = releasePartialSequences;
}
@Override
public boolean canRelease(MessageGroup messageGroup) {
boolean canRelease = false;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2011 the original author or authors.
* 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.
@@ -25,12 +25,12 @@ import java.lang.annotation.Target;
import org.springframework.integration.aggregator.AbstractCorrelatingMessageHandler;
/**
* Indicates that a method is capable of aggregating messages.
* Indicates that a method is capable of aggregating messages.
* <p>
* A method annotated with @Aggregator may accept a collection
* of Messages or Message payloads and should return a single
* Message or a single Object to be used as a Message payload.
*
*
* @author Marius Bogoevici
* @author Oleg Zhurakousky
*/
@@ -40,27 +40,27 @@ import org.springframework.integration.aggregator.AbstractCorrelatingMessageHand
public @interface Aggregator {
/**
* channel name for receiving messages to be aggregated
* @return The channel name for receiving messages to be aggregated
*/
String inputChannel() default "";
/**
* channel name for sending aggregated result messages
* @return The channel name for sending aggregated result messages
*/
String outputChannel() default "";
/**
* channel name for sending discarded messages (due to a timeout)
* @return The channel name for sending discarded messages (due to a timeout)
*/
String discardChannel() default "";
/**
* timeout for sending results to the reply target (in milliseconds)
* @return The timeout for sending results to the reply target (in milliseconds)
*/
long sendTimeout() default AbstractCorrelatingMessageHandler.DEFAULT_SEND_TIMEOUT;
/**
* indicates whether to send an incomplete aggregate on expiry of the message group
* @return Indicates whether to send an incomplete aggregate on expiry of the message group
*/
boolean sendPartialResultsOnExpiry() default false;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* 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.
@@ -23,14 +23,14 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* This annotation allows you to specify a SpEL expression indicating that a method
* This annotation allows you to specify a SpEL expression indicating that a method
* parameter's value should be mapped from the payload of a Message. The expression
* will be evaluated against the payload object as the root context. The annotated
* parameter type must match or be convertible from the evaluation result.
* <p>
* Example: void foo(@Payload("city.name") String cityName) - will map the value of
* 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
*/
@@ -40,7 +40,7 @@ import java.lang.annotation.Target;
public @interface Payload {
/**
* Expression for matching against nested properties of the payload.
* @return The expression for matching against nested properties of the payload.
*/
String value() default "";

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* 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.
@@ -39,7 +39,7 @@ import java.lang.annotation.Target;
public @interface Payloads {
/**
* Expression for matching against nested properties of the payloads.
* @return The expression for matching against nested properties of the payloads.
*/
String value() default "";

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* 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.
@@ -25,7 +25,7 @@ import java.lang.annotation.Target;
* Annotation to indicate that a method, or all public methods if applied at
* class-level, should publish Messages. The @Payload and @Header annotations
* can be used in conjunction with this to determine the content of the Message.
*
*
* @author Mark Fisher
* @since 2.0
*/
@@ -34,7 +34,7 @@ import java.lang.annotation.Target;
public @interface Publisher {
/**
* Name of the Message Channel to which Messages will be published.
* @return The name of the Message Channel to which Messages will be published.
*/
String channel() default "";

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* 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.
@@ -27,13 +27,13 @@ import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.core.Ordered;
import org.springframework.messaging.MessageChannel;
import org.springframework.integration.annotation.Publisher;
import org.springframework.messaging.MessageChannel;
import org.springframework.util.ClassUtils;
/**
* Post-processes beans that contain the method-level @{@link Publisher} annotation.
*
*
* @author Oleg Zhurakousky
* @author Mark Fisher
* @since 2.0
@@ -56,15 +56,19 @@ public class PublisherAnnotationBeanPostProcessor extends ProxyConfig
/**
* Set the default channel where Messages should be sent if the annotation
* itself does not provide a channel.
*
* @param defaultChannel The default channel.
*/
public void setDefaultChannel(MessageChannel defaultChannel){
this.defaultChannel = defaultChannel;
}
@Override
public void setBeanFactory(BeanFactory beanFactory) {
this.beanFactory = beanFactory;
}
@Override
public void setBeanClassLoader(ClassLoader classLoader) {
this.beanClassLoader = classLoader;
}
@@ -73,21 +77,25 @@ public class PublisherAnnotationBeanPostProcessor extends ProxyConfig
this.order = order;
}
@Override
public int getOrder() {
return this.order;
}
@Override
public void afterPropertiesSet(){
advisor = new PublisherAnnotationAdvisor();
advisor.setBeanFactory(beanFactory);
advisor.setDefaultChannel(defaultChannel);
}
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
return bean;
}
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
Class<?> targetClass = AopUtils.getTargetClass(bean);
if (targetClass == null) {
return bean;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* 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.
@@ -22,8 +22,9 @@ import java.util.Map;
/**
* Strategy for determining the channel name, payload expression, and header expressions
* for the {@link MessagePublishingInterceptor}.
*
*
* @author Mark Fisher
* @author Gary Russell
* @since 2.0
*/
interface PublisherMetadataSource {
@@ -40,12 +41,18 @@ interface PublisherMetadataSource {
/**
* Returns the channel name to which Messages should be published
* for this particular method invocation.
*
* @param method The Method.
* @return The channel name.
*/
String getChannelName(Method method);
/**
* Returns the expression string to be evaluated for creating the Message
* payload.
*
* @param method The Method.
* @return The payload expression.
*/
String getPayloadExpression(Method method);
@@ -53,6 +60,9 @@ interface PublisherMetadataSource {
* Returns the map of expression strings to be evaluated for any headers
* that should be set on the published Message. The keys in the Map are
* header names, the values are the expression strings.
*
* @param method The Method.
* @return The header expressions.
*/
Map<String, String> getHeaderExpressions(Method method);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* 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.
@@ -78,6 +78,9 @@ public abstract class AbstractMessageChannel extends IntegrationObjectSupport im
* <p>
* If this property is not set explicitly, any Message payload type will be
* accepted.
*
* @param datatypes The supported data types.
*
* @see #setConversionService(ConversionService)
*/
public void setDatatypes(Class<?>... datatypes) {
@@ -88,6 +91,8 @@ public abstract class AbstractMessageChannel extends IntegrationObjectSupport im
/**
* Set the list of channel interceptors. This will clear any existing
* interceptors.
*
* @param interceptors The list of interceptors.
*/
public void setInterceptors(List<ChannelInterceptor> interceptors) {
Collections.sort(interceptors, new OrderComparator());
@@ -96,6 +101,8 @@ public abstract class AbstractMessageChannel extends IntegrationObjectSupport im
/**
* Add a channel interceptor to the end of the list.
*
* @param interceptor The interceptor.
*/
public void addInterceptor(ChannelInterceptor interceptor) {
this.interceptors.add(interceptor);
@@ -109,6 +116,8 @@ public abstract class AbstractMessageChannel extends IntegrationObjectSupport im
* bean named "integrationConversionService" defined within that context.
* Finally, if that bean is not available, it will fallback to the
* "conversionService" bean, if available.
*
* @param conversionService The conversion service.
*/
@Override
public void setConversionService(ConversionService conversionService) {
@@ -117,6 +126,8 @@ public abstract class AbstractMessageChannel extends IntegrationObjectSupport im
/**
* Exposes the interceptor list for subclasses.
*
* @return The channel interceptor list.
*/
protected ChannelInterceptorList getInterceptors() {
return this.interceptors;
@@ -125,6 +136,7 @@ public abstract class AbstractMessageChannel extends IntegrationObjectSupport im
/**
* Returns the fully qualified channel name including the application context
* id, if available.
*
* @return The name.
*/
public String getFullChannelName() {
@@ -222,6 +234,10 @@ public abstract class AbstractMessageChannel extends IntegrationObjectSupport im
* must return immediately with or without success). A negative timeout
* value indicates that the method should block until either the message is
* accepted or the blocking thread is interrupted.
*
* @param message The message.
* @param timeout The timeout.
* @return true if the send was successful.
*/
protected abstract boolean doSend(Message<?> message, long timeout);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* 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.
@@ -21,7 +21,7 @@ import org.springframework.messaging.PollableChannel;
/**
* Base class for all pollable channels.
*
*
* @author Mark Fisher
*/
public abstract class AbstractPollableChannel extends AbstractMessageChannel implements PollableChannel {
@@ -29,10 +29,11 @@ public abstract class AbstractPollableChannel extends AbstractMessageChannel imp
/**
* Receive the first available message from this channel. If the channel
* contains no messages, this method will block.
*
*
* @return the first available message or <code>null</code> if the
* receiving thread is interrupted.
*/
@Override
public final Message<?> receive() {
return this.receive(-1);
}
@@ -43,13 +44,14 @@ public abstract class AbstractPollableChannel extends AbstractMessageChannel imp
* elapses. If the specified timeout is 0, the method will return
* immediately. If less than zero, it will block indefinitely (see
* {@link #receive()}).
*
*
* @param timeout the timeout in milliseconds
*
*
* @return the first available message or <code>null</code> if no message
* is available within the allotted time or the receiving thread is
* interrupted.
*/
@Override
public final Message<?> receive(long timeout) {
if (!this.getInterceptors().preReceive(this)) {
return null;
@@ -65,6 +67,9 @@ public abstract class AbstractPollableChannel extends AbstractMessageChannel imp
* return immediately with or without success). A negative timeout value
* indicates that the method should block until either a message is
* available or the blocking thread is interrupted.
*
* @param timeout The timeout.
* @return The message, or null.
*/
protected abstract Message<?> doReceive(long timeout);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* 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.
@@ -47,6 +47,8 @@ public class DirectChannel extends AbstractSubscribableChannel {
/**
* Create a DirectChannel with a {@link LoadBalancingStrategy}. The
* strategy <em>must not</em> be null.
*
* @param loadBalancingStrategy The load balancing strategy implementation.
*/
public DirectChannel(LoadBalancingStrategy loadBalancingStrategy) {
this.dispatcher.setLoadBalancingStrategy(loadBalancingStrategy);
@@ -56,6 +58,8 @@ public class DirectChannel extends AbstractSubscribableChannel {
/**
* Specify whether the channel's dispatcher should have failover enabled.
* By default, it will. Set this value to 'false' to disable it.
*
* @param failover The failover boolean.
*/
public void setFailover(boolean failover) {
this.dispatcher.setFailover(failover);
@@ -64,7 +68,8 @@ public class DirectChannel extends AbstractSubscribableChannel {
/**
* Specify the maximum number of subscribers supported by the
* channel's dispatcher.
* @param maxSubscribers
*
* @param maxSubscribers The maximum number of subscribers allowed.
*/
public void setMaxSubscribers(int maxSubscribers) {
this.maxSubscribers = maxSubscribers;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* 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.
@@ -63,6 +63,8 @@ public class ExecutorChannel extends AbstractSubscribableChannel {
* {@link Executor} when dispatching Messages.
* <p>
* The Executor must not be null.
*
* @param executor The executor.
*/
public ExecutorChannel(Executor executor) {
this(executor, new RoundRobinLoadBalancingStrategy());
@@ -73,6 +75,9 @@ public class ExecutorChannel extends AbstractSubscribableChannel {
* delegates to the provided {@link Executor} when dispatching Messages.
* <p>
* The Executor must not be null.
*
* @param executor The executor.
* @param loadBalancingStrategy The load balancing strategy implementation.
*/
public ExecutorChannel(Executor executor, LoadBalancingStrategy loadBalancingStrategy) {
Assert.notNull(executor, "executor must not be null");
@@ -88,6 +93,8 @@ public class ExecutorChannel extends AbstractSubscribableChannel {
/**
* Specify whether the channel's dispatcher should have failover enabled.
* By default, it will. Set this value to 'false' to disable it.
*
* @param failover The failover boolean.
*/
public void setFailover(boolean failover) {
this.failover = failover;
@@ -97,7 +104,8 @@ public class ExecutorChannel extends AbstractSubscribableChannel {
/**
* Specify the maximum number of subscribers supported by the
* channel's dispatcher.
* @param maxSubscribers
*
* @param maxSubscribers The maximum number of subscribers allowed.
*/
public void setMaxSubscribers(int maxSubscribers) {
this.maxSubscribers = maxSubscribers;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* 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.
@@ -44,6 +44,9 @@ public class PriorityChannel extends QueueChannel {
* will be determined by the provided {@link Comparator}. If the comparator
* is <code>null</code>, the priority will be based upon the value of
* {@link IntegrationMessageHeaderAccessor#getPriority()}.
*
* @param capacity The capacity.
* @param comparator The comparator.
*/
public PriorityChannel(int capacity, Comparator<Message<?>> comparator) {
super(new PriorityBlockingQueue<Message<?>>(11, new SequenceFallbackComparator(comparator)));
@@ -53,6 +56,8 @@ public class PriorityChannel extends QueueChannel {
/**
* Create a channel with the specified queue capacity. Message priority
* will be based upon the value of {@link IntegrationMessageHeaderAccessor#getPriority()}.
*
* @param capacity The queue capacity.
*/
public PriorityChannel(int capacity) {
this(capacity, null);
@@ -63,6 +68,8 @@ public class PriorityChannel extends QueueChannel {
* determined by the provided {@link Comparator}. If the comparator
* is <code>null</code>, the priority will be based upon the value of
* {@link IntegrationMessageHeaderAccessor#getPriority()}.
*
* @param comparator The comparator.
*/
public PriorityChannel(Comparator<Message<?>> comparator) {
this(0, comparator);
@@ -103,6 +110,7 @@ public class PriorityChannel extends QueueChannel {
this.targetComparator = targetComparator;
}
@Override
public int compare(Message<?> message1, Message<?> message2) {
int compareResult = 0;
if (this.targetComparator != null){
@@ -140,10 +148,12 @@ public class PriorityChannel extends QueueChannel {
return this.rootMessage;
}
@Override
public MessageHeaders getHeaders() {
return this.rootMessage.getHeaders();
}
@Override
public Object getPayload() {
return rootMessage.getPayload();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* 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.
@@ -55,6 +55,8 @@ public class PublishSubscribeChannel extends AbstractSubscribableChannel {
* Create a PublishSubscribeChannel that will use an {@link Executor}
* to invoke the handlers. If this is null, each invocation will occur in
* the message sender's thread.
*
* @param executor The executor.
*/
public PublishSubscribeChannel(Executor executor) {
this.executor = executor;
@@ -80,6 +82,9 @@ public class PublishSubscribeChannel extends AbstractSubscribableChannel {
* a {@link MessagePublishingErrorHandler} that sends error messages to
* the failed request Message's error channel header if available or to
* the default 'errorChannel' otherwise.
*
* @param errorHandler The error handler.
*
* @see #PublishSubscribeChannel(Executor)
*/
public void setErrorHandler(ErrorHandler errorHandler) {
@@ -91,6 +96,8 @@ public class PublishSubscribeChannel extends AbstractSubscribableChannel {
* ignored. By default this is <code>false</code> meaning that an Exception
* will be thrown whenever a handler fails. To override this and suppress
* Exceptions, set the value to <code>true</code>.
*
* @param ignoreFailures true if failures should be ignored.
*/
public void setIgnoreFailures(boolean ignoreFailures) {
this.ignoreFailures = ignoreFailures;
@@ -104,6 +111,8 @@ public class PublishSubscribeChannel extends AbstractSubscribableChannel {
* <em>not</em> be applied. If planning to use an Aggregator downstream
* with the default correlation and completion strategies, you should set
* this flag to <code>true</code>.
*
* @param applySequence true if the sequence information should be applied.
*/
public void setApplySequence(boolean applySequence) {
this.applySequence = applySequence;
@@ -113,7 +122,8 @@ public class PublishSubscribeChannel extends AbstractSubscribableChannel {
/**
* Specify the maximum number of subscribers supported by the
* channel's dispatcher.
* @param maxSubscribers
*
* @param maxSubscribers The maximum number of subscribers allowed.
*/
public void setMaxSubscribers(int maxSubscribers) {
this.maxSubscribers = maxSubscribers;
@@ -124,6 +134,7 @@ public class PublishSubscribeChannel extends AbstractSubscribableChannel {
* If at least this number of subscribers receive the message,
* {@link #send(org.springframework.messaging.Message)}
* will return true. Default: 0.
*
* @param minSubscribers The minimum number of subscribers.
*/
public void setMinSubscribers(int minSubscribers) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* 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.
@@ -22,8 +22,8 @@ import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
import org.springframework.messaging.Message;
import org.springframework.integration.core.MessageSelector;
import org.springframework.messaging.Message;
import org.springframework.util.Assert;
/**
@@ -43,6 +43,8 @@ public class QueueChannel extends AbstractPollableChannel implements QueueChanne
/**
* Create a channel with the specified queue.
*
* @param queue The queue.
*/
public QueueChannel(BlockingQueue<Message<?>> queue) {
Assert.notNull(queue, "'queue' must not be null");
@@ -51,6 +53,8 @@ public class QueueChannel extends AbstractPollableChannel implements QueueChanne
/**
* Create a channel with the specified queue capacity.
*
* @param capacity The capacity.
*/
public QueueChannel(int capacity) {
Assert.isTrue(capacity > 0, "The capacity must be a positive integer. " +
@@ -104,18 +108,14 @@ public class QueueChannel extends AbstractPollableChannel implements QueueChanne
}
}
/**
* Remove all {@link Message Messages} from this channel.
*/
@Override
public List<Message<?>> clear() {
List<Message<?>> clearedMessages = new ArrayList<Message<?>>();
this.queue.drainTo(clearedMessages);
return clearedMessages;
}
/**
* Remove any {@link Message Messages} that are not accepted by the provided selector.
*/
@Override
public List<Message<?>> purge(MessageSelector selector) {
if (selector == null) {
return this.clear();
@@ -131,10 +131,12 @@ public class QueueChannel extends AbstractPollableChannel implements QueueChanne
return purgedMessages;
}
@Override
public int getQueueSize() {
return this.queue.size();
}
@Override
public int getRemainingCapacity() {
return this.queue.remainingCapacity();
}

View File

@@ -17,8 +17,8 @@ package org.springframework.integration.channel;
import java.util.List;
import org.springframework.messaging.Message;
import org.springframework.integration.core.MessageSelector;
import org.springframework.messaging.Message;
/**
* Operations available on a channel that has queuing semantics.
@@ -31,21 +31,26 @@ public interface QueueChannelOperations {
/**
* Remove all {@link Message Messages} from this channel.
*
* @return The messages that were removed.
*/
List<Message<?>> clear();
/**
* Remove any {@link Message Messages} that are not accepted by the provided selector.
*
* @param selector The message selector.
* @return The list of messages that were purged.
*/
List<Message<?>> purge(MessageSelector selector);
/**
* Return the current number of queued {@link Message Messages} in this channel.
* @return The current number of queued {@link Message Messages} in this channel.
*/
int getQueueSize();
/**
* Return the remaining capacity of this channel.
* @return The remaining capacity of this channel.
*/
int getRemainingCapacity();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* 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
@@ -73,6 +73,7 @@ public abstract class AbstractSimpleMessageHandlerFactoryBean<H extends MessageH
this.order = order;
}
@Override
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
this.beanFactory = beanFactory;
}
@@ -88,12 +89,13 @@ public abstract class AbstractSimpleMessageHandlerFactoryBean<H extends MessageH
/**
* Sets the name of the handler component.
*
* @param componentName
* @param componentName The component name.
*/
public void setComponentName(String componentName) {
this.componentName = componentName;
}
@Override
public H getObject() throws Exception {
if (this.handler == null) {
this.handler = this.createHandlerInternal();
@@ -140,6 +142,7 @@ public abstract class AbstractSimpleMessageHandlerFactoryBean<H extends MessageH
protected abstract H createHandler();
@Override
public Class<? extends MessageHandler> getObjectType() {
if (this.handler != null) {
return this.handler.getClass();
@@ -147,6 +150,7 @@ public abstract class AbstractSimpleMessageHandlerFactoryBean<H extends MessageH
return MessageHandler.class;
}
@Override
public boolean isSingleton() {
return true;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013 the original author or authors.
* Copyright 2013-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.
@@ -56,7 +56,6 @@ import org.springframework.util.Assert;
* a set of provided SpEL functions.
* </li>
* </ul>
* <p/>
* <p>
* After initialization this factory populates functions and property accessors from
* {@link SpelFunctionFactoryBean}s and {@link SpelPropertyAccessorRegistrar}, respectively.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* 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.
@@ -67,6 +67,7 @@ public abstract class AbstractMethodAnnotationPostProcessor<T extends Annotation
}
@Override
public Object postProcess(Object bean, String beanName, Method method, T annotation) {
MessageHandler handler = this.createHandler(bean, method, annotation);
setAdviceChainIfPresent(beanName, annotation, handler);
@@ -142,6 +143,11 @@ public abstract class AbstractMethodAnnotationPostProcessor<T extends Annotation
/**
* Subclasses must implement this method to create the MessageHandler.
*
* @param bean The bean.
* @param method The method.
* @param annotation The annotation.
* @return The MessageHandler.
*/
protected abstract MessageHandler createHandler(Object bean, Method method, T annotation);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* 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.
@@ -30,7 +30,7 @@ import org.springframework.util.StringUtils;
/**
* Base parser for Channel Adapters.
* <p/>
* <p>
* Includes logic to determine {@link org.springframework.messaging.MessageChannel}:
* if 'channel' attribute is defined - uses its value as 'channelName';
* if 'id' attribute is defined - creates {@link DirectChannel} at runtime and uses id's value as 'channelName';
@@ -87,6 +87,11 @@ public abstract class AbstractChannelAdapterParser extends AbstractBeanDefinitio
/**
* Subclasses must implement this method to parse the adapter element.
* The name of the MessageChannel bean is provided.
*
* @param element The element.
* @param parserContext The parser context.
* @param channelName The channel name.
* @return The bean definition.
*/
protected abstract AbstractBeanDefinition doParse(Element element, ParserContext parserContext, String channelName);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* 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.
@@ -65,9 +65,6 @@ public abstract class AbstractChannelParser extends AbstractBeanDefinitionParser
return beanDefinition;
}
/* (non-Javadoc)
* @see org.springframework.beans.factory.xml.AbstractBeanDefinitionParser#registerBeanDefinition(org.springframework.beans.factory.config.BeanDefinitionHolder, org.springframework.beans.factory.support.BeanDefinitionRegistry)
*/
@Override
protected void registerBeanDefinition(BeanDefinitionHolder definition, BeanDefinitionRegistry registry) {
String scope = definition.getBeanDefinition().getScope();
@@ -83,6 +80,10 @@ public abstract class AbstractChannelParser extends AbstractBeanDefinitionParser
* arguments or properties should be configured. This base class will
* configure the interceptors including the 'datatype' interceptor if
* the 'datatype' attribute is defined on the channel element.
*
* @param element The element.
* @param parserContext The parser context.
* @return The bean definition builder.
*/
protected abstract BeanDefinitionBuilder buildBeanDefinition(Element element, ParserContext parserContext);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* 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.
@@ -68,6 +68,10 @@ public abstract class AbstractConsumerEndpointParser extends AbstractBeanDefinit
/**
* Parse the MessageHandler.
*
* @param element The element.
* @param parserContext The parser context.
* @return The bean definition builder.
*/
protected abstract BeanDefinitionBuilder parseHandler(Element element, ParserContext parserContext);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* 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.
@@ -125,6 +125,10 @@ abstract class AbstractDelegatingConsumerEndpointParser extends AbstractConsumer
/**
* Subclasses may override this no-op method to provide additional configuration.
*
* @param builder The builder.
* @param element The element.
* @param parserContext The parser context.
*/
void postProcess(BeanDefinitionBuilder builder, Element element, ParserContext parserContext) {
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* 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.
@@ -28,7 +28,7 @@ import org.springframework.util.StringUtils;
/**
* Base class for inbound gateway parsers.
*
*
* @author Mark Fisher
* @author Gary Russell
*/
@@ -76,6 +76,9 @@ public abstract class AbstractInboundGatewayParser extends AbstractSimpleBeanDef
/**
* Subclasses may add to the bean definition by overriding this method.
*
* @param builder The builder.
* @param element The element.
*/
protected void doPostProcess(BeanDefinitionBuilder builder, Element element) {
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* 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.
@@ -123,6 +123,10 @@ public abstract class AbstractOutboundChannelAdapterParser extends AbstractChann
* Override this method to control the registration process and return the bean name.
* If parsing a bean definition whose name can be auto-generated, consider using
* {@link #parseConsumer(Element, ParserContext)} instead.
*
* @param element The element.
* @param parserContext The parser context.
* @return The bean component definition.
*/
protected BeanComponentDefinition doParseAndRegisterConsumer(Element element, ParserContext parserContext) {
AbstractBeanDefinition definition = this.parseConsumer(element, parserContext);
@@ -143,12 +147,17 @@ public abstract class AbstractOutboundChannelAdapterParser extends AbstractChann
/**
* Override this method to return the BeanDefinition for the MessageConsumer. It will
* be registered with a generated name.
*
* @param element The element.
* @param parserContext The parser context.
* @return The bean definition.
*/
protected abstract AbstractBeanDefinition parseConsumer(Element element, ParserContext parserContext);
/**
* Override this to signal that this channel adapter is actually using a AbstractReplyProducingMessageHandler
* while it is not possible for this parser to determine that because, say, a FactoryBean is being used.
*
* @return false, unless overridden.
*/
protected boolean isUsingReplyProducer() {

View File

@@ -61,6 +61,10 @@ public abstract class AbstractOutboundGatewayParser extends AbstractConsumerEndp
/**
* Subclasses may override this method for additional configuration.
* @param builder The builder.
* @param element The element.
* @param parserContext The parser context.
*/
protected void postProcessGateway(BeanDefinitionBuilder builder, Element element, ParserContext parserContext) {
}

View File

@@ -62,6 +62,10 @@ public abstract class AbstractPollingInboundChannelAdapterParser extends Abstrac
/**
* Subclasses must implement this method to parse the PollableSource instance
* which the created Channel Adapter will poll.
*
* @param element The element.
* @param parserContext The parser context.
* @return The bean metadata element.
*/
protected abstract BeanMetadataElement parseSource(Element element, ParserContext parserContext);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* 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.
@@ -68,6 +68,8 @@ public abstract class AbstractRouterParser extends AbstractConsumerEndpointParse
/**
* Returns the name of the attribute that provides a key for the
* channel mappings. This can be overridden by subclasses.
*
* @return The mapping key attribute name.
*/
protected String getMappingKeyAttributeName() {
return "value";

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* 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.
@@ -281,6 +281,10 @@ public abstract class HeaderEnricherParserSupport extends AbstractTransformerPar
/**
* Subclasses may override this method to provide any additional processing.
*
* @param builder The builder.
* @param element The element.
* @param parserContext The parser context.
*/
protected void postProcessHeaderEnricher(BeanDefinitionBuilder builder, Element element, ParserContext parserContext) {
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* 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
@@ -205,6 +205,9 @@ public abstract class IntegrationNamespaceUtils {
/**
* Provides a user friendly description of an element based on its node name and, if available, its "id" attribute
* value. This is useful for creating error messages from within bean definition parsers.
*
* @param element The element.
* @return The description.
*/
public static String createElementDescription(Element element) {
String elementId = "'" + element.getNodeName() + "'";
@@ -303,7 +306,13 @@ public abstract class IntegrationNamespaceUtils {
}
/**
* Utility method to configure HeaderMapper for Inbound and Outbound channel adapters/gateway
* Utility method to configure a HeaderMapper for Inbound and Outbound channel adapters/gateway.
*
* @param element The element.
* @param rootBuilder The root builder.
* @param parserContext The parser context.
* @param headerMapperClass The header mapper class.
* @param replyHeaderValue The reply header value.
*/
public static void configureHeaderMapper(Element element, BeanDefinitionBuilder rootBuilder,
ParserContext parserContext, Class<?> headerMapperClass, String replyHeaderValue) {
@@ -340,7 +349,10 @@ public abstract class IntegrationNamespaceUtils {
/**
* Parse a "transactional" element and configure a {@link TransactionInterceptor}
* with "transactionManager" and other "transactionDefinition" properties.
* For example, this advisor will be applied on the Polling Task proxy
* For example, this advisor will be applied on the Polling Task proxy.
*
* @param txElement The transactional element.
* @return The bean definition.
*
* @see AbstractPollingEndpoint
*/
@@ -357,6 +369,9 @@ public abstract class IntegrationNamespaceUtils {
/**
* Parse attributes of "transactional" element and configure a {@link DefaultTransactionAttribute}
* with provided "transactionDefinition" properties.
*
* @param txElement The transactional element.
* @return The bean definition.
*/
public static BeanDefinition configureTransactionDefinition(Element txElement) {
BeanDefinitionBuilder txDefinitionBuilder = BeanDefinitionBuilder.genericBeanDefinition(DefaultTransactionAttribute.class);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* 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.
@@ -52,32 +52,32 @@ public abstract class IntegrationContextUtils {
public static final String INTEGRATION_GLOBAL_PROPERTIES_BEAN_NAME = "integrationGlobalProperties";
/**
* Return the {@link MetadataStore} bean whose name is "metadataStore".
* @param beanFactory BeanFactory for lookup, must not be null.
* @return The {@link MetadataStore} bean whose name is "metadataStore".
*/
public static MetadataStore getMetadataStore(BeanFactory beanFactory) {
return getBeanOfType(beanFactory, METADATA_STORE_BEAN_NAME, MetadataStore.class);
}
/**
* Return the {@link MessageChannel} bean whose name is "errorChannel".
* @param beanFactory BeanFactory for lookup, must not be null.
* @return The {@link MessageChannel} bean whose name is "errorChannel".
*/
public static MessageChannel getErrorChannel(BeanFactory beanFactory) {
return getBeanOfType(beanFactory, ERROR_CHANNEL_BEAN_NAME, MessageChannel.class);
}
/**
* Return the {@link TaskScheduler} bean whose name is "taskScheduler" if available.
* @param beanFactory BeanFactory for lookup, must not be null.
* @return The {@link TaskScheduler} bean whose name is "taskScheduler" if available.
*/
public static TaskScheduler getTaskScheduler(BeanFactory beanFactory) {
return getBeanOfType(beanFactory, TASK_SCHEDULER_BEAN_NAME, TaskScheduler.class);
}
/**
* Return the {@link TaskScheduler} bean whose name is "taskScheduler".
* @param beanFactory BeanFactory for lookup, must not be null.
* @return The {@link TaskScheduler} bean whose name is "taskScheduler".
* @throws IllegalStateException if no such bean is available
*/
public static TaskScheduler getRequiredTaskScheduler(BeanFactory beanFactory) {
@@ -87,16 +87,16 @@ public abstract class IntegrationContextUtils {
}
/**
* Return the {@link ConversionService} bean whose name is "integrationConversionService" if available.
* @param beanFactory BeanFactory for lookup, must not be null.
* @return The {@link ConversionService} bean whose name is "integrationConversionService" if available.
*/
public static ConversionService getConversionService(BeanFactory beanFactory) {
return getBeanOfType(beanFactory, INTEGRATION_CONVERSION_SERVICE_BEAN_NAME, ConversionService.class);
}
/**
* Return the instance of {@link StandardEvaluationContext} bean whose name is "integrationEvaluationContext" .
* @param beanFactory BeanFactory for lookup, must not be null.
* @return the instance of {@link StandardEvaluationContext} bean whose name is "integrationEvaluationContext" .
*/
public static StandardEvaluationContext getEvaluationContext(BeanFactory beanFactory) {
return getBeanOfType(beanFactory, INTEGRATION_EVALUATION_CONTEXT_BEAN_NAME, StandardEvaluationContext.class);
@@ -111,6 +111,7 @@ public abstract class IntegrationContextUtils {
}
/**
* @param beanFactory The bean factory.
* @return the global {@link IntegrationContextUtils#INTEGRATION_GLOBAL_PROPERTIES_BEAN_NAME}
* bean from provided {@code #beanFactory}, which represents the merged
* properties values from all 'META-INF/spring.integration.default.properties'

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* 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.
@@ -39,7 +39,7 @@ import org.springframework.util.StringUtils;
/**
* A base class that provides convenient access to the bean factory as
* well as {@link TaskScheduler} and {@link ConversionService} instances.
* <p>
*
* <p>This is intended to be used as a base class for internal framework
* components whereas code built upon the integration framework should not
* require tight coupling with the context but rather rely on standard
@@ -76,6 +76,7 @@ public abstract class IntegrationObjectSupport implements BeanNameAware, NamedCo
private volatile ApplicationContext applicationContext;
@Override
public final void setBeanName(String beanName) {
this.beanName = beanName;
}
@@ -84,14 +85,14 @@ public abstract class IntegrationObjectSupport implements BeanNameAware, NamedCo
* Will return the name of this component identified by {@link #componentName} field.
* If {@link #componentName} was not set this method will default to the 'beanName' of this component;
*/
@Override
public final String getComponentName() {
return StringUtils.hasText(this.componentName) ? this.componentName : this.beanName;
}
/**
* Sets the name of this component.
*
* @param componentName
* @param componentName The component name.
*/
public void setComponentName(String componentName) {
this.componentName = componentName;
@@ -100,21 +101,25 @@ public abstract class IntegrationObjectSupport implements BeanNameAware, NamedCo
/**
* Subclasses may implement this method to provide component type information.
*/
@Override
public String getComponentType() {
return null;
}
@Override
public final void setBeanFactory(BeanFactory beanFactory) {
Assert.notNull(beanFactory, "'beanFactory' must not be null");
this.beanFactory = beanFactory;
this.integrationProperties = IntegrationContextUtils.getIntegrationProperties(this.beanFactory);
}
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
Assert.notNull(applicationContext, "'applicationContext' must not be null");
this.applicationContext = applicationContext;
}
@Override
public final void afterPropertiesSet() {
try {
this.onInit();
@@ -129,6 +134,7 @@ public abstract class IntegrationObjectSupport implements BeanNameAware, NamedCo
/**
* Subclasses may implement this for initialization logic.
* @throws Exception Any exception.
*/
protected void onInit() throws Exception {
}
@@ -179,7 +185,8 @@ public abstract class IntegrationObjectSupport implements BeanNameAware, NamedCo
}
/**
* @see IntegrationContextUtils#getIntegrationProperties
* @see IntegrationContextUtils#getIntegrationProperties(BeanFactory)
* @return The global integration properties.
*/
protected Properties getIntegrationProperties() {
return this.integrationProperties;
@@ -188,6 +195,7 @@ public abstract class IntegrationObjectSupport implements BeanNameAware, NamedCo
/**
* @param key Integration property.
* @param tClass the class to convert a value of Integration property.
* @param <T> The expected type of the property.
* @return the value of the Integration property converted to the provide type.
*/
protected <T> T getIntegrationProperty(String key, Class<T> tClass) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013 the original author or authors.
* 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.
@@ -55,8 +55,7 @@ public final class IntegrationProperties {
/**
* Specifies the value of {@link org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler#poolSize}
* for {@code taskScheduler} bean initialized but Integration infrastructure.
* @see org.springframework.integration.config.xml.DefaultConfiguringBeanFactoryPostProcessor#registerTaskScheduler
* for the {@code taskScheduler} bean initialized by the AbstractTransformerIntegration infrastructure.
*/
public static final String TASKSCHEDULER_POOLSIZE = "taskScheduler.poolSize";

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* 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.
@@ -22,7 +22,7 @@ import org.springframework.core.Ordered;
* Interface that extends {@link Ordered} while also exposing the
* {@link #setOrder(int)} as an interface-level so that it is avaiable
* on AOP proxies, etc.
*
*
* @author Mark Fisher
* @since 2.0
*/
@@ -30,6 +30,8 @@ public interface Orderable extends Ordered {
/**
* Set the order for this component.
*
* @param order the order.
*/
void setOrder(int order);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* 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.
@@ -21,7 +21,7 @@ import org.springframework.messaging.MessageChannel;
/**
* Base interface for any component that is capable of sending
* Messages to a {@link MessageChannel}.
*
*
* @author Mark Fisher
* @since 2.0
*/
@@ -29,6 +29,8 @@ public interface MessageProducer {
/**
* Specify the MessageChannel to which produced Messages should be sent.
*
* @param outputChannel The output channel.
*/
void setOutputChannel(MessageChannel outputChannel);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* 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.
@@ -19,8 +19,8 @@ package org.springframework.integration.core;
import org.springframework.messaging.Message;
/**
* Base interface for any source of {@link Message Messages} that can be polled.
*
* Base interface for any source of {@link Message Messages} that can be polled.
*
* @author Mark Fisher
*/
public interface MessageSource<T> {
@@ -28,6 +28,8 @@ public interface MessageSource<T> {
/**
* Retrieve the next available message from this source.
* Returns <code>null</code> if no message is available.
*
* @return The messasge or null.
*/
Message<T> receive();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* 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.
@@ -20,6 +20,7 @@ import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.messaging.MessageHandler;
import org.springframework.util.Assert;
@@ -49,7 +50,7 @@ public abstract class AbstractDispatcher implements MessageDispatcher {
/**
* Set the maximum subscribers allowed by this dispatcher.
* @param maxSubscribers
* @param maxSubscribers The maximum number of subscribers allowed.
*/
public void setMaxSubscribers(int maxSubscribers) {
this.maxSubscribers = maxSubscribers;
@@ -58,6 +59,8 @@ public abstract class AbstractDispatcher implements MessageDispatcher {
/**
* Returns an unmodifiable {@link Set} of this dispatcher's handlers. This
* is provided for access by subclasses.
*
* @return The message handlers.
*/
protected Set<MessageHandler> getHandlers() {
return handlers.asUnmodifiableSet();
@@ -66,8 +69,10 @@ public abstract class AbstractDispatcher implements MessageDispatcher {
/**
* Add the handler to the internal Set.
*
* @param handler The handler to add.
* @return the result of {@link Set#add(Object)}
*/
@Override
public boolean addHandler(MessageHandler handler) {
Assert.notNull(handler, "handler must not be null");
Assert.isTrue(this.handlers.size() < this.maxSubscribers, "Maximum subscribers exceeded");
@@ -79,6 +84,7 @@ public abstract class AbstractDispatcher implements MessageDispatcher {
*
* @return the result of {@link Set#remove(Object)}
*/
@Override
public boolean removeHandler(MessageHandler handler) {
Assert.notNull(handler, "handler must not be null");
return this.handlers.remove(handler);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* 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.
@@ -78,6 +78,8 @@ public class BroadcastingDispatcher extends AbstractDispatcher {
* one throws an Exception. Since the Executor is most likely using a different thread, this flag would only affect
* whether an error Message is sent to the error channel or not in the case that such an Executor has been
* configured.
*
* @param ignoreFailures true when failures are to be ignored.
*/
public void setIgnoreFailures(boolean ignoreFailures) {
this.ignoreFailures = ignoreFailures;
@@ -85,7 +87,9 @@ public class BroadcastingDispatcher extends AbstractDispatcher {
/**
* Specify whether to apply sequence numbers to the messages prior to sending to the handlers. By default, sequence
* numbers will <em>not</em> be applied
* numbers will <em>not</em> be applied.
*
* @param applySequence true when sequence information should be applied.
*/
public void setApplySequence(boolean applySequence) {
this.applySequence = applySequence;
@@ -100,6 +104,7 @@ public class BroadcastingDispatcher extends AbstractDispatcher {
this.minSubscribers = minSubscribers;
}
@Override
public boolean dispatch(Message<?> message) {
int dispatched = 0;
int sequenceNumber = 1;
@@ -113,6 +118,7 @@ public class BroadcastingDispatcher extends AbstractDispatcher {
.pushSequenceDetails(message.getHeaders().getId(), sequenceNumber++, sequenceSize).build();
if (this.executor != null) {
this.executor.execute(new Runnable() {
@Override
public void run() {
invokeHandler(handler, messageToSend);
}

View File

@@ -1,4 +1,4 @@
/* Copyright 2002-2013 the original author or authors.
/* 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.
@@ -71,6 +71,8 @@ public class UnicastingDispatcher extends AbstractDispatcher {
* Specify whether this dispatcher should failover when a single
* {@link MessageHandler} throws an Exception. The default value is
* <code>true</code>.
*
* @param failover The failover boolean.
*/
public void setFailover(boolean failover) {
this.failover = failover;
@@ -78,6 +80,8 @@ public class UnicastingDispatcher extends AbstractDispatcher {
/**
* Provide a {@link LoadBalancingStrategy} for this dispatcher.
*
* @param loadBalancingStrategy The load balancing strategy implementation.
*/
public void setLoadBalancingStrategy(LoadBalancingStrategy loadBalancingStrategy) {
Lock lock = rwLock.writeLock();
@@ -90,9 +94,11 @@ public class UnicastingDispatcher extends AbstractDispatcher {
}
}
@Override
public final boolean dispatch(final Message<?> message) {
if (this.executor != null) {
this.executor.execute(new Runnable() {
@Override
public void run() {
doDispatch(message);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2011 the original author or authors.
* 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.
@@ -21,11 +21,11 @@ import java.util.HashMap;
import java.util.Map;
import org.springframework.expression.Expression;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessagingException;
import org.springframework.integration.core.MessageSource;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.integration.util.AbstractExpressionEvaluator;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessagingException;
import org.springframework.util.CollectionUtils;
/**
@@ -43,9 +43,10 @@ public abstract class AbstractMessageSource<T> extends AbstractExpressionEvaluat
? headerExpressions : Collections.<String, Expression>emptyMap();
}
@Override
@SuppressWarnings("unchecked")
public final Message<T> receive() {
Message<T> message = null;
Message<T> message = null;
Object result = this.doReceive();
Map<String, Object> headers = this.evaluateHeaders();
if (result instanceof Message<?>) {
@@ -93,6 +94,8 @@ public abstract class AbstractMessageSource<T> extends AbstractExpressionEvaluat
/**
* Subclasses must implement this method. Typically the returned value will be the payload of
* type T, but the returned value may also be a Message instance whose payload is of type T.
*
* @return The value returned.
*/
protected abstract Object doReceive();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* 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.
@@ -17,6 +17,7 @@
package org.springframework.integration.endpoint;
import org.springframework.integration.core.MessageSource;
import org.springframework.integration.core.MessagingTemplate;
import org.springframework.integration.history.MessageHistory;
import org.springframework.integration.history.TrackableComponent;
import org.springframework.integration.support.context.NamedComponent;
@@ -24,7 +25,6 @@ import org.springframework.integration.transaction.IntegrationResourceHolder;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessagingException;
import org.springframework.integration.core.MessagingTemplate;
import org.springframework.util.Assert;
/**
@@ -48,6 +48,8 @@ public class SourcePollingChannelAdapter extends AbstractPollingEndpoint
/**
* Specify the source to be polled for Messages.
*
* @param source The message source.
*/
public void setSource(MessageSource<?> source) {
this.source = source;
@@ -55,6 +57,8 @@ public class SourcePollingChannelAdapter extends AbstractPollingEndpoint
/**
* Specify the {@link MessageChannel} where Messages should be sent.
*
* @param outputChannel The output channel.
*/
public void setOutputChannel(MessageChannel outputChannel) {
this.outputChannel = outputChannel;
@@ -63,6 +67,8 @@ public class SourcePollingChannelAdapter extends AbstractPollingEndpoint
/**
* Specify the maximum time to wait for a Message to be sent to the
* output channel.
*
* @param sendTimeout The send timeout.
*/
public void setSendTimeout(long sendTimeout) {
this.messagingTemplate.setSendTimeout(sendTimeout);
@@ -70,7 +76,10 @@ public class SourcePollingChannelAdapter extends AbstractPollingEndpoint
/**
* Specify whether this component should be tracked in the Message History.
*
* @param shouldTrack true if the component should be tracked.
*/
@Override
public void setShouldTrack(boolean shouldTrack) {
this.shouldTrack = shouldTrack;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013 the original author or authors.
* Copyright 2013-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.
@@ -41,6 +41,7 @@ import org.springframework.util.Assert;
* <p>
* A {@link ExpressionEvalMapBuilder} must be used to instantiate this class
* via its {@link #from(Map)} method:
* </p>
* <pre class="code">
* {@code
*ExpressionEvalMap evalMap = ExpressionEvalMap
@@ -53,7 +54,6 @@ import org.springframework.util.Assert;
* .build();
*}
* </pre>
* </p>
* <p>
* Thread-safety depends on the original underlying Map.
* Objects of this class are not serializable.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* 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.
@@ -70,7 +70,7 @@ public abstract class ExpressionUtils {
/**
* Obtains the context from the beanFactory if not null; emits a warning if the beanFactory
* is null.
* @param beanFactory
* @param beanFactory The bean factory.
* @return The evaluation context.
*/
public static StandardEvaluationContext createStandardEvaluationContext(BeanFactory beanFactory) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* 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.
@@ -47,7 +47,7 @@ import org.springframework.util.StringUtils;
* This class uses {@link java.util.Properties} instances as its custom data structure for expressions,
* loading them via a {@link org.springframework.util.PropertiesPersister} strategy: The default
* strategy is capable of loading properties files with a specific character encoding, if desired.
*
*
* @author Juergen Hoeller
* @author Mark Fisher
* @since 2.0
@@ -179,6 +179,8 @@ public class ReloadableResourceBundleExpressionSource implements ExpressionSourc
* desirable in an application server environment, where the system Locale
* is not relevant to the application at all: Set this flag to "false"
* in such a scenario.
*
* @param fallbackToSystemLocale true to fall back.
*/
public void setFallbackToSystemLocale(boolean fallbackToSystemLocale) {
this.fallbackToSystemLocale = fallbackToSystemLocale;
@@ -197,6 +199,8 @@ public class ReloadableResourceBundleExpressionSource implements ExpressionSourc
* <li>A value of "0" will check the last-modified timestamp of the file on
* every expression access. <b>Do not use this in a production environment!</b>
* </ul>
*
* @param cacheSeconds The cache seconds.
*/
public void setCacheSeconds(int cacheSeconds) {
this.cacheMillis = (cacheSeconds * 1000);
@@ -205,6 +209,9 @@ public class ReloadableResourceBundleExpressionSource implements ExpressionSourc
/**
* Set the PropertiesPersister to use for parsing properties files.
* <p>The default is a DefaultPropertiesPersister.
*
* @param propertiesPersister The properties persister.
*
* @see org.springframework.util.DefaultPropertiesPersister
*/
public void setPropertiesPersister(PropertiesPersister propertiesPersister) {
@@ -221,6 +228,7 @@ public class ReloadableResourceBundleExpressionSource implements ExpressionSourc
* @see org.springframework.core.io.DefaultResourceLoader
* @see org.springframework.context.ResourceLoaderAware
*/
@Override
public void setResourceLoader(ResourceLoader resourceLoader) {
this.resourceLoader = (resourceLoader != null ? resourceLoader : new DefaultResourceLoader());
}
@@ -229,6 +237,7 @@ public class ReloadableResourceBundleExpressionSource implements ExpressionSourc
/**
* Resolves the given key in the retrieved bundle files to an Expression.
*/
@Override
public Expression getExpression(String key, Locale locale) {
String expressionString = this.getExpressionString(key, locale);
if (expressionString != null) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* 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.
@@ -17,11 +17,11 @@
package org.springframework.integration.filter;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.integration.MessageRejectedException;
import org.springframework.integration.core.MessageSelector;
import org.springframework.integration.handler.AbstractReplyProducingPostProcessingMessageHandler;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.util.Assert;
/**
@@ -49,6 +49,8 @@ public class MessageFilter extends AbstractReplyProducingPostProcessingMessageHa
/**
* Create a MessageFilter that will delegate to the given
* {@link MessageSelector}.
*
* @param selector The message selector.
*/
public MessageFilter(MessageSelector selector) {
Assert.notNull(selector, "selector must not be null");
@@ -66,6 +68,8 @@ public class MessageFilter extends AbstractReplyProducingPostProcessingMessageHa
* (in such a case, the Message will be sent to the discard channel,
* and <em>then</em> the exception will be thrown).
* @see #setDiscardChannel(MessageChannel)
*
* @param throwExceptionOnRejection true if an exception should be thrown.
*/
public void setThrowExceptionOnRejection(boolean throwExceptionOnRejection) {
this.throwExceptionOnRejection = throwExceptionOnRejection;
@@ -77,6 +81,9 @@ public class MessageFilter extends AbstractReplyProducingPostProcessingMessageHa
* the 'throwExceptionOnRejection' flag determines whether rejected Messages
* trigger an exception. That value is evaluated regardless of the presence
* of a discard channel.
*
* @param discardChannel The discard channel.
*
* @see #setThrowExceptionOnRejection(boolean)
*/
public void setDiscardChannel(MessageChannel discardChannel) {
@@ -87,6 +94,8 @@ public class MessageFilter extends AbstractReplyProducingPostProcessingMessageHa
* Set to 'true' if you wish the discard processing to occur within any
* request handler advice applied to this filter. Also applies to
* throwing an exception on rejection. Default: true.
*
* @param discardWithinAdvice true to discard within the advice.
*/
public void setDiscardWithinAdvice(boolean discardWithinAdvice) {
this.setPostProcessWithinAdvice(discardWithinAdvice);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* 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.
@@ -126,6 +126,8 @@ public class GatewayProxyFactoryBean extends AbstractEndpoint implements Trackab
/**
* Set the interface class that the generated proxy should implement.
* If none is provided explicitly, the default is {@link RequestReplyExchanger}.
*
* @param serviceInterface The service interface.
*/
public void setServiceInterface(Class<?> serviceInterface) {
Assert.notNull(serviceInterface, "'serviceInterface' must not be null");
@@ -137,7 +139,7 @@ public class GatewayProxyFactoryBean extends AbstractEndpoint implements Trackab
* Set the default request channel.
*
* @param defaultRequestChannel the channel to which request messages will
* be sent if no request channel has been configured with an annotation
* be sent if no request channel has been configured with an annotation.
*/
public void setDefaultRequestChannel(MessageChannel defaultRequestChannel) {
this.defaultRequestChannel = defaultRequestChannel;
@@ -159,6 +161,8 @@ public class GatewayProxyFactoryBean extends AbstractEndpoint implements Trackab
* Set the error channel. If no error channel is provided, this gateway will
* propagate Exceptions to the caller. To completely suppress Exceptions, provide
* a reference to the "nullChannel" here.
*
* @param errorChannel The error channel.
*/
public void setErrorChannel(MessageChannel errorChannel) {
this.errorChannel = errorChannel;
@@ -184,6 +188,7 @@ public class GatewayProxyFactoryBean extends AbstractEndpoint implements Trackab
this.defaultReplyTimeout = defaultReplyTimeout;
}
@Override
public void setShouldTrack(boolean shouldTrack) {
this.shouldTrack = shouldTrack;
if (!CollectionUtils.isEmpty(this.gatewayMap)) {
@@ -212,6 +217,7 @@ public class GatewayProxyFactoryBean extends AbstractEndpoint implements Trackab
this.globalMethodMetadata = globalMethodMetadata;
}
@Override
public void setBeanClassLoader(ClassLoader beanClassLoader) {
this.beanClassLoader = beanClassLoader;
}
@@ -254,10 +260,12 @@ public class GatewayProxyFactoryBean extends AbstractEndpoint implements Trackab
return this.serviceInterface;
}
@Override
public Class<?> getObjectType() {
return (this.serviceInterface != null ? this.serviceInterface : null);
}
@Override
public Object getObject() throws Exception {
if (this.serviceProxy == null) {
this.onInit();
@@ -266,10 +274,12 @@ public class GatewayProxyFactoryBean extends AbstractEndpoint implements Trackab
return this.serviceProxy;
}
@Override
public boolean isSingleton() {
return true;
}
@Override
public Object invoke(final MethodInvocation invocation) throws Throwable {
if (Future.class.isAssignableFrom(invocation.getMethod().getReturnType())) {
return this.asyncExecutor.submit(new AsyncInvocationTask(invocation));
@@ -514,6 +524,7 @@ public class GatewayProxyFactoryBean extends AbstractEndpoint implements Trackab
this.invocation = invocation;
}
@Override
public Object call() throws Exception {
try {
return doInvoke(this.invocation);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* 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.
@@ -16,6 +16,7 @@
package org.springframework.integration.gateway;
import org.springframework.integration.core.MessagingTemplate;
import org.springframework.integration.endpoint.AbstractEndpoint;
import org.springframework.integration.endpoint.EventDrivenConsumer;
import org.springframework.integration.endpoint.PollingConsumer;
@@ -31,7 +32,6 @@ import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessagingException;
import org.springframework.messaging.PollableChannel;
import org.springframework.messaging.SubscribableChannel;
import org.springframework.integration.core.MessagingTemplate;
import org.springframework.messaging.support.ErrorMessage;
import org.springframework.util.Assert;
@@ -105,6 +105,8 @@ public abstract class MessagingGatewaySupport extends AbstractEndpoint implement
* Set the error channel. If no error channel is provided, this gateway will
* propagate Exceptions to the caller. To completely suppress Exceptions, provide
* a reference to the "nullChannel" here.
*
* @param errorChannel The error channel.
*/
public void setErrorChannel(MessageChannel errorChannel) {
this.errorChannel = errorChannel;
@@ -134,6 +136,8 @@ public abstract class MessagingGatewaySupport extends AbstractEndpoint implement
/**
* Provide an {@link InboundMessageMapper} for creating request Messages
* from any object passed in a send or sendAndReceive operation.
*
* @param requestMapper The request mapper.
*/
public void setRequestMapper(InboundMessageMapper<?> requestMapper) {
requestMapper = (requestMapper != null) ? requestMapper : new DefaultRequestMapper();
@@ -144,6 +148,8 @@ public abstract class MessagingGatewaySupport extends AbstractEndpoint implement
/**
* Provide an {@link OutboundMessageMapper} for mapping to objects from
* any reply Messages received in receive or sendAndReceive operations.
*
* @param replyMapper The reply mapper.
*/
public void setReplyMapper(OutboundMessageMapper<?> replyMapper) {
this.messageConverter.setOutboundMessageMapper(replyMapper);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* 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.
@@ -23,6 +23,7 @@ import org.aopalliance.aop.Advice;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.beans.factory.BeanClassLoaderAware;
import org.springframework.integration.core.MessageProducer;
import org.springframework.integration.core.MessagingTemplate;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
@@ -30,7 +31,6 @@ import org.springframework.messaging.MessageDeliveryException;
import org.springframework.messaging.MessageHeaders;
import org.springframework.messaging.core.DestinationResolutionException;
import org.springframework.messaging.core.DestinationResolver;
import org.springframework.integration.core.MessagingTemplate;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.util.CollectionUtils;
@@ -65,19 +65,24 @@ public abstract class AbstractReplyProducingMessageHandler extends AbstractMessa
}
@Override
public void setOutputChannel(MessageChannel outputChannel) {
this.outputChannel = outputChannel;
}
/**
* Set the timeout for sending reply Messages.
*
* @param sendTimeout The send timeout.
*/
public void setSendTimeout(long sendTimeout) {
this.messagingTemplate.setSendTimeout(sendTimeout);
}
/**
* Set the DestinationResolver<MessageChannel> to be used when there is no default output channel.
* Set the DestinationResolver&lt;MessageChannel&gt; to be used when there is no default output channel.
*
* @param channelResolver The channel resolver.
*/
public void setChannelResolver(DestinationResolver<MessageChannel> channelResolver) {
Assert.notNull(channelResolver, "'channelResolver' must not be null");
@@ -87,6 +92,8 @@ public abstract class AbstractReplyProducingMessageHandler extends AbstractMessa
/**
* Flag whether a reply is required. If true an incoming message MUST result in a reply message being sent.
* If false an incoming message MAY result in a reply message being sent. Default is false.
*
* @param requiresReply true if a reply is required.
*/
public void setRequiresReply(boolean requiresReply) {
this.requiresReply = requiresReply;
@@ -94,6 +101,8 @@ public abstract class AbstractReplyProducingMessageHandler extends AbstractMessa
/**
* Provides access to the {@link MessagingTemplate} for subclasses.
*
* @return The messaging template.
*/
protected MessagingTemplate getMessagingTemplate() {
return this.messagingTemplate;
@@ -109,6 +118,7 @@ public abstract class AbstractReplyProducingMessageHandler extends AbstractMessa
return this.adviceChain != null && this.adviceChain.size() > 0;
}
@Override
public void setBeanClassLoader(ClassLoader beanClassLoader) {
this.beanClassLoader = beanClassLoader;
}
@@ -201,6 +211,7 @@ public abstract class AbstractReplyProducingMessageHandler extends AbstractMessa
* Send a reply Message. The 'replyChannelHeaderValue' will be considered only if this handler's
* 'outputChannel' is <code>null</code>. In that case, the header value must not also be
* <code>null</code>, and it must be an instance of either String or {@link MessageChannel}.
*
* @param replyMessage the reply Message to send
* @param replyChannelHeaderValue the 'replyChannel' header value from the original request
*/
@@ -222,6 +233,9 @@ public abstract class AbstractReplyProducingMessageHandler extends AbstractMessa
/**
* Send the message to the given channel. The channel must be a String or
* {@link MessageChannel} instance, never <code>null</code>.
*
* @param message The message.
* @param channel The channel to which to send the message.
*/
private void sendMessage(final Message<?> message, final Object channel) {
if (channel instanceof MessageChannel) {
@@ -247,6 +261,8 @@ public abstract class AbstractReplyProducingMessageHandler extends AbstractMessa
/**
* Subclasses may override this. True by default.
*
* @return true if the request headers should be copied.
*/
protected boolean shouldCopyRequestHeaders() {
return true;
@@ -257,6 +273,9 @@ public abstract class AbstractReplyProducingMessageHandler extends AbstractMessa
* value may be a Message, a MessageBuilder, or any plain Object. The base class
* will handle the final creation of a reply Message from any of those starting
* points. If the return value is null, the Message flow will end here.
*
* @param requestMessage The request message.
* @return The result of handling the message, or {@code null}.
*/
protected abstract Object handleRequestMessage(Message<?> requestMessage);
@@ -265,11 +284,13 @@ public abstract class AbstractReplyProducingMessageHandler extends AbstractMessa
Object handleRequestMessage(Message<?> requestMessage);
@Override
String toString();
}
private class AdvisedRequestHandler implements RequestHandler {
@Override
public Object handleRequestMessage(Message<?> requestMessage) {
return AbstractReplyProducingMessageHandler.this.handleRequestMessage(requestMessage);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* 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.
@@ -33,6 +33,8 @@ public abstract class AbstractReplyProducingPostProcessingMessageHandler
* the scope of any configured advice classes. If false, the
* post processing will occur after the advice chain returns. Default true.
* This is only applicable if there is in fact an advice chain present.
*
* @param postProcessWithinAdvice true if the post processing should be performed within the advice.
*/
public void setPostProcessWithinAdvice(boolean postProcessWithinAdvice) {
this.postProcessWithinAdvice = postProcessWithinAdvice;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* 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.
@@ -32,7 +32,6 @@ 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.messaging.MessageHandlingException;
import org.springframework.integration.context.IntegrationObjectSupport;
import org.springframework.integration.expression.ExpressionUtils;
import org.springframework.integration.store.MessageGroup;
@@ -42,8 +41,9 @@ import org.springframework.integration.store.SimpleMessageStore;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.jmx.export.annotation.ManagedResource;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessagingException;
import org.springframework.messaging.MessageHandler;
import org.springframework.messaging.MessageHandlingException;
import org.springframework.messaging.MessagingException;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.util.Assert;
@@ -110,6 +110,8 @@ public class DelayHandler extends AbstractReplyProducingMessageHandler implement
* to store delayed Messages in the {@link MessageGroupStore}. The sending of Messages after
* the delay will be handled by registered in the ApplicationContext default {@link ThreadPoolTaskScheduler}.
*
* @param messageGroupId The message group identifier.
*
* @see IntegrationObjectSupport#getTaskScheduler()
*/
public DelayHandler(String messageGroupId) {
@@ -120,6 +122,9 @@ public class DelayHandler extends AbstractReplyProducingMessageHandler implement
/**
* Create a DelayHandler with the given default delay. The sending of Messages
* after the delay will be handled by the provided {@link TaskScheduler}.
*
* @param messageGroupId The message group identifier.
* @param taskScheduler A task scheduler.
*/
public DelayHandler(String messageGroupId, TaskScheduler taskScheduler) {
this(messageGroupId);
@@ -130,7 +135,9 @@ public class DelayHandler extends AbstractReplyProducingMessageHandler implement
* Set the default delay in milliseconds. If no {@code delayExpression} property
* has been provided, the default delay will be applied to all Messages. If
* a delay should <em>only</em> be applied to Messages with evaluation result from
* @code delayExpression}, then set this value to 0.
* {@code delayExpression}, then set this value to 0.
*
* @param defaultDelay The default delay in milliseconds.
*/
public void setDefaultDelay(long defaultDelay) {
this.defaultDelay = defaultDelay;
@@ -141,6 +148,8 @@ public class DelayHandler extends AbstractReplyProducingMessageHandler implement
* (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) {
@@ -151,6 +160,8 @@ public class DelayHandler extends AbstractReplyProducingMessageHandler implement
* 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
* result of the expression evaluation will take precedence over this handler's default delay.
*
* @param delayExpression The delay expression.
*/
public void setDelayExpression(Expression delayExpression) {
this.delayExpression = delayExpression;
@@ -164,6 +175,8 @@ public class DelayHandler extends AbstractReplyProducingMessageHandler implement
* {@code Exception} will be thrown to the caller without falling back to the to the {@link #defaultDelay}.
* Default is {@code true}.
*
* @param ignoreExpressionFailures true if expression evaluation failures should be ignored.
*
* @see #determineDelayForMessage
*/
public void setIgnoreExpressionFailures(boolean ignoreExpressionFailures) {
@@ -173,6 +186,8 @@ public class DelayHandler extends AbstractReplyProducingMessageHandler implement
/**
* Specify the {@link MessageGroupStore} that should be used to store Messages
* while awaiting the delay.
*
* @param messageStore The message store.
*/
public void setMessageStore(MessageGroupStore messageStore) {
Assert.state(messageStore != null, "MessageStore must not be null");
@@ -183,6 +198,8 @@ public class DelayHandler extends AbstractReplyProducingMessageHandler implement
* Specify the {@code List<Advice>} to advise {@link DelayHandler.ReleaseMessageHandler} proxy.
* Usually used to add transactions to delayed messages retrieved from a transactional message store.
*
* @param delayedAdviceChain The advice chain.
*
* @see #createReleaseMessageTask
*/
public void setDelayedAdviceChain(List<Advice> delayedAdviceChain) {
@@ -310,6 +327,7 @@ public class DelayHandler extends AbstractReplyProducingMessageHandler implement
final Message<?> messageToSchedule = delayedMessage;
this.getTaskScheduler().schedule(new Runnable() {
@Override
public void run() {
releaseMessage(messageToSchedule);
}
@@ -334,6 +352,7 @@ public class DelayHandler extends AbstractReplyProducingMessageHandler implement
}
}
@Override
public int getDelayedMessageCount() {
return this.messageStore.messageGroupSize(this.messageGroupId);
}
@@ -345,10 +364,12 @@ public class DelayHandler extends AbstractReplyProducingMessageHandler implement
* and schedules task about 'delay' logic.
* This behavior is dictated by the avoidance of invocation thread overload.
*/
@Override
public void reschedulePersistedMessages() {
MessageGroup messageGroup = this.messageStore.getMessageGroup(this.messageGroupId);
for (final Message<?> message : messageGroup.getMessages()) {
this.getTaskScheduler().schedule(new Runnable() {
@Override
public void run() {
long delay = determineDelayForMessage(message);
if (delay > 0) {
@@ -374,6 +395,7 @@ public class DelayHandler extends AbstractReplyProducingMessageHandler implement
*
* @see #reschedulePersistedMessages
*/
@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
if (!this.initialized.getAndSet(true)) {
this.reschedulePersistedMessages();
@@ -390,6 +412,7 @@ public class DelayHandler extends AbstractReplyProducingMessageHandler implement
*/
private class ReleaseMessageHandler implements MessageHandler {
@Override
public void handleMessage(Message<?> message) throws MessagingException {
DelayHandler.this.doReleaseMessage(message);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* 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.
@@ -24,7 +24,7 @@ import org.springframework.util.Assert;
/**
* A {@link MessageProcessor} implementation that evaluates a SpEL expression
* with the Message itself as the root object within the evaluation context.
*
*
* @author Mark Fisher
* @since 2.0
*/
@@ -37,6 +37,8 @@ public class ExpressionEvaluatingMessageProcessor<T> extends AbstractMessageProc
/**
* Create an {@link ExpressionEvaluatingMessageProcessor} for the given expression.
*
* @param expression The expression.
*/
public ExpressionEvaluatingMessageProcessor(Expression expression) {
this(expression, null);
@@ -46,6 +48,9 @@ public class ExpressionEvaluatingMessageProcessor<T> extends AbstractMessageProc
/**
* Create an {@link ExpressionEvaluatingMessageProcessor} for the given expression
* and expected type for its evaluation result.
*
* @param expression The expression.
* @param expectedType The expected type.
*/
public ExpressionEvaluatingMessageProcessor(Expression expression, Class<T> expectedType) {
Assert.notNull(expression, "The expression must not be null");
@@ -62,7 +67,11 @@ public class ExpressionEvaluatingMessageProcessor<T> extends AbstractMessageProc
/**
* Processes the Message by evaluating the expression with that Message as the
* root object. The expression evaluation result Object will be returned.
*
* @param message The message.
* @return The result of processing the message.
*/
@Override
public T processMessage(Message<?> message) {
return this.evaluateExpression(this.expression, message, this.expectedType);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* 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
@@ -63,6 +63,8 @@ public class LoggingHandler extends AbstractMessageHandler {
* Create a LoggingHandler with the given log level (case-insensitive).
* <p>
* The valid levels are: FATAL, ERROR, WARN, INFO, DEBUG, or TRACE
* </p>
* @param level The level.
*/
public LoggingHandler(String level) {
Assert.notNull(level, "'level' cannot be null");
@@ -93,6 +95,7 @@ public class LoggingHandler extends AbstractMessageHandler {
/**
* Set the logging {@link Level}.
*
* @param level the level.
*/
public void setLevel(Level level) {
@@ -108,6 +111,8 @@ public class LoggingHandler extends AbstractMessageHandler {
/**
* Specify whether to log the full Message. Otherwise, only the payload will be logged. This value is
* <code>false</code> by default.
*
* @param shouldLogFullMessage true if the complete message should be logged.
*/
public void setShouldLogFullMessage(boolean shouldLogFullMessage) {
Assert.isTrue(!(this.expressionSet), "Cannot set both 'expression' AND 'shouldLogFullMessage' properties");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* 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.
@@ -23,13 +23,13 @@ import java.util.concurrent.locks.ReentrantLock;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.Lifecycle;
import org.springframework.messaging.MessageHandlingException;
import org.springframework.integration.core.MessageProducer;
import org.springframework.integration.filter.MessageFilter;
import org.springframework.integration.support.channel.BeanFactoryChannelResolver;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessageHandler;
import org.springframework.messaging.MessageHandlingException;
import org.springframework.messaging.core.DestinationResolver;
import org.springframework.util.Assert;
@@ -50,7 +50,6 @@ import org.springframework.util.Assert;
* <p>
* This component can be used from the namespace to improve the readability of
* the configuration by removing channels that can be created implicitly.
* <p>
*
* <pre class="code">
* {@code
@@ -95,6 +94,7 @@ public class MessageHandlerChain extends AbstractMessageHandler implements Messa
this.handlers = handlers;
}
@Override
public void setOutputChannel(MessageChannel outputChannel) {
this.outputChannel = outputChannel;
}
@@ -141,9 +141,11 @@ public class MessageHandlerChain extends AbstractMessageHandler implements Messa
"the last one in the chain must implement the MessageProducer interface.");
final MessageHandler nextHandler = handlers.get(i + 1);
final MessageChannel nextChannel = new MessageChannel() {
@Override
public boolean send(Message<?> message, long timeout) {
return this.send(message);
}
@Override
public boolean send(Message<?> message) {
nextHandler.handleMessage(message);
return true;
@@ -174,6 +176,7 @@ public class MessageHandlerChain extends AbstractMessageHandler implements Messa
* SmartLifecycle implementation (delegates to the {@link #handlers})
*/
@Override
public final boolean isRunning() {
this.lifecycleLock.lock();
try {
@@ -184,6 +187,7 @@ public class MessageHandlerChain extends AbstractMessageHandler implements Messa
}
}
@Override
public final void start() {
this.lifecycleLock.lock();
try {
@@ -200,6 +204,7 @@ public class MessageHandlerChain extends AbstractMessageHandler implements Messa
}
}
@Override
public final void stop() {
this.lifecycleLock.lock();
try {
@@ -245,10 +250,12 @@ public class MessageHandlerChain extends AbstractMessageHandler implements Messa
private class ReplyForwardingMessageChannel implements MessageChannel {
@Override
public boolean send(Message<?> message) {
return this.send(message, -1);
}
@Override
public boolean send(Message<?> message, long timeout) {
timeout = (MessageHandlerChain.this.sendTimeout != null)
? MessageHandlerChain.this.sendTimeout : timeout;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* 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.
@@ -35,7 +35,7 @@ import org.springframework.messaging.Message;
* This strategy and its various implementations are considered part of the
* internal "support" API, intended for use by Spring Integration's various
* message-handling components. As such, it is subject to change.
*
*
* @author Mark Fisher
* @since 2.0
*/
@@ -43,6 +43,9 @@ public interface MessageProcessor<T> {
/**
* Process the Message and return a value (or null).
*
* @param message The message to process.
* @return The result.
*/
T processMessage(Message<?> message);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* 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.
@@ -23,10 +23,10 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.aop.ProxyMethodInvocation;
import org.springframework.messaging.Message;
import org.springframework.integration.context.IntegrationObjectSupport;
import org.springframework.messaging.MessageHandler;
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHandler;
/**
* Base class for {@link MessageHandler} advice classes. Subclasses should provide
@@ -43,6 +43,7 @@ public abstract class AbstractRequestHandlerAdvice extends IntegrationObjectSupp
protected final Log logger = LogFactory.getLog(this.getClass());
@Override
public final Object invoke(final MethodInvocation invocation) throws Throwable {
Method method = invocation.getMethod();
@@ -67,6 +68,7 @@ public abstract class AbstractRequestHandlerAdvice extends IntegrationObjectSupp
try {
return doInvoke(new ExecutionCallback() {
@Override
public Object execute() throws Exception {
try {
return invocation.proceed();
@@ -79,6 +81,7 @@ public abstract class AbstractRequestHandlerAdvice extends IntegrationObjectSupp
}
}
@Override
public Object cloneAndExecute() throws Exception {
try {
/*
@@ -118,7 +121,7 @@ public abstract class AbstractRequestHandlerAdvice extends IntegrationObjectSupp
* @param target The target handler.
* @param message The message that will be sent to the handler.
* @return the result after invoking the {@link MessageHandler}.
* @throws Exception
* @throws Exception Any Exception.
*/
protected abstract Object doInvoke(ExecutionCallback callback, Object target, Message<?> message) throws Exception;
@@ -160,6 +163,9 @@ public abstract class AbstractRequestHandlerAdvice extends IntegrationObjectSupp
/**
* Call this for a normal invocation.proceed().
*
* @return The result of the execution.
* @throws Exception Any Exception.
*/
Object execute() throws Exception;
@@ -167,6 +173,9 @@ public abstract class AbstractRequestHandlerAdvice extends IntegrationObjectSupp
* Call this when it is necessary to clone the invocation before
* calling proceed() - such as when the invocation might be called
* multiple times - for example in a retry advice.
*
* @return The result of the execution.
* @throws Exception Any Exception.
*/
Object cloneAndExecute() throws Exception;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* 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.
@@ -83,7 +83,7 @@ public class ExpressionEvaluatingRequestHandlerAdvice extends AbstractRequestHan
/**
* If true, any exception will be caught and null returned.
* Default false.
* @param trapException
* @param trapException true to trap Exceptions.
*/
public void setTrapException(boolean trapException) {
this.trapException = trapException;
@@ -92,7 +92,8 @@ public class ExpressionEvaluatingRequestHandlerAdvice extends AbstractRequestHan
/**
* If true, the result of evaluating the onFailureExpression will
* be returned as the result of AbstractReplyProducingMessageHandler.handleRequestMessage(Message).
* @param returnFailureExpressionResult
*
* @param returnFailureExpressionResult true to return the result of the evaluation.
*/
public void setReturnFailureExpressionResult(boolean returnFailureExpressionResult) {
this.returnFailureExpressionResult = returnFailureExpressionResult;
@@ -102,7 +103,7 @@ public class ExpressionEvaluatingRequestHandlerAdvice extends AbstractRequestHan
* If true and an onSuccess expression evaluation fails with an exception, the exception will be thrown to the
* caller. If false, the exception is caught. Default false. Ignored for onFailure expression evaluation - the
* original exception will be propagated (unless trapException is true).
* @param propagateOnSuccessEvaluationFailures
* @param propagateOnSuccessEvaluationFailures The propagateOnSuccessEvaluationFailures to set.
*/
public void setPropagateEvaluationFailures(boolean propagateOnSuccessEvaluationFailures) {
this.propagateOnSuccessEvaluationFailures = propagateOnSuccessEvaluationFailures;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* 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.
@@ -56,6 +56,11 @@ public class JsonToObjectTransformer extends AbstractTransformer implements Bean
/**
* Backward compatibility - allows existing configurations using Jackson 1.x to inject
* an ObjectMapper directly.
*
* @param targetClass The target class.
* @param objectMapper The object mapper.
* @throws ClassNotFoundException When the target class is not found.
*
* @deprecated in favor of {@link #JsonToObjectTransformer(Class, JsonObjectMapper)}
*/
@Deprecated

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* 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.
@@ -53,6 +53,9 @@ public class ObjectToJsonTransformer extends AbstractTransformer {
/**
* Backward compatibility - allows existing configurations using Jackson 1.x to inject
* an ObjectMapper directly.
*
* @param objectMapper The object mapper.
*
* @deprecated in favor of {@link #ObjectToJsonTransformer(JsonObjectMapper)}
*/
@Deprecated
@@ -81,7 +84,7 @@ public class ObjectToJsonTransformer extends AbstractTransformer {
/**
* Sets the content-type header value
*
* @param contentType
* @param contentType The content type.
*/
public void setContentType(String contentType) {
// only null assertion is needed since "" is a valid value

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* 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.
@@ -78,6 +78,8 @@ public abstract class AbstractHeaderMapper<T> implements RequestReplyHeaderMappe
* <p>
* This will match the header name directly or, for non-standard headers, it will match
* the header name prefixed with the value, if specified, by {@link #setUserDefinedHeaderPrefix(String)}.
*
* @param requestHeaderNames The request header names.
*/
public void setRequestHeaderNames(String[] requestHeaderNames) {
Assert.notNull(requestHeaderNames, "'requestHeaderNames' must not be null");
@@ -90,6 +92,8 @@ public abstract class AbstractHeaderMapper<T> implements RequestReplyHeaderMappe
* The values can also contain simple wildcard patterns (e.g. "foo*" or "*foo") to be matched.
* <p>
* Any non-standard headers will be prefixed with the value specified by {@link #setUserDefinedHeaderPrefix(String)}.
*
* @param replyHeaderNames The reply header names.
*/
public void setReplyHeaderNames(String[] replyHeaderNames) {
Assert.notNull(replyHeaderNames, "'replyHeaderNames' must not be null");
@@ -103,6 +107,8 @@ public abstract class AbstractHeaderMapper<T> implements RequestReplyHeaderMappe
* This does not affect the standard properties for the particular protocol, such as
* contentType for AMQP, etc. The header names used for mapping such properties are
* defined in a corresponding Headers class as constants (e.g. AmqpHeaders).
*
* @param userDefinedHeaderPrefix The user defined header prefix.
*/
public void setUserDefinedHeaderPrefix(String userDefinedHeaderPrefix) {
this.userDefinedHeaderPrefix = (userDefinedHeaderPrefix != null) ? userDefinedHeaderPrefix : "";
@@ -111,28 +117,44 @@ public abstract class AbstractHeaderMapper<T> implements RequestReplyHeaderMappe
/**
* Maps headers from a Spring Integration MessageHeaders instance to the target instance
* matching on the set of REQUEST headers (if different).
*
* @param headers The headers.
* @param target The target.
*/
@Override
public void fromHeadersToRequest(MessageHeaders headers, T target) {
this.fromHeaders(headers, target, this.requestHeaderNames);
}
/**
* Maps headers from a Spring Integration MessageHeaders instance to the target instance
* matching on the set of REPLY headers (if different).
*
* @param headers The headers.
* @param target The target.
*/
@Override
public void fromHeadersToReply(MessageHeaders headers, T target) {
this.fromHeaders(headers, target, this.replyHeaderNames);
}
/**
* Maps headers/properties of the target object to Map of MessageHeaders
* matching on the set of REQUEST headers
*
* @param source The source.
* @return The headers.
*/
@Override
public Map<String, Object> toHeadersFromRequest(T source) {
return this.toHeaders(source, this.requestHeaderNames);
}
/**
* Maps headers/properties of the target object to Map of MessageHeaders
* matching on the set of REPLY headers
*
* @param source The source.
* @return The headers.
*/
@Override
public Map<String, Object> toHeadersFromReply(T source) {
return this.toHeaders(source, this.replyHeaderNames);
}
@@ -285,21 +307,21 @@ public abstract class AbstractHeaderMapper<T> implements RequestReplyHeaderMappe
}
/**
* Returns the list of standard REQUEST headers. Implementation provided by a subclass
* @return The list of standard REQUEST headers. Implementation provided by a subclass
*/
protected List<String> getStandardReplyHeaderNames(){
return Collections.emptyList();
}
/**
* Returns the PREFIX used by standard headers (if any)
* @return The PREFIX used by standard headers (if any)
*/
protected List<String> getStandardRequestHeaderNames(){
return Collections.emptyList();
}
/**
* Returns the list of standard REPLY headers. Implementation provided by a subclass
* @return The list of standard REPLY headers. Implementation provided by a subclass
*/
protected abstract String getStandardHeaderPrefix();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* 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.
@@ -33,18 +33,25 @@ public interface MetadataStore {
/**
* Writes a key value pair to this MetadataStore.
*
* @param key The key.
* @param value The value.
*/
void put(String key, String value);
/**
* Reads a value for the given key from this MetadataStore.
*
* @param key The key.
* @return The value.
*/
@ManagedAttribute
String get(String key);
/**
* Remove a value for the given key from this MetadataStore.
* return the previous value associated with <tt>key</tt>, or
* @param key The key.
* @return The previous value associated with <tt>key</tt>, or
* <tt>null</tt> if there was no mapping for <tt>key</tt>.
*/
@ManagedAttribute

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* 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.
@@ -61,6 +61,8 @@ public abstract class AbstractMappingMessageRouter extends AbstractMessageRouter
/**
* Provide mappings from channel keys to channel names.
* Channel names will be resolved by the {@link DestinationResolver}.
*
* @param channelMappings The channel mappings.
*/
public void setChannelMappings(Map<String, String> channelMappings) {
Map<String, String> oldChannelMappings = this.channelMappings;
@@ -78,6 +80,8 @@ public abstract class AbstractMappingMessageRouter extends AbstractMessageRouter
* The default is a BeanFactoryChannelResolver.
* This is considered an infrastructural configuration option and
* as of 2.1 has been deprecated as a configuration-driven attribute.
*
* @param channelResolver The channel resolver.
*/
public void setChannelResolver(DestinationResolver<MessageChannel> channelResolver) {
Assert.notNull(channelResolver, "'channelResolver' must not be null");
@@ -86,6 +90,8 @@ public abstract class AbstractMappingMessageRouter extends AbstractMessageRouter
/**
* Specify a prefix to be added to each channel name prior to resolution.
*
* @param prefix The prefix.
*/
public void setPrefix(String prefix) {
this.prefix = prefix;
@@ -93,6 +99,8 @@ public abstract class AbstractMappingMessageRouter extends AbstractMessageRouter
/**
* Specify a suffix to be added to each channel name prior to resolution.
*
* @param suffix The suffix.
*/
public void setSuffix(String suffix) {
this.suffix = suffix;
@@ -101,6 +109,8 @@ public abstract class AbstractMappingMessageRouter extends AbstractMessageRouter
/**
* Specify whether this router should ignore any failure to resolve a channel name to
* an actual MessageChannel instance when delegating to the ChannelResolver strategy.
*
* @param resolutionRequired true if resolution is required.
*/
public void setResolutionRequired(boolean resolutionRequired) {
this.resolutionRequired = resolutionRequired;
@@ -109,6 +119,8 @@ public abstract class AbstractMappingMessageRouter extends AbstractMessageRouter
/**
* Returns an unmodifiable version of the channel mappings.
* This is intended for use by subclasses only.
*
* @return The channel mappings.
*/
protected Map<String, String> getChannelMappings() {
return Collections.unmodifiableMap(this.channelMappings);
@@ -116,7 +128,11 @@ public abstract class AbstractMappingMessageRouter extends AbstractMessageRouter
/**
* Add a channel mapping from the provided key to channel name.
*
* @param key The key.
* @param channelName The channel name.
*/
@Override
@ManagedOperation
public void setChannelMapping(String key, String channelName) {
this.channelMappings.put(key, channelName);
@@ -124,7 +140,10 @@ public abstract class AbstractMappingMessageRouter extends AbstractMessageRouter
/**
* Remove a channel mapping for the given key if present.
*
* @param key The key.
*/
@Override
@ManagedOperation
public void removeChannelMapping(String key) {
this.channelMappings.remove(key);
@@ -142,6 +161,9 @@ public abstract class AbstractMappingMessageRouter extends AbstractMessageRouter
* Subclasses must implement this method to return the channel keys.
* A "key" might be present in this router's "channelMappings", or it
* could be the channel's name or even the Message Channel instance itself.
*
* @param message The message.
* @return The channel keys.
*/
protected abstract List<Object> getChannelKeys(Message<?> message);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* 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.
@@ -21,6 +21,7 @@ import java.util.Collection;
import org.springframework.core.convert.ConversionService;
import org.springframework.core.convert.support.DefaultConversionService;
import org.springframework.integration.channel.NullChannel;
import org.springframework.integration.core.MessagingTemplate;
import org.springframework.integration.handler.AbstractMessageHandler;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.jmx.export.annotation.ManagedResource;
@@ -28,7 +29,6 @@ import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessageDeliveryException;
import org.springframework.messaging.MessagingException;
import org.springframework.integration.core.MessagingTemplate;
/**
* Base class for all Message Routers.
@@ -58,6 +58,8 @@ public abstract class AbstractMessageRouter extends AbstractMessageHandler {
* {@link MessageDeliveryException}.
*
* If messages shall be ignored (dropped) instead, please provide a {@link NullChannel}.
*
* @param defaultOutputChannel The default output channel.
*/
public void setDefaultOutputChannel(MessageChannel defaultOutputChannel) {
this.defaultOutputChannel = defaultOutputChannel;
@@ -66,6 +68,8 @@ public abstract class AbstractMessageRouter extends AbstractMessageHandler {
/**
* Set the timeout for sending a message to the resolved channel. By default, there is no timeout, meaning the send
* will block indefinitely.
*
* @param timeout The timeout.
*/
public void setTimeout(long timeout) {
this.messagingTemplate.setSendTimeout(timeout);
@@ -75,6 +79,8 @@ public abstract class AbstractMessageRouter extends AbstractMessageHandler {
* Specify whether send failures for one or more of the recipients should be ignored. By default this is
* <code>false</code> meaning that an Exception will be thrown whenever a send fails. To override this and suppress
* Exceptions, set the value to <code>true</code>.
*
* @param ignoreSendFailures true to ignore send failures.
*/
public void setIgnoreSendFailures(boolean ignoreSendFailures) {
this.ignoreSendFailures = ignoreSendFailures;
@@ -85,6 +91,8 @@ public abstract class AbstractMessageRouter extends AbstractMessageHandler {
* channels. By default, this value is <code>false</code> meaning that sequence headers will <em>not</em> be
* applied. If planning to use an Aggregator downstream with the default correlation and completion strategies, you
* should set this flag to <code>true</code>.
*
* @param applySequence true to apply sequence information.
*/
public void setApplySequence(boolean applySequence) {
this.applySequence = applySequence;
@@ -96,7 +104,9 @@ public abstract class AbstractMessageRouter extends AbstractMessageHandler {
}
/**
* Provides {@link MessagingTemplate} access for subclasses.
* Provides {@link MessagingTemplate} access for subclasses
*
* @return The messaging template.
*/
protected MessagingTemplate getMessagingTemplate() {
return this.messagingTemplate;
@@ -116,6 +126,9 @@ public abstract class AbstractMessageRouter extends AbstractMessageHandler {
/**
* Subclasses must implement this method to return a Collection of zero or more
* MessageChannels to which the given Message should be routed.
*
* @param message The message.
* @return The collection of message channels.
*/
protected abstract Collection<MessageChannel> determineTargetChannels(Message<?> message);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* 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.
@@ -36,6 +36,8 @@ public class HeaderValueRouter extends AbstractMappingMessageRouter {
/**
* Create a router that uses the provided header name to lookup a channel.
*
* @param headerName The header name.
*/
public HeaderValueRouter(String headerName) {
Assert.notNull(headerName, "'headerName' must not be null");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* 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.
@@ -26,12 +26,17 @@ public interface MappingMessageRouterManagement {
/**
* Add a channel mapping from the provided key to channel name.
*
* @param key The key.
* @param channelName The channel name.
*/
@ManagedOperation
public abstract void setChannelMapping(String key, String channelName);
/**
* Remove a channel mapping for the given key if present.
*
* @param key The key.
*/
@ManagedOperation
public abstract void removeChannelMapping(String key);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* 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.
@@ -21,9 +21,9 @@ import java.util.Collection;
import java.util.List;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.integration.core.MessageSelector;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.integration.core.MessageSelector;
import org.springframework.util.Assert;
/**
@@ -64,6 +64,8 @@ public class RecipientListRouter extends AbstractMessageRouter implements Initia
* Set the channels for this router. Either call this method or
* {@link #setRecipients(List)} but not both. If MessageSelectors should be
* considered, then use {@link #setRecipients(List)}.
*
* @param channels The channels.
*/
public void setChannels(List<MessageChannel> channels) {
Assert.notEmpty(channels, "channels must not be empty");
@@ -76,6 +78,8 @@ public class RecipientListRouter extends AbstractMessageRouter implements Initia
/**
* Set the recipients for this router.
*
* @param recipients The recipients.
*/
public void setRecipients(List<Recipient> recipients) {
Assert.notEmpty(recipients, "recipients must not be empty");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* 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.
@@ -20,6 +20,7 @@ import java.util.List;
import java.util.concurrent.Executor;
import org.aopalliance.aop.Advice;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.integration.transaction.TransactionSynchronizationFactory;
import org.springframework.scheduling.Trigger;
@@ -88,6 +89,8 @@ public class PollerMetadata {
*
* <p>The default is unbounded.
*
* @param maxMessagesPerPoll The maxMessagesPerPoll to set.
*
* @see #MAX_MESSAGES_UNBOUNDED
*/
public void setMaxMessagesPerPoll(long maxMessagesPerPoll) {
@@ -134,6 +137,7 @@ public class PollerMetadata {
/**
* Return the default {@link PollerMetadata} bean if available.
* @param beanFactory BeanFactory for lookup, must not be null.
* @return The poller metadata.
*/
public static PollerMetadata getDefaultPollerMetadata(BeanFactory beanFactory) {
Assert.notNull(beanFactory, "BeanFactory must not be null");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* 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.
@@ -19,8 +19,8 @@ package org.springframework.integration.selector;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import org.springframework.messaging.Message;
import org.springframework.integration.core.MessageSelector;
import org.springframework.messaging.Message;
import org.springframework.util.Assert;
/**
@@ -28,7 +28,7 @@ import org.springframework.util.Assert;
* chain of selectors. Whether the Message is {@link #accept(Message) accepted}
* is based upon the tallied results of the individual selectors' responses in
* accordance with this chain's {@link VotingStrategy}.
*
*
* @author Mark Fisher
*/
public class MessageSelectorChain implements MessageSelector {
@@ -44,6 +44,8 @@ public class MessageSelectorChain implements MessageSelector {
/**
* Specify the voting strategy for this selector chain.
* <p>The default is {@link VotingStrategy#ALL}.
*
* @param votingStrategy The voting strategy.
*/
public void setVotingStrategy(VotingStrategy votingStrategy) {
Assert.notNull(votingStrategy, "votingStrategy must not be null");
@@ -52,6 +54,8 @@ public class MessageSelectorChain implements MessageSelector {
/**
* Add a selector to the end of the chain.
*
* @param selector The message selector.
*/
public void add(MessageSelector selector) {
this.selectors.add(selector);
@@ -59,6 +63,9 @@ public class MessageSelectorChain implements MessageSelector {
/**
* Add a selector to the chain at the specified index.
*
* @param index The index.
* @param selector The message selector.
*/
public void add(int index, MessageSelector selector) {
this.selectors.add(index, selector);
@@ -66,6 +73,8 @@ public class MessageSelectorChain implements MessageSelector {
/**
* Initialize the selector chain. Removes any existing selectors.
*
* @param selectors The message selectors.
*/
public void setSelectors(List<MessageSelector> selectors) {
Assert.notEmpty(selectors, "selectors must not be empty");
@@ -81,6 +90,7 @@ public class MessageSelectorChain implements MessageSelector {
* the individual selectors' responses in accordance with this chain's
* {@link VotingStrategy}.
*/
@Override
public final boolean accept(Message<?> message) {
int count = 0;
int accepted = 0;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* 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.
@@ -19,24 +19,26 @@ package org.springframework.integration.selector;
import java.util.ArrayList;
import java.util.List;
import org.springframework.messaging.Message;
import org.springframework.integration.core.MessageSelector;
import org.springframework.messaging.Message;
import org.springframework.util.Assert;
/**
* A {@link MessageSelector} implementation that checks the type of the
* {@link Message} payload. The payload type must be assignable to at least one
* of the selector's accepted types.
*
*
* @author Mark Fisher
*/
public class PayloadTypeSelector implements MessageSelector {
private List<Class<?>> acceptedTypes = new ArrayList<Class<?>>();
private final List<Class<?>> acceptedTypes = new ArrayList<Class<?>>();
/**
* Create a selector for the provided types. At least one is required.
*
* @param types The types.
*/
public PayloadTypeSelector(Class<?>... types) {
Assert.notEmpty(types, "at least one type is required");
@@ -46,6 +48,7 @@ public class PayloadTypeSelector implements MessageSelector {
}
@Override
public boolean accept(Message<?> message) {
Assert.notNull(message, "'message' must not be null");
Object payload = message.getPayload();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* 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.
@@ -20,16 +20,16 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHeaders;
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHeaders;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
/**
* Base class for Message-splitting handlers.
*
*
* @author Mark Fisher
* @author Dave Syer
*/
@@ -39,6 +39,8 @@ public abstract class AbstractMessageSplitter extends AbstractReplyProducingMess
/**
* Set the applySequence flag to the specified value. Defaults to true.
*
* @param applySequence true to apply sequence information.
*/
public void setApplySequence(boolean applySequence) {
this.applySequence = applySequence;
@@ -105,6 +107,9 @@ public abstract class AbstractMessageSplitter extends AbstractReplyProducingMess
* Array. The individual elements may be Messages, but it is not necessary. If the elements are not Messages, each
* will be provided as the payload of a Message. It is also acceptable to return a single Object or Message. In that
* case, a single reply Message will be produced.
*
* @param message The message.
* @return The result of splitting the message.
*/
protected abstract Object splitMessage(Message<?> message);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* 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.
@@ -27,7 +27,7 @@ import org.springframework.messaging.Message;
* after receiving an array or Collection. If a value is provided for the
* 'delimiters' property, then String payloads will be tokenized based on
* those delimiters.
*
*
* @author Mark Fisher
*/
public class DefaultMessageSplitter extends AbstractMessageSplitter {
@@ -39,11 +39,14 @@ public class DefaultMessageSplitter extends AbstractMessageSplitter {
* Set delimiters to use for tokenizing String values. The default is
* <code>null</code> indicating that no tokenization should occur. If
* delimiters are provided, they will be applied to any String payload.
*
* @param delimiters The delimiters.
*/
public void setDelimiters(String delimiters) {
this.delimiters = delimiters;
}
@Override
protected final Object splitMessage(Message<?> message) {
Object payload = message.getPayload();
if (payload instanceof String && this.delimiters != null) {

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2002-2011 the original author or authors.
*
* 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.
@@ -18,12 +18,13 @@ import java.util.LinkedHashSet;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.jmx.export.annotation.ManagedAttribute;
/**
* @author Dave Syer
* @author Oleg Zhurakousky
*
*
* @since 2.0
*
*/
@@ -31,13 +32,10 @@ public abstract class AbstractMessageGroupStore implements MessageGroupStore, It
protected final Log logger = LogFactory.getLog(getClass());
private Collection<MessageGroupCallback> expiryCallbacks = new LinkedHashSet<MessageGroupCallback>();
private final Collection<MessageGroupCallback> expiryCallbacks = new LinkedHashSet<MessageGroupCallback>();
private volatile boolean timeoutOnIdle;
/**
*
*/
public AbstractMessageGroupStore() {
super();
}
@@ -45,7 +43,7 @@ public abstract class AbstractMessageGroupStore implements MessageGroupStore, It
/**
* Convenient injection point for expiry callbacks in the message store. Each of the callbacks provided will simply
* be registered with the store using {@link #registerMessageGroupExpiryCallback(MessageGroupCallback)}.
*
*
* @param expiryCallbacks the expiry callbacks to add
*/
public void setExpiryCallbacks(Collection<MessageGroupCallback> expiryCallbacks) {
@@ -53,25 +51,29 @@ public abstract class AbstractMessageGroupStore implements MessageGroupStore, It
registerMessageGroupExpiryCallback(callback);
}
}
public boolean isTimeoutOnIdle() {
return timeoutOnIdle;
}
/**
* Allows you to override the rule for the timeout calculation. Typical timeout is based from the time
* the {@link MessageGroup} was created. If you want the timeout to be based on the time
* the {@link MessageGroup} was created. If you want the timeout to be based on the time
* the {@link MessageGroup} was idling (e.g., inactive from the last update) invoke this method with 'true'.
* Default is 'false'.
*
* @param timeoutOnIdle The boolean.
*/
public void setTimeoutOnIdle(boolean timeoutOnIdle) {
this.timeoutOnIdle = timeoutOnIdle;
}
@Override
public void registerMessageGroupExpiryCallback(MessageGroupCallback callback) {
expiryCallbacks.add(callback);
}
@Override
public int expireMessageGroups(long timeout) {
int count = 0;
long threshold = System.currentTimeMillis() - timeout;
@@ -81,7 +83,7 @@ public abstract class AbstractMessageGroupStore implements MessageGroupStore, It
if (this.isTimeoutOnIdle() && group.getLastModified() > 0) {
timestamp = group.getLastModified();
}
if (timestamp <= threshold) {
count++;
expire(group);
@@ -90,6 +92,7 @@ public abstract class AbstractMessageGroupStore implements MessageGroupStore, It
return count;
}
@Override
@ManagedAttribute
public int getMessageCountForAllMessageGroups() {
int count = 0;
@@ -99,6 +102,7 @@ public abstract class AbstractMessageGroupStore implements MessageGroupStore, It
return count;
}
@Override
@ManagedAttribute
public int getMessageGroupCount() {
int count = 0;
@@ -109,9 +113,9 @@ public abstract class AbstractMessageGroupStore implements MessageGroupStore, It
}
private void expire(MessageGroup group) {
RuntimeException exception = null;
for (MessageGroupCallback callback : expiryCallbacks) {
try {
callback.execute(this, group);
@@ -122,7 +126,7 @@ public abstract class AbstractMessageGroupStore implements MessageGroupStore, It
logger.error("Exception in expiry callback", e);
}
}
if (exception != null) {
throw exception;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* 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.
@@ -33,11 +33,16 @@ public interface MessageGroup {
/**
* Query if the message can be added.
*
* @param message The message.
* @return true if the message can be added.
*/
boolean canAdd(Message<?> message);
/**
* Returns all available Messages from the group at the time of invocation
*
* @return The messages.
*/
Collection<Message<?>> getMessages();
@@ -47,7 +52,7 @@ public interface MessageGroup {
Object getGroupId();
/**
* Returns the sequenceNumber of the last released message. Used in Resequencer use cases only
* @return the sequenceNumber of the last released message. Used in Resequencer use cases only
*/
int getLastReleasedMessageSequenceNumber();
@@ -57,7 +62,7 @@ public interface MessageGroup {
boolean isComplete();
/**
*
* Complete the group.
*/
void complete();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* 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
@@ -14,8 +14,8 @@ package org.springframework.integration.store;
import java.util.Iterator;
import org.springframework.messaging.Message;
import org.springframework.jmx.export.annotation.ManagedAttribute;
import org.springframework.messaging.Message;
/**
* Interface for storage operations on groups of messages linked by a group id.
@@ -49,8 +49,10 @@ public interface MessageGroupStore {
int getMessageGroupCount();
/**
* Returns the size of this MessageGroup
* @param groupId
* Returns the size of this MessageGroup.
*
* @param groupId The group identifier.
* @return The size.
*/
@ManagedAttribute
int messageGroupSize(Object groupId);
@@ -59,37 +61,41 @@ public interface MessageGroupStore {
* Return all Messages currently in the MessageStore that were stored using
* {@link #addMessageToGroup(Object, Message)} with this group id.
*
* @return a group of messages, empty if none exists for this key
* @param groupId The group identifier.
* @return A group of messages, empty if none exists for this key.
*/
MessageGroup getMessageGroup(Object groupId);
/**
* Store a message with an association to a group id. This can be used to group messages together.
*
* @param groupId the group id to store the message under
* @param message a message
* @param groupId The group id to store the message under.
* @param message A message.
* @return The message group.
*/
MessageGroup addMessageToGroup(Object groupId, Message<?> message);
/**
* Persist a deletion on a single message from the group. The group is modified to reflect that 'messageToRemove' is
* no longer present in the group.
* @param key the groupId for the group containing the message
* @param messageToRemove the message to be removed
*
* @param key The groupId for the group containing the message.
* @param messageToRemove The message to be removed.
* @return The message Group.
*/
MessageGroup removeMessageFromGroup(Object key, Message<?> messageToRemove);
/**
* Remove the message group with this id.
*
* @param groupId the id of the group to remove
* @param groupId The id of the group to remove.
*/
void removeMessageGroup(Object groupId);
/**
* Register a callback for when a message group is expired through {@link #expireMessageGroups(long)}.
*
* @param callback a callback to execute when a message group is cleaned up
* @param callback A callback to execute when a message group is cleaned up.
*/
void registerMessageGroupExpiryCallback(MessageGroupCallback callback);
@@ -108,12 +114,14 @@ public interface MessageGroupStore {
/**
* Allows you to set the sequence number of the last released Message. Used for Resequencing use cases
* @param sequenceNumber
*
* @param groupId The group identifier.
* @param sequenceNumber The sequence number.
*/
void setLastReleasedSequenceNumberForGroup(Object groupId, int sequenceNumber);
/**
* Returns the iterator of currently accumulated {@link MessageGroup}s
* @return The iterator of currently accumulated {@link MessageGroup}s.
*/
Iterator<MessageGroup> iterator();
@@ -121,6 +129,9 @@ public interface MessageGroupStore {
/**
* Polls Message from this {@link MessageGroup} (in FIFO style if supported by the implementation)
* while also removing the polled {@link Message}
*
* @param groupId The group identifier.
* @return The message.
*/
Message<?> pollMessageFromGroup(Object groupId);
@@ -128,6 +139,8 @@ public interface MessageGroupStore {
* Completes this MessageGroup. Completion of the MessageGroup generally means
* that this group should not be allowing any more mutating operation to be performed on it.
* For example any attempt to add/remove new Message form the group should not be allowed.
*
* @param groupId The group identifier.
*/
void completeGroup(Object groupId);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* 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.
@@ -18,22 +18,23 @@ package org.springframework.integration.store;
import java.util.UUID;
import org.springframework.messaging.Message;
import org.springframework.jmx.export.annotation.ManagedAttribute;
import org.springframework.messaging.Message;
/**
* Strategy interface for storing and retrieving messages.
*
*
* @author Mark Fisher
* @author Iwein Fuld
* @author Dave Syer
*
*
* @since 2.0
*/
public interface MessageStore {
/**
* Return the Message with the given id, or <i>null</i> if no Message with that id exists in the MessageStore.
* @param id The message identifier.
* @return The Message with the given id, or <i>null</i> if no Message with that id exists in the MessageStore.
*/
Message<?> getMessage(UUID id);
@@ -42,22 +43,27 @@ public interface MessageStore {
* does then the return value can be different than the input. The id of the return value will be used as an index
* so that the {@link #getMessage(UUID)} and {@link #removeMessage(UUID)} behave properly. Since messages are
* immutable, putting the same message more than once is a no-op.
*
* @return the message that was stored
*
* @param message The message.
* @param <T> The payload type.
* @return The message that was stored.
*/
<T> Message<T> addMessage(Message<T> message);
/**
* Remove the Message with the given id from the MessageStore, if present, and return it. If no Message with that id
* is present in the store, this will return <i>null</i>.
*
* @param id THe message identifier.
* @return The message.
*/
Message<?> removeMessage(UUID id);
/**
* Optional attribute giving the number of messages in the store. Implementations may decline to respond by throwing
* an exception.
*
* @return the number of messages
*
* @return The number of messages.
* @throws UnsupportedOperationException if not implemented
*/
@ManagedAttribute

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2007-2011 the original author or authors
* Copyright 2007-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.
@@ -21,7 +21,7 @@ import org.springframework.messaging.MessagingException;
/**
* Exception for problems that occur when using a {@link MessageStore} implementation.
*
*
* @author Oleg Zhurakousky
* @since 2.1
*/
@@ -30,47 +30,47 @@ public class MessageStoreException extends MessagingException {
private static final long serialVersionUID = 1L;
/**
* @param message
* @param message The message.
*/
public MessageStoreException(Message<?> message) {
super(message);
}
/**
* @param description
* @param description The description.
*/
public MessageStoreException(String description) {
super(description);
}
/**
* @param description
* @param cause
* @param description The description.
* @param cause The cause.
*/
public MessageStoreException(String description, Throwable cause) {
super(description, cause);
}
/**
* @param message
* @param description
* @param message The message.
* @param description The description.
*/
public MessageStoreException(Message<?> message, String description) {
super(message, description);
}
/**
* @param message
* @param cause
* @param message The message.
* @param cause The cause.
*/
public MessageStoreException(Message<?> message, Throwable cause) {
super(message, cause);
}
/**
* @param message
* @param description
* @param cause
* @param message The message.
* @param description The description.
* @param cause The cause.
*/
public MessageStoreException(Message<?> message, String description, Throwable cause) {
super(message, description, cause);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* 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
@@ -21,13 +21,13 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.locks.Lock;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessagingException;
import org.springframework.integration.util.DefaultLockRegistry;
import org.springframework.integration.util.LockRegistry;
import org.springframework.integration.util.UpperBound;
import org.springframework.jmx.export.annotation.ManagedAttribute;
import org.springframework.jmx.export.annotation.ManagedResource;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessagingException;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
@@ -64,6 +64,9 @@ public class SimpleMessageStore extends AbstractMessageGroupStore implements Mes
* {@link #addMessage(Message)} and to those stored via {@link #addMessageToGroup(Object, Message)}. In both cases
* the capacity applies to the number of messages that can be stored, and once that limit is reached attempting to
* store another will result in an exception.
*
* @param individualCapacity The message capacity.
* @param groupCapacity The capacity of each group.
*/
public SimpleMessageStore(int individualCapacity, int groupCapacity) {
this(individualCapacity, groupCapacity, new DefaultLockRegistry());
@@ -73,6 +76,10 @@ public class SimpleMessageStore extends AbstractMessageGroupStore implements Mes
* See {@link #SimpleMessageStore(int, int)}.
* Also allows the provision of a custom {@link LockRegistry}
* rather than using the default.
*
* @param individualCapacity The message capacity.
* @param groupCapacity The capacity of each group.
* @param lockRegistry The lock registry.
*/
public SimpleMessageStore(int individualCapacity, int groupCapacity, LockRegistry lockRegistry) {
Assert.notNull(lockRegistry, "The LockRegistry cannot be null");
@@ -85,6 +92,8 @@ public class SimpleMessageStore extends AbstractMessageGroupStore implements Mes
/**
* Creates a SimpleMessageStore with the same capacity for individual and grouped messages.
*
* @param capacity The capacity.
*/
public SimpleMessageStore(int capacity) {
this(capacity, capacity);
@@ -103,11 +112,13 @@ public class SimpleMessageStore extends AbstractMessageGroupStore implements Mes
this.lockRegistry = lockRegistry;
}
@Override
@ManagedAttribute
public long getMessageCount() {
return idToMessage.size();
}
@Override
public <T> Message<T> addMessage(Message<T> message) {
this.isUsed = true;
if (!individualUpperBound.tryAcquire(0)) {
@@ -118,19 +129,23 @@ public class SimpleMessageStore extends AbstractMessageGroupStore implements Mes
return message;
}
@Override
public Message<?> getMessage(UUID key) {
return (key != null) ? this.idToMessage.get(key) : null;
}
@Override
public Message<?> removeMessage(UUID key) {
if (key != null) {
individualUpperBound.release();
return this.idToMessage.remove(key);
}
else
else {
return null;
}
}
@Override
public MessageGroup getMessageGroup(Object groupId) {
Assert.notNull(groupId, "'groupId' must not be null");
@@ -143,6 +158,7 @@ public class SimpleMessageStore extends AbstractMessageGroupStore implements Mes
return simpleMessageGroup;
}
@Override
public MessageGroup addMessageToGroup(Object groupId, Message<?> message) {
if (!groupUpperBound.tryAcquire(0)) {
throw new MessagingException(this.getClass().getSimpleName()
@@ -171,6 +187,7 @@ public class SimpleMessageStore extends AbstractMessageGroupStore implements Mes
}
}
@Override
public void removeMessageGroup(Object groupId) {
Lock lock = this.lockRegistry.obtain(groupId);
try {
@@ -193,6 +210,7 @@ public class SimpleMessageStore extends AbstractMessageGroupStore implements Mes
}
}
@Override
public MessageGroup removeMessageFromGroup(Object groupId, Message<?> messageToRemove) {
Lock lock = this.lockRegistry.obtain(groupId);
try {
@@ -215,10 +233,12 @@ public class SimpleMessageStore extends AbstractMessageGroupStore implements Mes
}
}
@Override
public Iterator<MessageGroup> iterator() {
return new HashSet<MessageGroup>(groupIdToMessageGroup.values()).iterator();
}
@Override
public void setLastReleasedSequenceNumberForGroup(Object groupId, int sequenceNumber) {
Lock lock = this.lockRegistry.obtain(groupId);
try {
@@ -240,6 +260,7 @@ public class SimpleMessageStore extends AbstractMessageGroupStore implements Mes
}
}
@Override
public void completeGroup(Object groupId) {
Lock lock = this.lockRegistry.obtain(groupId);
try {
@@ -261,6 +282,7 @@ public class SimpleMessageStore extends AbstractMessageGroupStore implements Mes
}
}
@Override
public Message<?> pollMessageFromGroup(Object groupId) {
Collection<Message<?>> messageList = this.getMessageGroup(groupId).getMessages();
Message<?> message = null;
@@ -273,6 +295,7 @@ public class SimpleMessageStore extends AbstractMessageGroupStore implements Mes
return message;
}
@Override
public int messageGroupSize(Object groupId) {
return this.getMessageGroup(groupId).size();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* 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.
@@ -24,11 +24,11 @@ import java.util.List;
import java.util.Map;
import org.springframework.integration.IntegrationMessageHeaderAccessor;
import org.springframework.messaging.support.GenericMessage;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessageHeaders;
import org.springframework.messaging.support.ErrorMessage;
import org.springframework.messaging.support.GenericMessage;
import org.springframework.util.Assert;
/**
@@ -65,6 +65,8 @@ public final class MessageBuilder<T> {
* provided message. The payload of the provided Message will also be used as the payload for the new message.
*
* @param message the Message from which the payload and all headers will be copied
* @param <T> The type of the payload.
* @return A MessageBuilder.
*/
public static <T> MessageBuilder<T> fromMessage(Message<T> message) {
Assert.notNull(message, "message must not be null");
@@ -76,6 +78,8 @@ public final class MessageBuilder<T> {
* Create a builder for a new {@link Message} instance with the provided payload.
*
* @param payload the payload for the new message
* @param <T> The type of the payload.
* @return A MessageBuilder.
*/
public static <T> MessageBuilder<T> withPayload(T payload) {
MessageBuilder<T> builder = new MessageBuilder<T>(payload, null);
@@ -84,6 +88,10 @@ public final class MessageBuilder<T> {
/**
* Set the value for the given header name. If the provided value is <code>null</code>, the header will be removed.
*
* @param headerName The header name.
* @param headerValue The header value.
* @return this MessageBuilder.
*/
public MessageBuilder<T> setHeader(String headerName, Object headerValue) {
this.headerAccessor.setHeader(headerName, headerValue);
@@ -92,6 +100,10 @@ public final class MessageBuilder<T> {
/**
* Set the value for the given header name only if the header name is not already associated with a value.
*
* @param headerName The header name.
* @param headerValue The header value.
* @return this MessageBuilder.
*/
public MessageBuilder<T> setHeaderIfAbsent(String headerName, Object headerValue) {
this.headerAccessor.setHeaderIfAbsent(headerName, headerValue);
@@ -103,7 +115,8 @@ public final class MessageBuilder<T> {
* may contain simple matching patterns for header names. Supported pattern styles are:
* "xxx*", "*xxx", "*xxx*" and "xxx*yyy".
*
* @param headerPatterns
* @param headerPatterns The header patterns.
* @return this MessageBuilder.
*/
public MessageBuilder<T> removeHeaders(String... headerPatterns) {
this.headerAccessor.removeHeaders(headerPatterns);
@@ -111,6 +124,8 @@ public final class MessageBuilder<T> {
}
/**
* Remove the value for the given header name.
* @param headerName The header name.
* @return this MessageBuilder.
*/
public MessageBuilder<T> removeHeader(String headerName) {
this.headerAccessor.removeHeader(headerName);
@@ -122,6 +137,9 @@ public final class MessageBuilder<T> {
* {@link #copyHeadersIfAbsent(Map)} to avoid overwriting values. Note that the 'id' and 'timestamp' header values
* will never be overwritten.
*
* @param headersToCopy The headers to copy.
* @return this MessageBuilder.
*
* @see MessageHeaders#ID
* @see MessageHeaders#TIMESTAMP
*/
@@ -132,6 +150,9 @@ public final class MessageBuilder<T> {
/**
* Copy the name-value pairs from the provided Map. This operation will <em>not</em> overwrite any existing values.
*
* @param headersToCopy The headers to copy.
* @return this MessageBuilder.
*/
public MessageBuilder<T> copyHeadersIfAbsent(Map<String, ?> headersToCopy) {
this.headerAccessor.copyHeadersIfAbsent(headersToCopy);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* 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.
@@ -41,7 +41,8 @@ public class MapMessageConverter implements MessageConverter {
* Headers to be converted in {@link #fromMessage(Message, Class)}.
* {@link #toMessage(Object, MessageHeaders)} will populate all headers found in
* the map, unless {@link #filterHeadersInToMessage} is true.
* @param headerNames
*
* @param headerNames The header names.
*/
public void setHeaderNames(String... headerNames) {
this.headerNames = headerNames;
@@ -52,7 +53,8 @@ public class MapMessageConverter implements MessageConverter {
* will be mapped. Set this property
* to 'true' if you wish to limit the inbound headers to those in
* the #headerNames.
* @param filterHeadersInToMessage
*
* @param filterHeadersInToMessage true if the headers should be filtered.
*/
public void setFilterHeadersInToMessage(boolean filterHeadersInToMessage) {
this.filterHeadersInToMessage = filterHeadersInToMessage;
@@ -73,11 +75,6 @@ public class MapMessageConverter implements MessageConverter {
headers.keySet().retainAll(Arrays.asList(this.headerNames));
}
messageBuilder.copyHeaders(headers);
/*for (Entry<String, ?> entry : headers.entrySet()) {
if (this.filterHeadersInToMessage ? this.headerNames.contains(entry.getKey()) : true) {
messageBuilder.setHeader(entry.getKey(), entry.getValue());
}
}*/
}
Message<?> convertedMessage = messageBuilder.build();
return convertedMessage;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* 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
@@ -49,8 +49,8 @@ public class IntegrationResourceHolder implements ResourceHolder {
/**
* Adds attribute to this {@link ResourceHolder} instance
*
* @param key
* @param value
* @param key The key.
* @param value The value.
*/
public void addAttribute(String key, Object value){
this.attributes.put(key, value);
@@ -66,12 +66,15 @@ public class IntegrationResourceHolder implements ResourceHolder {
return Collections.unmodifiableMap(attributes);
}
@Override
public void reset() {
}
@Override
public void unbound() {
}
@Override
public boolean isVoid() {
return false;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2009 the original author or authors.
* 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.
@@ -16,18 +16,19 @@
package org.springframework.integration.transformer;
import org.springframework.messaging.Message;
import org.springframework.integration.context.IntegrationObjectSupport;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.Message;
/**
* A base class for {@link Transformer} implementations.
*
*
* @author Mark Fisher
* @author Oleg Zhurakousky
*/
public abstract class AbstractTransformer extends IntegrationObjectSupport implements Transformer {
@Override
public final Message<?> transform(Message<?> message) {
try {
Object result = this.doTransform(message);
@@ -50,6 +51,10 @@ public abstract class AbstractTransformer extends IntegrationObjectSupport imple
* logic. If the return value is itself a Message, it will be used as the
* result. Otherwise, any non-null return value will be used as the payload
* of the result Message.
*
* @param message The message.
* @return The result of the transformation.
* @throws Exception Any exception.
*/
protected abstract Object doTransform(Message<?> message) throws Exception;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* 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.
@@ -16,15 +16,15 @@
package org.springframework.integration.transformer;
import org.springframework.messaging.Message;
import org.springframework.integration.store.MessageStore;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.Message;
import org.springframework.util.Assert;
/**
* Transformer that stores a Message and returns a new Message whose payload
* is the id of the stored Message.
*
*
* @author Mark Fisher
* @since 2.0
*/
@@ -35,6 +35,8 @@ public class ClaimCheckInTransformer extends AbstractTransformer {
/**
* Create a claim check-in transformer that will delegate to the provided MessageStore.
*
* @param messageStore The message store.
*/
public ClaimCheckInTransformer(MessageStore messageStore) {
Assert.notNull(messageStore, "MessageStore must not be null");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* 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.
@@ -18,16 +18,16 @@ package org.springframework.integration.transformer;
import java.util.UUID;
import org.springframework.messaging.Message;
import org.springframework.integration.store.MessageStore;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.Message;
import org.springframework.util.Assert;
/**
* Transformer that accepts a Message whose payload is a UUID and retrieves the Message associated
* with that id from a MessageStore if available. An Exception will be thrown if no Message with
* that ID can be retrieved from the given MessageStore.
*
*
* @author Mark Fisher
* @author Oleg Zhurakousky
* @author Nick Spacek
@@ -42,12 +42,14 @@ public class ClaimCheckOutTransformer extends AbstractTransformer {
/**
* Create a claim check-out transformer that will delegate to the provided MessageStore.
*
* @param messageStore The message store.
*/
public ClaimCheckOutTransformer(MessageStore messageStore) {
Assert.notNull(messageStore, "MessageStore must not be null");
this.messageStore = messageStore;
}
public void setRemoveMessage(boolean removeMessage) {
this.removeMessage = removeMessage;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* 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.
@@ -26,15 +26,15 @@ import org.springframework.expression.Expression;
import org.springframework.expression.spel.SpelParserConfiguration;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.support.StandardEvaluationContext;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessageHandlingException;
import org.springframework.integration.expression.ExpressionUtils;
import org.springframework.integration.expression.IntegrationEvaluationContextAware;
import org.springframework.integration.gateway.MessagingGatewaySupport;
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.integration.transformer.support.HeaderValueMessageProcessor;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessageHandlingException;
import org.springframework.util.Assert;
import org.springframework.util.ReflectionUtils;
@@ -80,6 +80,8 @@ public class ContentEnricher extends AbstractReplyProducingMessageHandler implem
* Provide the map of expressions to evaluate when enriching the target payload.
* The keys should simply be property names, and the values should be Expressions
* that will evaluate against the reply Message as the root object.
*
* @param propertyExpressions The property expressions.
*/
public void setPropertyExpressions(Map<String, Expression> propertyExpressions) {
Assert.notEmpty(propertyExpressions, "propertyExpressions must not be empty");
@@ -99,6 +101,8 @@ public class ContentEnricher extends AbstractReplyProducingMessageHandler implem
* the target MessageHeaders.
* The keys should simply be header names, and the values should be Expressions
* that will evaluate against the reply Message as the root object.
*
* @param headerExpressions The header expressions.
*/
public void setHeaderExpressions(Map<String, HeaderValueMessageProcessor<?>> headerExpressions) {
Assert.notEmpty(headerExpressions, "headerExpressions must not be empty");
@@ -112,6 +116,8 @@ public class ContentEnricher extends AbstractReplyProducingMessageHandler implem
* Gateway will be initialized. Setting a request channel is optional.
* Not setting a request channel is useful in situations where
* message payloads shall be enriched with static values only.
*
* @param requestChannel The request channel.
*/
public void setRequestChannel(MessageChannel requestChannel) {
this.requestChannel = requestChannel;
@@ -121,6 +127,8 @@ public class ContentEnricher extends AbstractReplyProducingMessageHandler implem
* Sets the content enricher's reply channel. If not specified, yet the request
* channel is set, an anonymous reply channel will automatically created
* for each request.
*
* @param replyChannel The reply channel.
*/
public void setReplyChannel(MessageChannel replyChannel) {
this.replyChannel = replyChannel;
@@ -171,6 +179,8 @@ public class ContentEnricher extends AbstractReplyProducingMessageHandler implem
* If more sophisticated logic is required (e.g. changing the message
* headers etc.) please use additional downstream transformers.
*
* @param requestPayloadExpression The request payload expression.
*
*/
public void setRequestPayloadExpression(Expression requestPayloadExpression) {
this.requestPayloadExpression = requestPayloadExpression;
@@ -179,6 +189,8 @@ public class ContentEnricher extends AbstractReplyProducingMessageHandler implem
/**
* Specify whether to clone payload objects to create the target object.
* This is only applicable for payload types that implement Cloneable.
*
* @param shouldClonePayload true if the payload should be cloned.
*/
public void setShouldClonePayload(boolean shouldClonePayload) {
this.shouldClonePayload = shouldClonePayload;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* 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.
@@ -60,6 +60,8 @@ public class HeaderEnricher implements Transformer, BeanNameAware, InitializingB
/**
* Create a HeaderEnricher with the given map of headers.
*
* @param headersToAdd The headers to add.
*/
public HeaderEnricher(Map<String, ? extends HeaderValueMessageProcessor<?>> headersToAdd) {
this.headersToAdd = (headersToAdd != null) ? headersToAdd
@@ -80,11 +82,14 @@ public class HeaderEnricher implements Transformer, BeanNameAware, InitializingB
* <code>true</code>. Set this to <code>false</code> if a
* <code>null</code> value should trigger <i>removal</i> of the
* corresponding header instead.
*
* @param shouldSkipNulls true when null values should be skipped.
*/
public void setShouldSkipNulls(boolean shouldSkipNulls) {
this.shouldSkipNulls = shouldSkipNulls;
}
@Override
public Message<?> transform(Message<?> message) {
try {
Map<String, Object> headerMap = new HashMap<String, Object>(message.getHeaders());
@@ -147,6 +152,7 @@ public class HeaderEnricher implements Transformer, BeanNameAware, InitializingB
* org.springframework.beans.factory.BeanNameAware#setBeanName(java.lang
* .String)
*/
@Override
public void setBeanName(String beanName) {
this.beanName = beanName;
@@ -158,6 +164,7 @@ public class HeaderEnricher implements Transformer, BeanNameAware, InitializingB
* @see
* org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
*/
@Override
public void afterPropertiesSet() throws Exception {
boolean shouldOverwrite = this.defaultOverwrite;
for (HeaderValueMessageProcessor<?> processor : this.headersToAdd.values()) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* 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.
@@ -45,7 +45,7 @@ public class MapToObjectTransformer extends AbstractPayloadTransformer<Map<?, ?>
private final String targetBeanName;
/**
* @param targetClass
* @param targetClass The target class.
*/
public MapToObjectTransformer(Class<?> targetClass) {
Assert.notNull(targetClass, "targetClass must not be null");
@@ -54,7 +54,7 @@ public class MapToObjectTransformer extends AbstractPayloadTransformer<Map<?, ?>
}
/**
* @param beanName
* @param beanName The bean name.
*/
public MapToObjectTransformer(String beanName) {
Assert.hasText(beanName, "beanName must not be empty");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* 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.
@@ -39,6 +39,8 @@ public class MessageTransformingHandler extends AbstractReplyProducingMessageHan
/**
* Create a {@link MessageTransformingHandler} instance that delegates to
* the provided {@link Transformer}.
*
* @param transformer The transformer.
*/
public MessageTransformingHandler(Transformer transformer) {
Assert.notNull(transformer, "transformer must not be null");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* 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
@@ -52,8 +52,7 @@ public final class DefaultLockRegistry implements LockRegistry {
* <li>0x3ff (1023) - 1024 locks</li>
* <li>0xfff (4095) - 4096 locks</li>
* </ul>
* <p>
* @param mask
* @param mask The bit mask.
*/
public DefaultLockRegistry(int mask){
String bits = Integer.toBinaryString(mask);
@@ -71,6 +70,7 @@ public final class DefaultLockRegistry implements LockRegistry {
* the mask and using the result as an index to the lock table.
* @param lockKey the object used to derive the lock index.
*/
@Override
public Lock obtain(Object lockKey) {
Assert.notNull(lockKey, "'lockKey' must not be null");
Integer lockIndex = lockKey.hashCode() & this.mask;

Some files were not shown because too many files have changed in this diff Show More