diff --git a/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/config/AmqpChannelParserTests.java b/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/config/AmqpChannelParserTests.java index 2296355228..2d7f72fc61 100644 --- a/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/config/AmqpChannelParserTests.java +++ b/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/config/AmqpChannelParserTests.java @@ -26,7 +26,7 @@ import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; -import org.springframework.integration.context.IntegrationContextUtils; +import org.springframework.integration.support.utils.IntegrationUtils; import org.springframework.integration.test.util.TestUtils; import org.springframework.messaging.MessageChannel; import org.springframework.messaging.support.ChannelInterceptorAdapter; @@ -54,7 +54,7 @@ public class AmqpChannelParserTests { assertEquals(Integer.MAX_VALUE, TestUtils.getPropertyValue( TestUtils.getPropertyValue(channel, "dispatcher"), "maxSubscribers", Integer.class).intValue()); channel = context.getBean("pubSub", MessageChannel.class); - Object mbf = context.getBean(IntegrationContextUtils.INTEGRATION_MESSAGE_BUILDER_FACTORY_BEAN_NAME); + Object mbf = context.getBean(IntegrationUtils.INTEGRATION_MESSAGE_BUILDER_FACTORY_BEAN_NAME); assertSame(mbf, TestUtils.getPropertyValue(channel, "dispatcher.messageBuilderFactory")); assertSame(mbf, TestUtils.getPropertyValue(channel, "container.messageListener.messageBuilderFactory")); } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/aggregator/AbstractAggregatingMessageGroupProcessor.java b/spring-integration-core/src/main/java/org/springframework/integration/aggregator/AbstractAggregatingMessageGroupProcessor.java index ed5fefea55..660a666ae7 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/aggregator/AbstractAggregatingMessageGroupProcessor.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/aggregator/AbstractAggregatingMessageGroupProcessor.java @@ -25,11 +25,11 @@ import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactoryAware; import org.springframework.integration.IntegrationMessageHeaderAccessor; -import org.springframework.integration.context.IntegrationContextUtils; import org.springframework.integration.store.MessageGroup; import org.springframework.integration.support.AbstractIntegrationMessageBuilder; import org.springframework.integration.support.DefaultMessageBuilderFactory; import org.springframework.integration.support.MessageBuilderFactory; +import org.springframework.integration.support.utils.IntegrationUtils; import org.springframework.messaging.Message; import org.springframework.messaging.MessageHeaders; import org.springframework.util.Assert; @@ -52,7 +52,7 @@ public abstract class AbstractAggregatingMessageGroupProcessor implements Messag @Override public void setBeanFactory(BeanFactory beanFactory) throws BeansException { - this.messageBuilderFactory = IntegrationContextUtils.getMessageBuilderFactory(beanFactory); + this.messageBuilderFactory = IntegrationUtils.getMessageBuilderFactory(beanFactory); } @Override diff --git a/spring-integration-core/src/main/java/org/springframework/integration/aop/MessagePublishingInterceptor.java b/spring-integration-core/src/main/java/org/springframework/integration/aop/MessagePublishingInterceptor.java index 1d3b1fb9d3..c0bf07576a 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/aop/MessagePublishingInterceptor.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/aop/MessagePublishingInterceptor.java @@ -36,12 +36,12 @@ import org.springframework.expression.ParseException; import org.springframework.expression.spel.SpelParserConfiguration; import org.springframework.expression.spel.standard.SpelExpressionParser; import org.springframework.expression.spel.support.StandardEvaluationContext; -import org.springframework.integration.context.IntegrationContextUtils; import org.springframework.integration.core.MessagingTemplate; import org.springframework.integration.expression.ExpressionUtils; import org.springframework.integration.support.AbstractIntegrationMessageBuilder; import org.springframework.integration.support.DefaultMessageBuilderFactory; import org.springframework.integration.support.MessageBuilderFactory; +import org.springframework.integration.support.utils.IntegrationUtils; import org.springframework.messaging.Message; import org.springframework.messaging.MessageChannel; import org.springframework.messaging.core.DestinationResolver; @@ -97,7 +97,7 @@ public class MessagePublishingInterceptor implements MethodInterceptor, BeanFact public void setBeanFactory(BeanFactory beanFactory) throws BeansException { this.beanFactory = beanFactory; this.messagingTemplate.setBeanFactory(beanFactory); - this.messageBuilderFactory = IntegrationContextUtils.getMessageBuilderFactory(beanFactory); + this.messageBuilderFactory = IntegrationUtils.getMessageBuilderFactory(beanFactory); } public final Object invoke(final MethodInvocation invocation) throws Throwable { diff --git a/spring-integration-core/src/main/java/org/springframework/integration/config/IntegrationRegistrar.java b/spring-integration-core/src/main/java/org/springframework/integration/config/IntegrationRegistrar.java index 8741e141f3..7fb766eaf0 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/config/IntegrationRegistrar.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/config/IntegrationRegistrar.java @@ -49,6 +49,7 @@ import org.springframework.integration.context.IntegrationProperties; import org.springframework.integration.expression.IntegrationEvaluationContextAwareBeanPostProcessor; import org.springframework.integration.support.DefaultMessageBuilderFactory; import org.springframework.integration.support.converter.DefaultDatatypeChannelMessageConverter; +import org.springframework.integration.support.utils.IntegrationUtils; import org.springframework.util.ClassUtils; /** @@ -359,17 +360,17 @@ public class IntegrationRegistrar implements ImportBeanDefinitionRegistrar, Bean boolean alreadyRegistered = false; if (registry instanceof ListableBeanFactory) { alreadyRegistered = ((ListableBeanFactory) registry) - .containsBean(IntegrationContextUtils.INTEGRATION_MESSAGE_BUILDER_FACTORY_BEAN_NAME); + .containsBean(IntegrationUtils.INTEGRATION_MESSAGE_BUILDER_FACTORY_BEAN_NAME); } else { alreadyRegistered = registry - .isBeanNameInUse(IntegrationContextUtils.INTEGRATION_MESSAGE_BUILDER_FACTORY_BEAN_NAME); + .isBeanNameInUse(IntegrationUtils.INTEGRATION_MESSAGE_BUILDER_FACTORY_BEAN_NAME); } if (!alreadyRegistered) { BeanDefinitionBuilder mbfBuilder = BeanDefinitionBuilder .genericBeanDefinition(DefaultMessageBuilderFactory.class); registry.registerBeanDefinition( - IntegrationContextUtils.INTEGRATION_MESSAGE_BUILDER_FACTORY_BEAN_NAME, + IntegrationUtils.INTEGRATION_MESSAGE_BUILDER_FACTORY_BEAN_NAME, mbfBuilder.getBeanDefinition()); } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/context/IntegrationContextUtils.java b/spring-integration-core/src/main/java/org/springframework/integration/context/IntegrationContextUtils.java index da2dc15cc6..9c549fa0c7 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/context/IntegrationContextUtils.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/context/IntegrationContextUtils.java @@ -18,15 +18,10 @@ package org.springframework.integration.context; import java.util.Properties; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - import org.springframework.beans.factory.BeanFactory; import org.springframework.expression.spel.support.StandardEvaluationContext; import org.springframework.integration.config.IntegrationConfigUtils; import org.springframework.integration.metadata.MetadataStore; -import org.springframework.integration.support.DefaultMessageBuilderFactory; -import org.springframework.integration.support.MessageBuilderFactory; import org.springframework.messaging.MessageChannel; import org.springframework.scheduling.TaskScheduler; import org.springframework.util.Assert; @@ -41,8 +36,6 @@ import org.springframework.util.Assert; */ public abstract class IntegrationContextUtils { - private static final Log logger = LogFactory.getLog(IntegrationContextUtils.class); - public static final String TASK_SCHEDULER_BEAN_NAME = "taskScheduler"; public static final String ERROR_CHANNEL_BEAN_NAME = "errorChannel"; @@ -79,15 +72,8 @@ public abstract class IntegrationContextUtils { public static final String INTEGRATION_FIXED_SUBSCRIBER_CHANNEL_BPP_BEAN_NAME = "fixedSubscriberChannelBeanFactoryPostProcessor"; - public static final String INTEGRATION_MESSAGE_BUILDER_FACTORY_BEAN_NAME = "messageBuilderFactory"; - public static final String GLOBAL_CHANNEL_INTERCEPTOR_PROCESSOR_BEAN_NAME = "globalChannelInterceptorProcessor"; - /** - * Should be set to TRUE on CI plans and framework developer systems. - */ - public static final boolean fatalWhenNoBeanFactory = Boolean.valueOf(System.getenv("SI_FATAL_WHEN_NO_BEANFACTORY")); - /** * @param beanFactory BeanFactory for lookup, must not be null. * @return The {@link MetadataStore} bean whose name is "metadataStore". @@ -162,41 +148,4 @@ public abstract class IntegrationContextUtils { return properties; } - /** - * Returns the context-wide `messageBuilderFactory` bean from the beanFactory, - * or a {@link DefaultMessageBuilderFactory} if not found or the beanFactory is null. - * @param beanFactory The bean factory. - * @return The message builder factory. - */ - public static MessageBuilderFactory getMessageBuilderFactory(BeanFactory beanFactory) { - MessageBuilderFactory messageBuilderFactory = null; - if (beanFactory != null) { - try { - messageBuilderFactory = beanFactory.getBean( - IntegrationContextUtils.INTEGRATION_MESSAGE_BUILDER_FACTORY_BEAN_NAME, MessageBuilderFactory.class); - } - catch (Exception e) { - if (logger.isDebugEnabled()) { - logger.debug("No MessageBuilderFactory with name '" - + IntegrationContextUtils.INTEGRATION_MESSAGE_BUILDER_FACTORY_BEAN_NAME - + "' found: " + e.getMessage() - + ", using default."); - } - } - } - else { - if (logger.isDebugEnabled()) { - logger.debug("No 'beanFactory' supplied; cannot find MessageBuilderFactory" - + ", using default."); - } - if (fatalWhenNoBeanFactory) { - throw new RuntimeException("All Message creators need a BeanFactory"); - } - } - if (messageBuilderFactory == null) { - messageBuilderFactory = new DefaultMessageBuilderFactory(); - } - return messageBuilderFactory; - } - } 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 bd47d1c691..04bffc9158 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 @@ -128,7 +128,7 @@ public abstract class IntegrationObjectSupport implements BeanNameAware, NamedCo public final void afterPropertiesSet() { try { if (this.messageBuilderFactory == null) { - this.messageBuilderFactory = IntegrationContextUtils.getMessageBuilderFactory(this.beanFactory); + this.messageBuilderFactory = IntegrationUtils.getMessageBuilderFactory(this.beanFactory); } this.onInit(); } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/dispatcher/BroadcastingDispatcher.java b/spring-integration-core/src/main/java/org/springframework/integration/dispatcher/BroadcastingDispatcher.java index 0476ec1076..ce5fc0951a 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/dispatcher/BroadcastingDispatcher.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/dispatcher/BroadcastingDispatcher.java @@ -23,9 +23,9 @@ import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactoryAware; import org.springframework.integration.MessageDispatchingException; -import org.springframework.integration.context.IntegrationContextUtils; import org.springframework.integration.support.DefaultMessageBuilderFactory; import org.springframework.integration.support.MessageBuilderFactory; +import org.springframework.integration.support.utils.IntegrationUtils; import org.springframework.messaging.Message; import org.springframework.messaging.MessageHandler; import org.springframework.messaging.MessagingException; @@ -114,7 +114,7 @@ public class BroadcastingDispatcher extends AbstractDispatcher implements BeanFa @Override public void setBeanFactory(BeanFactory beanFactory) throws BeansException { - this.messageBuilderFactory = IntegrationContextUtils.getMessageBuilderFactory(beanFactory); + this.messageBuilderFactory = IntegrationUtils.getMessageBuilderFactory(beanFactory); } @Override diff --git a/spring-integration-core/src/main/java/org/springframework/integration/store/AbstractMessageGroupStore.java b/spring-integration-core/src/main/java/org/springframework/integration/store/AbstractMessageGroupStore.java index 9cc44c90f5..9a2f573c11 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/store/AbstractMessageGroupStore.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/store/AbstractMessageGroupStore.java @@ -1,158 +1,158 @@ -/* - * Copyright 2002-2014 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package org.springframework.integration.store; - -import java.util.Collection; -import java.util.LinkedHashSet; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.springframework.beans.factory.BeanFactory; -import org.springframework.beans.factory.BeanFactoryAware; -import org.springframework.integration.context.IntegrationContextUtils; -import org.springframework.integration.support.DefaultMessageBuilderFactory; -import org.springframework.integration.support.MessageBuilderFactory; -import org.springframework.jmx.export.annotation.ManagedAttribute; -import org.springframework.jmx.export.annotation.ManagedResource; - -/** - * @author Dave Syer - * @author Oleg Zhurakousky - * @author Gary Russell - * - * @since 2.0 - * - */ -@ManagedResource -public abstract class AbstractMessageGroupStore implements MessageGroupStore, Iterable, - BeanFactoryAware { - - protected final Log logger = LogFactory.getLog(getClass()); - - private final Collection expiryCallbacks = new LinkedHashSet(); - - private volatile boolean timeoutOnIdle; - - private volatile BeanFactory beanFactory; - - private volatile MessageBuilderFactory messageBuilderFactory = new DefaultMessageBuilderFactory(); - - public AbstractMessageGroupStore() { - super(); - } - - @Override - public final void setBeanFactory(BeanFactory beanFactory) { - this.beanFactory = beanFactory; - this.messageBuilderFactory = IntegrationContextUtils.getMessageBuilderFactory(this.beanFactory); - } - - protected MessageBuilderFactory getMessageBuilderFactory() { - return messageBuilderFactory; - } - - /** - * 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 expiryCallbacks) { - for (MessageGroupCallback callback : expiryCallbacks) { - 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 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; - for (MessageGroup group : this) { - - long timestamp = group.getTimestamp(); - if (this.isTimeoutOnIdle() && group.getLastModified() > 0) { - timestamp = group.getLastModified(); - } - - if (timestamp <= threshold) { - count++; - expire(group); - } - } - return count; - } - - @Override - @ManagedAttribute - public int getMessageCountForAllMessageGroups() { - int count = 0; - for (MessageGroup group : this) { - count += group.size(); - } - return count; - } - - @Override - @ManagedAttribute - public int getMessageGroupCount() { - int count = 0; - for (@SuppressWarnings("unused") MessageGroup group : this) { - count ++; - } - return count; - } - - private void expire(MessageGroup group) { - - RuntimeException exception = null; - - for (MessageGroupCallback callback : expiryCallbacks) { - try { - callback.execute(this, group); - } catch (RuntimeException e) { - if (exception == null) { - exception = e; - } - logger.error("Exception in expiry callback", e); - } - } - - if (exception != null) { - throw exception; - } - } - -} +/* + * Copyright 2002-2014 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package org.springframework.integration.store; + +import java.util.Collection; +import java.util.LinkedHashSet; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import org.springframework.beans.factory.BeanFactory; +import org.springframework.beans.factory.BeanFactoryAware; +import org.springframework.integration.support.DefaultMessageBuilderFactory; +import org.springframework.integration.support.MessageBuilderFactory; +import org.springframework.integration.support.utils.IntegrationUtils; +import org.springframework.jmx.export.annotation.ManagedAttribute; +import org.springframework.jmx.export.annotation.ManagedResource; + +/** + * @author Dave Syer + * @author Oleg Zhurakousky + * @author Gary Russell + * + * @since 2.0 + * + */ +@ManagedResource +public abstract class AbstractMessageGroupStore implements MessageGroupStore, Iterable, + BeanFactoryAware { + + protected final Log logger = LogFactory.getLog(getClass()); + + private final Collection expiryCallbacks = new LinkedHashSet(); + + private volatile boolean timeoutOnIdle; + + private volatile BeanFactory beanFactory; + + private volatile MessageBuilderFactory messageBuilderFactory = new DefaultMessageBuilderFactory(); + + public AbstractMessageGroupStore() { + super(); + } + + @Override + public final void setBeanFactory(BeanFactory beanFactory) { + this.beanFactory = beanFactory; + this.messageBuilderFactory = IntegrationUtils.getMessageBuilderFactory(this.beanFactory); + } + + protected MessageBuilderFactory getMessageBuilderFactory() { + return messageBuilderFactory; + } + + /** + * 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 expiryCallbacks) { + for (MessageGroupCallback callback : expiryCallbacks) { + 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 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; + for (MessageGroup group : this) { + + long timestamp = group.getTimestamp(); + if (this.isTimeoutOnIdle() && group.getLastModified() > 0) { + timestamp = group.getLastModified(); + } + + if (timestamp <= threshold) { + count++; + expire(group); + } + } + return count; + } + + @Override + @ManagedAttribute + public int getMessageCountForAllMessageGroups() { + int count = 0; + for (MessageGroup group : this) { + count += group.size(); + } + return count; + } + + @Override + @ManagedAttribute + public int getMessageGroupCount() { + int count = 0; + for (@SuppressWarnings("unused") MessageGroup group : this) { + count ++; + } + return count; + } + + private void expire(MessageGroup group) { + + RuntimeException exception = null; + + for (MessageGroupCallback callback : expiryCallbacks) { + try { + callback.execute(this, group); + } catch (RuntimeException e) { + if (exception == null) { + exception = e; + } + logger.error("Exception in expiry callback", e); + } + } + + if (exception != null) { + throw exception; + } + } + +} diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/converter/MapMessageConverter.java b/spring-integration-core/src/main/java/org/springframework/integration/support/converter/MapMessageConverter.java index 879220d31f..8cb7971ebe 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/converter/MapMessageConverter.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/converter/MapMessageConverter.java @@ -21,10 +21,10 @@ import java.util.Map; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactoryAware; -import org.springframework.integration.context.IntegrationContextUtils; import org.springframework.integration.support.AbstractIntegrationMessageBuilder; import org.springframework.integration.support.DefaultMessageBuilderFactory; import org.springframework.integration.support.MessageBuilderFactory; +import org.springframework.integration.support.utils.IntegrationUtils; import org.springframework.messaging.Message; import org.springframework.messaging.MessageHeaders; import org.springframework.messaging.converter.MessageConverter; @@ -50,7 +50,7 @@ public class MapMessageConverter implements MessageConverter, BeanFactoryAware { @Override public final void setBeanFactory(BeanFactory beanFactory) { this.beanFactory = beanFactory; - this.messageBuilderFactory = IntegrationContextUtils.getMessageBuilderFactory(this.beanFactory); + this.messageBuilderFactory = IntegrationUtils.getMessageBuilderFactory(this.beanFactory); } protected MessageBuilderFactory getMessageBuilderFactory() { diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/converter/SimpleMessageConverter.java b/spring-integration-core/src/main/java/org/springframework/integration/support/converter/SimpleMessageConverter.java index f5f7b97aa2..c835c30345 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/converter/SimpleMessageConverter.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/converter/SimpleMessageConverter.java @@ -19,11 +19,11 @@ package org.springframework.integration.support.converter; import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactoryAware; -import org.springframework.integration.context.IntegrationContextUtils; import org.springframework.integration.mapping.InboundMessageMapper; import org.springframework.integration.mapping.OutboundMessageMapper; import org.springframework.integration.support.DefaultMessageBuilderFactory; import org.springframework.integration.support.MessageBuilderFactory; +import org.springframework.integration.support.utils.IntegrationUtils; import org.springframework.messaging.Message; import org.springframework.messaging.MessageHeaders; import org.springframework.messaging.converter.MessageConversionException; @@ -73,7 +73,7 @@ public class SimpleMessageConverter implements MessageConverter, BeanFactoryAwar @Override public void setBeanFactory(BeanFactory beanFactory) throws BeansException { - this.messageBuilderFactory = IntegrationContextUtils.getMessageBuilderFactory(beanFactory); + this.messageBuilderFactory = IntegrationUtils.getMessageBuilderFactory(beanFactory); } @Override diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/json/AbstractJacksonJsonMessageParser.java b/spring-integration-core/src/main/java/org/springframework/integration/support/json/AbstractJacksonJsonMessageParser.java index c27774e1a8..526bc6a9fa 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/json/AbstractJacksonJsonMessageParser.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/json/AbstractJacksonJsonMessageParser.java @@ -21,9 +21,9 @@ import java.lang.reflect.Type; import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactoryAware; -import org.springframework.integration.context.IntegrationContextUtils; import org.springframework.integration.support.DefaultMessageBuilderFactory; import org.springframework.integration.support.MessageBuilderFactory; +import org.springframework.integration.support.utils.IntegrationUtils; import org.springframework.messaging.Message; /** @@ -48,7 +48,7 @@ abstract class AbstractJacksonJsonMessageParser

implements JsonInboundMessage @Override public void setBeanFactory(BeanFactory beanFactory) throws BeansException { - this.messageBuilderFactory = IntegrationContextUtils.getMessageBuilderFactory(beanFactory); + this.messageBuilderFactory = IntegrationUtils.getMessageBuilderFactory(beanFactory); } protected MessageBuilderFactory getMessageBuilderFactory() { diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/utils/IntegrationUtils.java b/spring-integration-core/src/main/java/org/springframework/integration/support/utils/IntegrationUtils.java index 07a8a195b2..f349e33133 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/utils/IntegrationUtils.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/utils/IntegrationUtils.java @@ -15,8 +15,13 @@ */ package org.springframework.integration.support.utils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + import org.springframework.beans.factory.BeanFactory; import org.springframework.core.convert.ConversionService; +import org.springframework.integration.support.DefaultMessageBuilderFactory; +import org.springframework.integration.support.MessageBuilderFactory; import org.springframework.util.Assert; /** @@ -28,8 +33,18 @@ import org.springframework.util.Assert; */ public class IntegrationUtils { + private static final Log logger = LogFactory.getLog(IntegrationUtils.class); + public static final String INTEGRATION_CONVERSION_SERVICE_BEAN_NAME = "integrationConversionService"; + public static final String INTEGRATION_MESSAGE_BUILDER_FACTORY_BEAN_NAME = "messageBuilderFactory"; + + + /** + * Should be set to TRUE on CI plans and framework developer systems. + */ + public static final boolean fatalWhenNoBeanFactory = Boolean.valueOf(System.getenv("SI_FATAL_WHEN_NO_BEANFACTORY")); + /** * @param beanFactory BeanFactory for lookup, must not be null. * @return The {@link ConversionService} bean whose name is "integrationConversionService" if available. @@ -38,6 +53,43 @@ public class IntegrationUtils { return getBeanOfType(beanFactory, INTEGRATION_CONVERSION_SERVICE_BEAN_NAME, ConversionService.class); } + /** + * Returns the context-wide `messageBuilderFactory` bean from the beanFactory, + * or a {@link DefaultMessageBuilderFactory} if not found or the beanFactory is null. + * @param beanFactory The bean factory. + * @return The message builder factory. + */ + public static MessageBuilderFactory getMessageBuilderFactory(BeanFactory beanFactory) { + MessageBuilderFactory messageBuilderFactory = null; + if (beanFactory != null) { + try { + messageBuilderFactory = beanFactory.getBean( + INTEGRATION_MESSAGE_BUILDER_FACTORY_BEAN_NAME, MessageBuilderFactory.class); + } + catch (Exception e) { + if (logger.isDebugEnabled()) { + logger.debug("No MessageBuilderFactory with name '" + + INTEGRATION_MESSAGE_BUILDER_FACTORY_BEAN_NAME + + "' found: " + e.getMessage() + + ", using default."); + } + } + } + else { + if (logger.isDebugEnabled()) { + logger.debug("No 'beanFactory' supplied; cannot find MessageBuilderFactory" + + ", using default."); + } + if (fatalWhenNoBeanFactory) { + throw new RuntimeException("All Message creators need a BeanFactory"); + } + } + if (messageBuilderFactory == null) { + messageBuilderFactory = new DefaultMessageBuilderFactory(); + } + return messageBuilderFactory; + } + private static T getBeanOfType(BeanFactory beanFactory, String beanName, Class type) { Assert.notNull(beanFactory, "BeanFactory must not be null"); if (!beanFactory.containsBean(beanName)) { diff --git a/spring-integration-core/src/main/java/org/springframework/integration/transformer/AbstractMessageProcessingTransformer.java b/spring-integration-core/src/main/java/org/springframework/integration/transformer/AbstractMessageProcessingTransformer.java index 27a4acad2b..3ea4796d75 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/transformer/AbstractMessageProcessingTransformer.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/transformer/AbstractMessageProcessingTransformer.java @@ -19,7 +19,6 @@ package org.springframework.integration.transformer; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactoryAware; import org.springframework.core.convert.ConversionService; -import org.springframework.integration.context.IntegrationContextUtils; import org.springframework.integration.handler.AbstractMessageProcessor; import org.springframework.integration.handler.MessageProcessor; import org.springframework.integration.support.DefaultMessageBuilderFactory; @@ -57,7 +56,7 @@ public abstract class AbstractMessageProcessingTransformer implements Transforme if (conversionService != null && this.messageProcessor instanceof AbstractMessageProcessor) { ((AbstractMessageProcessor) this.messageProcessor).setConversionService(conversionService); } - this.messageBuilderFactory = IntegrationContextUtils.getMessageBuilderFactory(beanFactory); + this.messageBuilderFactory = IntegrationUtils.getMessageBuilderFactory(beanFactory); } @Override diff --git a/spring-integration-core/src/main/java/org/springframework/integration/util/AbstractExpressionEvaluator.java b/spring-integration-core/src/main/java/org/springframework/integration/util/AbstractExpressionEvaluator.java index 330d3c0b95..7b1ff32037 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/util/AbstractExpressionEvaluator.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/util/AbstractExpressionEvaluator.java @@ -26,10 +26,10 @@ import org.springframework.expression.Expression; import org.springframework.expression.ExpressionParser; import org.springframework.expression.spel.standard.SpelExpressionParser; import org.springframework.expression.spel.support.StandardEvaluationContext; -import org.springframework.integration.context.IntegrationContextUtils; import org.springframework.integration.expression.ExpressionUtils; import org.springframework.integration.support.DefaultMessageBuilderFactory; import org.springframework.integration.support.MessageBuilderFactory; +import org.springframework.integration.support.utils.IntegrationUtils; import org.springframework.messaging.Message; import org.springframework.messaging.MessageHandlingException; @@ -67,7 +67,7 @@ public abstract class AbstractExpressionEvaluator implements BeanFactoryAware, I if (this.evaluationContext != null && this.evaluationContext.getBeanResolver() == null) { this.evaluationContext.setBeanResolver(new BeanFactoryResolver(beanFactory)); } - this.messageBuilderFactory = IntegrationContextUtils.getMessageBuilderFactory(beanFactory); + this.messageBuilderFactory = IntegrationUtils.getMessageBuilderFactory(beanFactory); } } @@ -88,7 +88,7 @@ public abstract class AbstractExpressionEvaluator implements BeanFactoryAware, I public void afterPropertiesSet() throws Exception { getEvaluationContext(); if (this.messageBuilderFactory == null) { - this.messageBuilderFactory = IntegrationContextUtils.getMessageBuilderFactory(this.beanFactory); + this.messageBuilderFactory = IntegrationUtils.getMessageBuilderFactory(this.beanFactory); } } diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/AggregatorParserTests.java b/spring-integration-core/src/test/java/org/springframework/integration/config/AggregatorParserTests.java index e25aad5a70..43aa1916e1 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/config/AggregatorParserTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/config/AggregatorParserTests.java @@ -45,9 +45,9 @@ import org.springframework.integration.aggregator.ExpressionEvaluatingReleaseStr import org.springframework.integration.aggregator.MethodInvokingMessageGroupProcessor; import org.springframework.integration.aggregator.MethodInvokingReleaseStrategy; import org.springframework.integration.aggregator.ReleaseStrategy; -import org.springframework.integration.context.IntegrationContextUtils; import org.springframework.integration.endpoint.EventDrivenConsumer; import org.springframework.integration.support.MessageBuilder; +import org.springframework.integration.support.utils.IntegrationUtils; import org.springframework.integration.test.util.TestUtils; import org.springframework.messaging.Message; import org.springframework.messaging.MessageChannel; @@ -90,7 +90,7 @@ public class AggregatorParserTests { .size()); Message aggregatedMessage = aggregatorBean.getAggregatedMessages().get("id1"); assertEquals("The aggregated message payload is not correct", "123456789", aggregatedMessage.getPayload()); - Object mbf = context.getBean(IntegrationContextUtils.INTEGRATION_MESSAGE_BUILDER_FACTORY_BEAN_NAME); + Object mbf = context.getBean(IntegrationUtils.INTEGRATION_MESSAGE_BUILDER_FACTORY_BEAN_NAME); Object handler = context.getBean("aggregatorWithReference.handler"); assertSame(mbf, TestUtils.getPropertyValue(handler, "outputProcessor.messageBuilderFactory")); assertSame(mbf, TestUtils.getPropertyValue(handler, "outputProcessor.processor.messageBuilderFactory")); @@ -117,7 +117,7 @@ public class AggregatorParserTests { } assertEquals("The aggregated message payload is not correct", "[123]", aggregatedMessage.get().getPayload() .toString()); - Object mbf = context.getBean(IntegrationContextUtils.INTEGRATION_MESSAGE_BUILDER_FACTORY_BEAN_NAME); + Object mbf = context.getBean(IntegrationUtils.INTEGRATION_MESSAGE_BUILDER_FACTORY_BEAN_NAME); Object handler = context.getBean("aggregatorWithExpressions.handler"); assertSame(mbf, TestUtils.getPropertyValue(handler, "outputProcessor.messageBuilderFactory")); assertSame(mbf, TestUtils.getPropertyValue(handler, "outputProcessor.processor.messageBuilderFactory")); @@ -169,7 +169,7 @@ public class AggregatorParserTests { PollableChannel outputChannel = (PollableChannel) context.getBean("outputChannel"); Message response = outputChannel.receive(10); Assert.assertEquals(6l, response.getPayload()); - Object mbf = context.getBean(IntegrationContextUtils.INTEGRATION_MESSAGE_BUILDER_FACTORY_BEAN_NAME); + Object mbf = context.getBean(IntegrationUtils.INTEGRATION_MESSAGE_BUILDER_FACTORY_BEAN_NAME); Object handler = context.getBean("aggregatorWithReferenceAndMethod.handler"); assertSame(mbf, TestUtils.getPropertyValue(handler, "outputProcessor.messageBuilderFactory")); assertSame(mbf, TestUtils.getPropertyValue(handler, "outputProcessor.processor.messageBuilderFactory")); @@ -245,7 +245,7 @@ public class AggregatorParserTests { EventDrivenConsumer aggregatorConsumer = (EventDrivenConsumer) context.getBean("aggregatorWithExpressionsAndPojoAggregator"); AggregatingMessageHandler aggregatingMessageHandler = (AggregatingMessageHandler) TestUtils.getPropertyValue(aggregatorConsumer, "handler"); MethodInvokingMessageGroupProcessor messageGroupProcessor = (MethodInvokingMessageGroupProcessor) TestUtils.getPropertyValue(aggregatingMessageHandler, "outputProcessor"); - Object mbf = context.getBean(IntegrationContextUtils.INTEGRATION_MESSAGE_BUILDER_FACTORY_BEAN_NAME); + Object mbf = context.getBean(IntegrationUtils.INTEGRATION_MESSAGE_BUILDER_FACTORY_BEAN_NAME); assertSame(mbf, TestUtils.getPropertyValue(messageGroupProcessor, "messageBuilderFactory")); Object messageGroupProcessorTargetObject = TestUtils.getPropertyValue(messageGroupProcessor, "processor.delegate.targetObject"); assertSame(context.getBean("aggregatorBean"), messageGroupProcessorTargetObject); diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/PublishSubscribeChannelParserTests.java b/spring-integration-core/src/test/java/org/springframework/integration/config/PublishSubscribeChannelParserTests.java index bfc72e5dd1..d0c4864fab 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/config/PublishSubscribeChannelParserTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/config/PublishSubscribeChannelParserTests.java @@ -30,8 +30,8 @@ import org.junit.Test; import org.springframework.beans.DirectFieldAccessor; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.integration.channel.PublishSubscribeChannel; -import org.springframework.integration.context.IntegrationContextUtils; import org.springframework.integration.dispatcher.BroadcastingDispatcher; +import org.springframework.integration.support.utils.IntegrationUtils; import org.springframework.integration.util.ErrorHandlingTaskExecutor; import org.springframework.util.ErrorHandler; @@ -54,7 +54,7 @@ public class PublishSubscribeChannelParserTests { assertNull(dispatcherAccessor.getPropertyValue("executor")); assertFalse((Boolean) dispatcherAccessor.getPropertyValue("ignoreFailures")); assertFalse((Boolean) dispatcherAccessor.getPropertyValue("applySequence")); - Object mbf = context.getBean(IntegrationContextUtils.INTEGRATION_MESSAGE_BUILDER_FACTORY_BEAN_NAME); + Object mbf = context.getBean(IntegrationUtils.INTEGRATION_MESSAGE_BUILDER_FACTORY_BEAN_NAME); assertSame(mbf, dispatcherAccessor.getPropertyValue("messageBuilderFactory")); context.close(); } diff --git a/spring-integration-core/src/test/java/org/springframework/integration/gateway/GatewayInterfaceTests.java b/spring-integration-core/src/test/java/org/springframework/integration/gateway/GatewayInterfaceTests.java index 1478c53414..52c3413ae6 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/gateway/GatewayInterfaceTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/gateway/GatewayInterfaceTests.java @@ -42,8 +42,8 @@ import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.integration.annotation.Gateway; import org.springframework.integration.annotation.Header; import org.springframework.integration.channel.DirectChannel; -import org.springframework.integration.context.IntegrationContextUtils; import org.springframework.integration.support.MessageBuilder; +import org.springframework.integration.support.utils.IntegrationUtils; import org.springframework.integration.test.util.TestUtils; import org.springframework.messaging.Message; import org.springframework.messaging.MessageHandler; @@ -81,7 +81,7 @@ public class GatewayInterfaceTests { bar.foo("hello"); assertTrue(called.get()); Map gateways = TestUtils.getPropertyValue(ac.getBean("&sampleGateway"), "gatewayMap", Map.class); - Object mbf = ac.getBean(IntegrationContextUtils.INTEGRATION_MESSAGE_BUILDER_FACTORY_BEAN_NAME); + Object mbf = ac.getBean(IntegrationUtils.INTEGRATION_MESSAGE_BUILDER_FACTORY_BEAN_NAME); assertSame(mbf, TestUtils.getPropertyValue(gateways.values().iterator().next(), "messageConverter.messageBuilderFactory")); ac.close(); diff --git a/spring-integration-file/src/main/java/org/springframework/integration/file/transformer/AbstractFilePayloadTransformer.java b/spring-integration-file/src/main/java/org/springframework/integration/file/transformer/AbstractFilePayloadTransformer.java index 42629dc3b1..f701fa6733 100644 --- a/spring-integration-file/src/main/java/org/springframework/integration/file/transformer/AbstractFilePayloadTransformer.java +++ b/spring-integration-file/src/main/java/org/springframework/integration/file/transformer/AbstractFilePayloadTransformer.java @@ -24,10 +24,10 @@ import org.apache.commons.logging.LogFactory; import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactoryAware; -import org.springframework.integration.context.IntegrationContextUtils; import org.springframework.integration.file.FileHeaders; import org.springframework.integration.support.DefaultMessageBuilderFactory; import org.springframework.integration.support.MessageBuilderFactory; +import org.springframework.integration.support.utils.IntegrationUtils; import org.springframework.integration.transformer.Transformer; import org.springframework.messaging.Message; import org.springframework.messaging.MessagingException; @@ -58,7 +58,7 @@ public abstract class AbstractFilePayloadTransformer implements Transformer, @Override public void setBeanFactory(BeanFactory beanFactory) throws BeansException { - this.messageBuilderFactory = IntegrationContextUtils.getMessageBuilderFactory(beanFactory); + this.messageBuilderFactory = IntegrationUtils.getMessageBuilderFactory(beanFactory); } @Override diff --git a/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpMessageMapper.java b/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpMessageMapper.java index bdaab3f6b2..687a3971d0 100644 --- a/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpMessageMapper.java +++ b/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpMessageMapper.java @@ -24,13 +24,13 @@ import org.apache.commons.logging.LogFactory; import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactoryAware; -import org.springframework.integration.context.IntegrationContextUtils; import org.springframework.integration.ip.IpHeaders; import org.springframework.integration.mapping.InboundMessageMapper; import org.springframework.integration.mapping.OutboundMessageMapper; import org.springframework.integration.support.AbstractIntegrationMessageBuilder; import org.springframework.integration.support.DefaultMessageBuilderFactory; import org.springframework.integration.support.MessageBuilderFactory; +import org.springframework.integration.support.utils.IntegrationUtils; import org.springframework.messaging.Message; import org.springframework.messaging.MessageHandlingException; @@ -88,7 +88,7 @@ public class TcpMessageMapper implements @Override public void setBeanFactory(BeanFactory beanFactory) throws BeansException { - this.messageBuilderFactory = IntegrationContextUtils.getMessageBuilderFactory(beanFactory); + this.messageBuilderFactory = IntegrationUtils.getMessageBuilderFactory(beanFactory); } protected MessageBuilderFactory getMessageBuilderFactory() { diff --git a/spring-integration-ip/src/main/java/org/springframework/integration/ip/udp/DatagramPacketMessageMapper.java b/spring-integration-ip/src/main/java/org/springframework/integration/ip/udp/DatagramPacketMessageMapper.java index 0796990cda..4bfd2d1c06 100644 --- a/spring-integration-ip/src/main/java/org/springframework/integration/ip/udp/DatagramPacketMessageMapper.java +++ b/spring-integration-ip/src/main/java/org/springframework/integration/ip/udp/DatagramPacketMessageMapper.java @@ -26,7 +26,6 @@ import java.util.regex.Pattern; import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactoryAware; -import org.springframework.integration.context.IntegrationContextUtils; import org.springframework.integration.ip.IpHeaders; import org.springframework.integration.ip.util.RegexUtils; import org.springframework.integration.mapping.InboundMessageMapper; @@ -34,6 +33,7 @@ import org.springframework.integration.mapping.MessageMappingException; import org.springframework.integration.mapping.OutboundMessageMapper; import org.springframework.integration.support.DefaultMessageBuilderFactory; import org.springframework.integration.support.MessageBuilderFactory; +import org.springframework.integration.support.utils.IntegrationUtils; import org.springframework.messaging.Message; import org.springframework.messaging.MessageHandlingException; import org.springframework.messaging.MessageHeaders; @@ -107,7 +107,7 @@ public class DatagramPacketMessageMapper implements InboundMessageMapper implements Transformer, @Override public final void setBeanFactory(BeanFactory beanFactory) { this.beanFactory = beanFactory; - this.messageBuilderFactory = IntegrationContextUtils.getMessageBuilderFactory(this.beanFactory); + this.messageBuilderFactory = IntegrationUtils.getMessageBuilderFactory(this.beanFactory); } protected MessageBuilderFactory getMessageBuilderFactory() { diff --git a/spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/store/AbstractConfigurableMongoDbMessageStore.java b/spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/store/AbstractConfigurableMongoDbMessageStore.java index 47629c71f8..e76209121c 100644 --- a/spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/store/AbstractConfigurableMongoDbMessageStore.java +++ b/spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/store/AbstractConfigurableMongoDbMessageStore.java @@ -23,8 +23,6 @@ import java.util.Map; import java.util.Set; import java.util.UUID; -import com.mongodb.DB; -import com.mongodb.MongoException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -52,14 +50,17 @@ import org.springframework.data.mongodb.core.query.Criteria; import org.springframework.data.mongodb.core.query.Order; import org.springframework.data.mongodb.core.query.Query; import org.springframework.data.mongodb.core.query.Update; -import org.springframework.integration.context.IntegrationContextUtils; import org.springframework.integration.store.BasicMessageGroupStore; import org.springframework.integration.support.DefaultMessageBuilderFactory; import org.springframework.integration.support.MessageBuilderFactory; +import org.springframework.integration.support.utils.IntegrationUtils; import org.springframework.messaging.Message; import org.springframework.messaging.MessageHeaders; import org.springframework.util.Assert; +import com.mongodb.DB; +import com.mongodb.MongoException; + /** * The abstract MongoDB {@link BasicMessageGroupStore} implementation to provide configuration for common options * for implementations of this class. @@ -121,7 +122,7 @@ public abstract class AbstractConfigurableMongoDbMessageStore implements BasicMe @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { this.applicationContext = applicationContext; - this.messageBuilderFactory = IntegrationContextUtils.getMessageBuilderFactory(this.applicationContext); + this.messageBuilderFactory = IntegrationUtils.getMessageBuilderFactory(this.applicationContext); } @Override diff --git a/spring-integration-mqtt/src/main/java/org/springframework/integration/mqtt/support/DefaultPahoMessageConverter.java b/spring-integration-mqtt/src/main/java/org/springframework/integration/mqtt/support/DefaultPahoMessageConverter.java index 7064eb6191..4064a5ee96 100644 --- a/spring-integration-mqtt/src/main/java/org/springframework/integration/mqtt/support/DefaultPahoMessageConverter.java +++ b/spring-integration-mqtt/src/main/java/org/springframework/integration/mqtt/support/DefaultPahoMessageConverter.java @@ -19,10 +19,10 @@ import org.eclipse.paho.client.mqttv3.MqttMessage; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactoryAware; -import org.springframework.integration.context.IntegrationContextUtils; import org.springframework.integration.support.AbstractIntegrationMessageBuilder; import org.springframework.integration.support.DefaultMessageBuilderFactory; import org.springframework.integration.support.MessageBuilderFactory; +import org.springframework.integration.support.utils.IntegrationUtils; import org.springframework.messaging.Message; import org.springframework.messaging.MessageHeaders; import org.springframework.messaging.converter.MessageConversionException; @@ -62,7 +62,7 @@ public class DefaultPahoMessageConverter implements MqttMessageConverter, BeanFa @Override public final void setBeanFactory(BeanFactory beanFactory) { this.beanFactory = beanFactory; - this.messageBuilderFactory = IntegrationContextUtils.getMessageBuilderFactory(this.beanFactory); + this.messageBuilderFactory = IntegrationUtils.getMessageBuilderFactory(this.beanFactory); } protected BeanFactory getBeanFactory() { diff --git a/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisChannelParserTests.java b/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisChannelParserTests.java index b8002c998e..ebff8401db 100644 --- a/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisChannelParserTests.java +++ b/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisChannelParserTests.java @@ -29,9 +29,9 @@ import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.data.redis.connection.RedisConnectionFactory; import org.springframework.data.redis.listener.RedisMessageListenerContainer; import org.springframework.data.redis.serializer.RedisSerializer; -import org.springframework.integration.context.IntegrationContextUtils; import org.springframework.integration.redis.rules.RedisAvailable; import org.springframework.integration.redis.rules.RedisAvailableTests; +import org.springframework.integration.support.utils.IntegrationUtils; import org.springframework.integration.test.util.TestUtils; import org.springframework.messaging.Message; import org.springframework.messaging.MessageHandler; @@ -62,7 +62,7 @@ public class RedisChannelParserTests extends RedisAvailableTests{ TestUtils.getPropertyValue(redisChannel, "dispatcher"), "maxSubscribers", Integer.class).intValue()); redisChannel = context.getBean("redisChannelWithSubLimit", SubscribableChannel.class); assertEquals(1, TestUtils.getPropertyValue(redisChannel, "dispatcher.maxSubscribers", Integer.class).intValue()); - Object mbf = context.getBean(IntegrationContextUtils.INTEGRATION_MESSAGE_BUILDER_FACTORY_BEAN_NAME); + Object mbf = context.getBean(IntegrationUtils.INTEGRATION_MESSAGE_BUILDER_FACTORY_BEAN_NAME); assertSame(mbf, TestUtils.getPropertyValue(redisChannel, "dispatcher.messageBuilderFactory")); assertSame(mbf, TestUtils.getPropertyValue(redisChannel, "messageBuilderFactory")); context.close(); diff --git a/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisInboundChannelAdapterParserTests.java b/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisInboundChannelAdapterParserTests.java index 8e724b8f50..0bf4c19220 100644 --- a/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisInboundChannelAdapterParserTests.java +++ b/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisInboundChannelAdapterParserTests.java @@ -33,11 +33,11 @@ import org.springframework.context.ApplicationContext; import org.springframework.data.redis.connection.RedisConnectionFactory; import org.springframework.data.redis.listener.RedisMessageListenerContainer; import org.springframework.integration.channel.QueueChannel; -import org.springframework.integration.context.IntegrationContextUtils; import org.springframework.integration.redis.inbound.RedisInboundChannelAdapter; import org.springframework.integration.redis.rules.RedisAvailable; import org.springframework.integration.redis.rules.RedisAvailableTests; import org.springframework.integration.support.converter.SimpleMessageConverter; +import org.springframework.integration.support.utils.IntegrationUtils; import org.springframework.integration.test.util.TestUtils; import org.springframework.messaging.Message; import org.springframework.messaging.MessageChannel; @@ -78,7 +78,7 @@ public class RedisInboundChannelAdapterParserTests extends RedisAvailableTests { Object bean = context.getBean("withoutSerializer.adapter"); assertNotNull(bean); assertNull(TestUtils.getPropertyValue(bean, "serializer")); - Object mbf = context.getBean(IntegrationContextUtils.INTEGRATION_MESSAGE_BUILDER_FACTORY_BEAN_NAME); + Object mbf = context.getBean(IntegrationUtils.INTEGRATION_MESSAGE_BUILDER_FACTORY_BEAN_NAME); assertSame(mbf, TestUtils.getPropertyValue(bean, "messageConverter.messageBuilderFactory")); } diff --git a/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisOutboundChannelAdapterParserTests.java b/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisOutboundChannelAdapterParserTests.java index bbe573faf8..6029428265 100644 --- a/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisOutboundChannelAdapterParserTests.java +++ b/spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisOutboundChannelAdapterParserTests.java @@ -29,7 +29,6 @@ import org.springframework.context.ApplicationContext; import org.springframework.data.redis.listener.RedisMessageListenerContainer; import org.springframework.expression.Expression; import org.springframework.integration.channel.QueueChannel; -import org.springframework.integration.context.IntegrationContextUtils; import org.springframework.integration.endpoint.EventDrivenConsumer; import org.springframework.integration.redis.inbound.RedisInboundChannelAdapter; import org.springframework.integration.redis.outbound.RedisPublishingMessageHandler; @@ -37,6 +36,7 @@ import org.springframework.integration.redis.rules.RedisAvailable; import org.springframework.integration.redis.rules.RedisAvailableTests; import org.springframework.integration.support.MessageBuilder; import org.springframework.integration.support.converter.SimpleMessageConverter; +import org.springframework.integration.support.utils.IntegrationUtils; import org.springframework.integration.test.util.TestUtils; import org.springframework.messaging.Message; import org.springframework.messaging.MessageChannel; @@ -75,7 +75,7 @@ public class RedisOutboundChannelAdapterParserTests extends RedisAvailableTests Object converterBean = context.getBean("testConverter"); assertEquals(converterBean, accessor.getPropertyValue("messageConverter")); assertEquals(context.getBean("serializer"), accessor.getPropertyValue("serializer")); - Object mbf = context.getBean(IntegrationContextUtils.INTEGRATION_MESSAGE_BUILDER_FACTORY_BEAN_NAME); + Object mbf = context.getBean(IntegrationUtils.INTEGRATION_MESSAGE_BUILDER_FACTORY_BEAN_NAME); assertSame(mbf, TestUtils.getPropertyValue(handler, "messageConverter.messageBuilderFactory")); } diff --git a/spring-integration-syslog/src/main/java/org/springframework/integration/syslog/DefaultMessageConverter.java b/spring-integration-syslog/src/main/java/org/springframework/integration/syslog/DefaultMessageConverter.java index 9ea39d3828..a705bca975 100644 --- a/spring-integration-syslog/src/main/java/org/springframework/integration/syslog/DefaultMessageConverter.java +++ b/spring-integration-syslog/src/main/java/org/springframework/integration/syslog/DefaultMessageConverter.java @@ -24,9 +24,9 @@ import java.util.Set; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactoryAware; -import org.springframework.integration.context.IntegrationContextUtils; import org.springframework.integration.support.DefaultMessageBuilderFactory; import org.springframework.integration.support.MessageBuilderFactory; +import org.springframework.integration.support.utils.IntegrationUtils; import org.springframework.integration.transformer.SyslogToMapTransformer; import org.springframework.messaging.Message; @@ -54,7 +54,7 @@ public class DefaultMessageConverter implements MessageConverter, BeanFactoryAwa @Override public final void setBeanFactory(BeanFactory beanFactory) { this.beanFactory = beanFactory; - this.messageBuilderFactory = IntegrationContextUtils.getMessageBuilderFactory(this.beanFactory); + this.messageBuilderFactory = IntegrationUtils.getMessageBuilderFactory(this.beanFactory); } protected MessageBuilderFactory getMessageBuilderFactory() {