INT-2638 added support for Redis inbound channel adapters
Currenly there is support for: - list-inbound-channel-adapter - http://redis.io/commands#list - zset-inbound-channel-adapter - http://redis.io/commands#sorted_set INT-2638 polishing INT-2638 polished schema docs INT-2638 polishing INT-2638 polishing INT-2638 refactored Redis collection inbound adapters to use RedisStore (view) INT-2638 polishing, exposed redis-template via the namespace INT-2638 polished based on PR comments INT-2638 polishing INT-2638 Polishing
This commit is contained in:
committed by
Gary Russell
parent
9423c21e7a
commit
bfb5cbdb2a
@@ -17,6 +17,10 @@ import static org.springframework.beans.factory.xml.AbstractBeanDefinitionParser
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.config.BeanDefinitionHolder;
|
||||
import org.springframework.beans.factory.config.RuntimeBeanReference;
|
||||
@@ -24,9 +28,12 @@ import org.springframework.beans.factory.config.TypedStringValue;
|
||||
import org.springframework.beans.factory.parsing.BeanComponentDefinition;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.support.ManagedList;
|
||||
import org.springframework.beans.factory.support.RootBeanDefinition;
|
||||
import org.springframework.beans.factory.xml.BeanDefinitionParserDelegate;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.core.Conventions;
|
||||
import org.springframework.expression.common.LiteralExpression;
|
||||
import org.springframework.integration.config.ExpressionFactoryBean;
|
||||
import org.springframework.integration.endpoint.AbstractPollingEndpoint;
|
||||
import org.springframework.transaction.interceptor.DefaultTransactionAttribute;
|
||||
import org.springframework.transaction.interceptor.MatchAlwaysTransactionAttributeSource;
|
||||
@@ -34,9 +41,6 @@ import org.springframework.transaction.interceptor.TransactionInterceptor;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.util.xml.DomUtils;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
/**
|
||||
* Shared utility methods for integration namespace parsers.
|
||||
@@ -379,4 +383,36 @@ public abstract class IntegrationNamespaceUtils {
|
||||
return adviceChain;
|
||||
}
|
||||
|
||||
public static RootBeanDefinition createExpressionDefinitionFromValueOrExpression(String valueElementName,
|
||||
String expressionElementName, ParserContext parserContext, Element element, boolean oneRequired) {
|
||||
|
||||
Assert.hasText(valueElementName, "'valueElementName' must not be empty");
|
||||
Assert.hasText(expressionElementName, "'expressionElementName' must no be empty");
|
||||
|
||||
String valueElementValue = element.getAttribute(valueElementName);
|
||||
String expressionElementValue = element.getAttribute(expressionElementName);
|
||||
|
||||
boolean hasAttributeValue = StringUtils.hasText(valueElementValue);
|
||||
boolean hasAttributeExpression = StringUtils.hasText(expressionElementValue);
|
||||
|
||||
if (hasAttributeValue && hasAttributeExpression){
|
||||
parserContext.getReaderContext().error("Only one of '" + valueElementName + "' or '"
|
||||
+ expressionElementName + "' is allowed", element);
|
||||
}
|
||||
|
||||
if (oneRequired && (!hasAttributeValue && !hasAttributeExpression)){
|
||||
parserContext.getReaderContext().error("One of '" + valueElementName + "' or '"
|
||||
+ expressionElementName + "' is required", element);
|
||||
}
|
||||
RootBeanDefinition expressionDef = null;
|
||||
if (hasAttributeValue) {
|
||||
expressionDef = new RootBeanDefinition(LiteralExpression.class);
|
||||
expressionDef.getConstructorArgumentValues().addGenericArgumentValue(valueElementValue);
|
||||
}
|
||||
else if (hasAttributeExpression){
|
||||
expressionDef = new RootBeanDefinition(ExpressionFactoryBean.class);
|
||||
expressionDef.getConstructorArgumentValues().addGenericArgumentValue(expressionElementValue);
|
||||
}
|
||||
return expressionDef;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,11 +152,15 @@ public class SourcePollingChannelAdapter extends AbstractPollingEndpoint impleme
|
||||
Object resource = NO_TX_RESOURCE;
|
||||
if (this.isPseudoTxMessageSource) {
|
||||
messageSource = (PseudoTransactionalMessageSource<?,Object>) this.source;
|
||||
resource = messageSource.getResource();
|
||||
}
|
||||
Message<?> message;
|
||||
try {
|
||||
message = this.source.receive();
|
||||
if (this.isPseudoTxMessageSource) {
|
||||
Object actualResource = messageSource.getResource();
|
||||
resource = actualResource != null ? actualResource : resource;
|
||||
}
|
||||
|
||||
if (TransactionSynchronizationManager.isActualTransactionActive()) {
|
||||
TransactionSynchronizationManager.bindResource(this, resource);
|
||||
TransactionSynchronizationManager.registerSynchronization(
|
||||
|
||||
@@ -15,17 +15,22 @@
|
||||
*/
|
||||
package org.springframework.integration.util;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.context.expression.BeanFactoryResolver;
|
||||
import org.springframework.context.expression.MapAccessor;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.expression.BeanResolver;
|
||||
import org.springframework.expression.spel.support.StandardEvaluationContext;
|
||||
import org.springframework.expression.spel.support.StandardTypeConverter;
|
||||
import org.springframework.integration.context.IntegrationContextUtils;
|
||||
|
||||
/**
|
||||
* Utility class with static methods for helping with establishing environments for
|
||||
* SpEL expressions.
|
||||
*
|
||||
* @author Gary Russell
|
||||
* @author Oleg Zhurakousky
|
||||
* @since 2.2
|
||||
*
|
||||
*/
|
||||
@@ -83,4 +88,19 @@ public class ExpressionUtils {
|
||||
}
|
||||
return evaluationContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates {@link BeanFactoryResolver}, extracts {@link ConversionService} and delegates to
|
||||
* {@link #createStandardEvaluationContext(BeanResolver, ConversionService)}
|
||||
*
|
||||
* @param beanFactory
|
||||
* @return
|
||||
*/
|
||||
public static StandardEvaluationContext createStandardEvaluationContext(BeanFactory beanFactory) {
|
||||
ConversionService conversionService = IntegrationContextUtils.getConversionService(beanFactory);
|
||||
if (conversionService == null && beanFactory instanceof ConfigurableListableBeanFactory){
|
||||
conversionService = ((ConfigurableListableBeanFactory)beanFactory).getConversionService();
|
||||
}
|
||||
return createStandardEvaluationContext(new BeanFactoryResolver(beanFactory), conversionService);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user