diff --git a/build.gradle b/build.gradle index ee36c8ff34..c7d3fbf422 100644 --- a/build.gradle +++ b/build.gradle @@ -447,7 +447,15 @@ project('spring-integration-jpa') { compile ("org.eclipse.persistence:javax.persistence:$jpaApiVersion", optional) - testCompile "org.springframework.data:spring-data-jpa:$springDataJpaVersion" + testCompile ("org.springframework.data:spring-data-jpa:$springDataJpaVersion") { + exclude group: 'org.springframework', module: 'spring-beans' + exclude group: 'org.springframework', module: 'spring-context' + exclude group: 'org.springframework', module: 'spring-core' + exclude group: 'org.springframework', module: 'spring-expression' + exclude group: 'org.springframework', module: 'spring-aop' + exclude group: 'org.springframework', module: 'spring-orm' + exclude group: 'org.springframework', module: 'spring-tx' + } testCompile "com.h2database:h2:$h2Version" testCompile "org.hsqldb:hsqldb:$hsqldbVersion" diff --git a/spring-integration-core/src/main/java/org/springframework/integration/config/annotation/AbstractMethodAnnotationPostProcessor.java b/spring-integration-core/src/main/java/org/springframework/integration/config/annotation/AbstractMethodAnnotationPostProcessor.java index 587b45cd1c..b34a4d0619 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/config/annotation/AbstractMethodAnnotationPostProcessor.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/config/annotation/AbstractMethodAnnotationPostProcessor.java @@ -121,7 +121,7 @@ public abstract class AbstractMethodAnnotationPostProcessor) GenericTypeResolver.resolveTypeArgument(this.getClass(), diff --git a/spring-integration-core/src/main/java/org/springframework/integration/context/IntegrationObjectSupport.java b/spring-integration-core/src/main/java/org/springframework/integration/context/IntegrationObjectSupport.java index 7fc4d4eb05..04fa375183 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/context/IntegrationObjectSupport.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/context/IntegrationObjectSupport.java @@ -73,7 +73,7 @@ public abstract class IntegrationObjectSupport implements BeanNameAware, NamedCo */ protected final Log logger = LogFactory.getLog(getClass()); - private final ConversionService defaultConversionService = new DefaultConversionService(); + private final ConversionService defaultConversionService = DefaultConversionService.getSharedInstance(); private volatile DestinationResolver channelResolver; diff --git a/spring-integration-core/src/main/java/org/springframework/integration/dsl/RouterSpec.java b/spring-integration-core/src/main/java/org/springframework/integration/dsl/RouterSpec.java index a5abe1277e..74be3d0488 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/dsl/RouterSpec.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/dsl/RouterSpec.java @@ -172,7 +172,7 @@ public final class RouterSpec protected void onInit() throws Exception { ConversionService conversionService = getConversionService(); if (conversionService == null) { - conversionService = new DefaultConversionService(); + conversionService = DefaultConversionService.getSharedInstance(); } for (Map.Entry entry : this.mapping.entrySet()) { Object key = entry.getKey(); diff --git a/spring-integration-core/src/main/java/org/springframework/integration/handler/LambdaMessageProcessor.java b/spring-integration-core/src/main/java/org/springframework/integration/handler/LambdaMessageProcessor.java index 66333220c5..dd94340559 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/handler/LambdaMessageProcessor.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/handler/LambdaMessageProcessor.java @@ -86,7 +86,7 @@ public class LambdaMessageProcessor implements MessageProcessor, BeanFac public void setBeanFactory(BeanFactory beanFactory) throws BeansException { ConversionService conversionService = IntegrationUtils.getConversionService(beanFactory); if (conversionService == null) { - conversionService = new DefaultConversionService(); + conversionService = DefaultConversionService.getSharedInstance(); } this.conversionService = conversionService; } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/router/AbstractMessageRouter.java b/spring-integration-core/src/main/java/org/springframework/integration/router/AbstractMessageRouter.java index 817b0a19a9..53e37543d4 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/router/AbstractMessageRouter.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/router/AbstractMessageRouter.java @@ -140,7 +140,7 @@ public abstract class AbstractMessageRouter extends AbstractMessageHandler imple if (this.getConversionService() == null) { synchronized (this) { if (this.getConversionService() == null) { - this.setConversionService(new DefaultConversionService()); + this.setConversionService(DefaultConversionService.getSharedInstance()); } } } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/converter/DefaultDatatypeChannelMessageConverter.java b/spring-integration-core/src/main/java/org/springframework/integration/support/converter/DefaultDatatypeChannelMessageConverter.java index 654820365e..1ba5638580 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/converter/DefaultDatatypeChannelMessageConverter.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/converter/DefaultDatatypeChannelMessageConverter.java @@ -39,7 +39,7 @@ import org.springframework.util.Assert; public class DefaultDatatypeChannelMessageConverter implements MessageConverter, BeanFactoryAware { - private volatile ConversionService conversionService = new DefaultConversionService(); + private volatile ConversionService conversionService = DefaultConversionService.getSharedInstance(); private volatile boolean conversionServiceSet; diff --git a/spring-integration-core/src/main/java/org/springframework/integration/transformer/MapToObjectTransformer.java b/spring-integration-core/src/main/java/org/springframework/integration/transformer/MapToObjectTransformer.java index 5ed1aa8871..58b9840004 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/transformer/MapToObjectTransformer.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/transformer/MapToObjectTransformer.java @@ -84,7 +84,7 @@ public class MapToObjectTransformer extends AbstractPayloadTransformer DataBinder binder = new DataBinder(target); ConversionService conversionService = this.getConversionService(); if (conversionService == null) { - conversionService = new DefaultConversionService(); + conversionService = DefaultConversionService.getSharedInstance(); } binder.setConversionService(conversionService); binder.bind(new MutablePropertyValues(payload)); diff --git a/spring-integration-core/src/main/java/org/springframework/integration/util/BeanFactoryTypeConverter.java b/spring-integration-core/src/main/java/org/springframework/integration/util/BeanFactoryTypeConverter.java index d023e11123..c6e26498e3 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/util/BeanFactoryTypeConverter.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/util/BeanFactoryTypeConverter.java @@ -27,8 +27,8 @@ import org.springframework.core.convert.ConversionService; import org.springframework.core.convert.TypeDescriptor; import org.springframework.core.convert.support.DefaultConversionService; import org.springframework.expression.TypeConverter; -import org.springframework.messaging.MessageHeaders; import org.springframework.integration.history.MessageHistory; +import org.springframework.messaging.MessageHeaders; import org.springframework.util.ClassUtils; /** @@ -39,9 +39,6 @@ import org.springframework.util.ClassUtils; */ public class BeanFactoryTypeConverter implements TypeConverter, BeanFactoryAware { - private static ConversionService defaultConversionService; - - private volatile SimpleTypeConverter delegate = new SimpleTypeConverter(); private volatile boolean haveCalledDelegateGetDefaultEditor; @@ -50,12 +47,7 @@ public class BeanFactoryTypeConverter implements TypeConverter, BeanFactoryAware public BeanFactoryTypeConverter() { - synchronized (BeanFactoryTypeConverter.class) { - if (defaultConversionService == null) { - defaultConversionService = new DefaultConversionService(); - } - } - this.conversionService = defaultConversionService; + this.conversionService = DefaultConversionService.getSharedInstance(); } public BeanFactoryTypeConverter(ConversionService conversionService) { @@ -67,6 +59,7 @@ public class BeanFactoryTypeConverter implements TypeConverter, BeanFactoryAware this.conversionService = conversionService; } + @Override public void setBeanFactory(BeanFactory beanFactory) throws BeansException { if (beanFactory instanceof ConfigurableBeanFactory) { Object typeConverter = ((ConfigurableBeanFactory) beanFactory).getTypeConverter(); @@ -90,6 +83,7 @@ public class BeanFactoryTypeConverter implements TypeConverter, BeanFactoryAware return this.delegate.findCustomEditor(targetType, null) != null || this.getDefaultEditor(targetType) != null; } + @Override public boolean canConvert(TypeDescriptor sourceTypeDescriptor, TypeDescriptor targetTypeDescriptor) { if (this.conversionService.canConvert(sourceTypeDescriptor, targetTypeDescriptor)) { return true; @@ -100,6 +94,7 @@ public class BeanFactoryTypeConverter implements TypeConverter, BeanFactoryAware return canConvert(sourceType, targetType); } + @Override public Object convertValue(Object value, TypeDescriptor sourceType, TypeDescriptor targetType) { // Echoes org.springframework.expression.common.ExpressionUtils.convertTypedValue() if ((targetType.getType() == Void.class || targetType.getType() == Void.TYPE) && value == null) { diff --git a/spring-integration-core/src/test/java/org/springframework/integration/expression/ExpressionUtilsTests.java b/spring-integration-core/src/test/java/org/springframework/integration/expression/ExpressionUtilsTests.java index 405cb47a9a..aa6b2eea83 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/expression/ExpressionUtilsTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/expression/ExpressionUtilsTests.java @@ -17,13 +17,16 @@ package org.springframework.integration.expression; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNotSame; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; import org.junit.Test; + import org.springframework.beans.factory.support.RootBeanDefinition; import org.springframework.context.support.ConversionServiceFactoryBean; import org.springframework.context.support.GenericApplicationContext; +import org.springframework.core.convert.support.DefaultConversionService; import org.springframework.expression.TypeConverter; import org.springframework.expression.spel.support.StandardEvaluationContext; import org.springframework.integration.config.IntegrationEvaluationContextFactoryBean; @@ -66,6 +69,8 @@ public class ExpressionUtilsTests { assertNotNull(evalContext.getBeanResolver()); TypeConverter typeConverter = evalContext.getTypeConverter(); assertNotNull(typeConverter); + assertSame(DefaultConversionService.getSharedInstance(), + TestUtils.getPropertyValue(typeConverter, "conversionService")); } @Test @@ -78,6 +83,8 @@ public class ExpressionUtilsTests { assertNotNull(evalContext.getBeanResolver()); TypeConverter typeConverter = evalContext.getTypeConverter(); assertNotNull(typeConverter); + assertNotSame(DefaultConversionService.getSharedInstance(), + TestUtils.getPropertyValue(typeConverter, "conversionService")); assertSame(context.getBean(IntegrationUtils.INTEGRATION_CONVERSION_SERVICE_BEAN_NAME), TestUtils.getPropertyValue(typeConverter, "conversionService")); } @@ -88,5 +95,7 @@ public class ExpressionUtilsTests { assertNull(evalContext.getBeanResolver()); TypeConverter typeConverter = evalContext.getTypeConverter(); assertNotNull(typeConverter); + assertSame(DefaultConversionService.getSharedInstance(), + TestUtils.getPropertyValue(typeConverter, "conversionService")); } }