diff --git a/spring-integration-core/src/main/java/org/springframework/integration/endpoint/MethodInvokingMessageSource.java b/spring-integration-core/src/main/java/org/springframework/integration/endpoint/MethodInvokingMessageSource.java index a757c7139d..3dde97e696 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/endpoint/MethodInvokingMessageSource.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/endpoint/MethodInvokingMessageSource.java @@ -65,7 +65,8 @@ public class MethodInvokingMessageSource extends AbstractMessageSource i } @Override - public void afterPropertiesSet() { + public void afterPropertiesSet() throws Exception { + super.afterPropertiesSet(); synchronized (this.initializationMonitor) { if (this.initialized) { return; diff --git a/spring-integration-core/src/main/java/org/springframework/integration/resource/ResourceRetrievingMessageSource.java b/spring-integration-core/src/main/java/org/springframework/integration/resource/ResourceRetrievingMessageSource.java index 87b3235195..70ce0e0ab1 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/resource/ResourceRetrievingMessageSource.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/resource/ResourceRetrievingMessageSource.java @@ -41,7 +41,8 @@ import org.springframework.util.ObjectUtils; * @author Gary Russell * @since 2.1 */ -public class ResourceRetrievingMessageSource extends AbstractMessageSource implements ApplicationContextAware, InitializingBean { +public class ResourceRetrievingMessageSource extends AbstractMessageSource + implements ApplicationContextAware, InitializingBean { private final String pattern; @@ -78,11 +79,10 @@ public class ResourceRetrievingMessageSource extends AbstractMessageSource) null); + return this.evaluateExpression(expression, input, null); } protected T evaluateExpression(String expression, Object input, Class expectedType) { - return this.expressionParser.parseExpression(expression).getValue(this.getEvaluationContext(), input, expectedType); + return this.expressionParser.parseExpression(expression) + .getValue(this.getEvaluationContext(), input, expectedType); } protected Object evaluateExpression(Expression expression, Object input) { - return this.evaluateExpression(expression, input, (Class) null); + return this.evaluateExpression(expression, input, null); } protected T evaluateExpression(Expression expression, Class expectedType) { diff --git a/spring-integration-core/src/test/java/org/springframework/integration/message/MethodInvokingMessageSourceTests.java b/spring-integration-core/src/test/java/org/springframework/integration/message/MethodInvokingMessageSourceTests.java index d2348cd204..f70d521a66 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/message/MethodInvokingMessageSourceTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/message/MethodInvokingMessageSourceTests.java @@ -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,9 +30,9 @@ import org.springframework.beans.factory.BeanFactory; import org.springframework.expression.Expression; import org.springframework.expression.common.LiteralExpression; import org.springframework.expression.spel.standard.SpelExpressionParser; +import org.springframework.integration.endpoint.MethodInvokingMessageSource; import org.springframework.messaging.Message; import org.springframework.messaging.MessagingException; -import org.springframework.integration.endpoint.MethodInvokingMessageSource; /** * @author Mark Fisher @@ -43,6 +43,7 @@ public class MethodInvokingMessageSourceTests { @Test public void testValidMethod() { MethodInvokingMessageSource source = new MethodInvokingMessageSource(); + source.setBeanFactory(mock(BeanFactory.class)); source.setObject(new TestBean()); source.setMethodName("validMethod"); Message result = source.receive(); @@ -72,6 +73,7 @@ public class MethodInvokingMessageSourceTests { @Test(expected=MessagingException.class) public void testNoMatchingMethodName() { MethodInvokingMessageSource source = new MethodInvokingMessageSource(); + source.setBeanFactory(mock(BeanFactory.class)); source.setObject(new TestBean()); source.setMethodName("noMatchingMethod"); source.receive(); @@ -80,6 +82,7 @@ public class MethodInvokingMessageSourceTests { @Test(expected=MessagingException.class) public void testInvalidMethodWithArg() { MethodInvokingMessageSource source = new MethodInvokingMessageSource(); + source.setBeanFactory(mock(BeanFactory.class)); source.setObject(new TestBean()); source.setMethodName("invalidMethodWithArg"); source.receive(); @@ -88,6 +91,7 @@ public class MethodInvokingMessageSourceTests { @Test(expected=MessagingException.class) public void testInvalidMethodWithNoReturnValue() { MethodInvokingMessageSource source = new MethodInvokingMessageSource(); + source.setBeanFactory(mock(BeanFactory.class)); source.setObject(new TestBean()); source.setMethodName("invalidMethodWithNoReturnValue"); source.receive(); @@ -96,6 +100,7 @@ public class MethodInvokingMessageSourceTests { @Test public void testNullReturningMethodReturnsNullMessage() { MethodInvokingMessageSource source = new MethodInvokingMessageSource(); + source.setBeanFactory(mock(BeanFactory.class)); source.setObject(new TestBean()); source.setMethodName("nullReturningMethod"); Message message = source.receive(); diff --git a/spring-integration-file/src/main/java/org/springframework/integration/file/remote/synchronizer/AbstractInboundFileSynchronizingMessageSource.java b/spring-integration-file/src/main/java/org/springframework/integration/file/remote/synchronizer/AbstractInboundFileSynchronizingMessageSource.java index 1fbe26a75a..deaaf34335 100644 --- a/spring-integration-file/src/main/java/org/springframework/integration/file/remote/synchronizer/AbstractInboundFileSynchronizingMessageSource.java +++ b/spring-integration-file/src/main/java/org/springframework/integration/file/remote/synchronizer/AbstractInboundFileSynchronizingMessageSource.java @@ -22,8 +22,7 @@ import java.util.Arrays; import java.util.Comparator; import java.util.regex.Pattern; -import org.springframework.integration.core.MessageSource; -import org.springframework.integration.endpoint.MessageProducerSupport; +import org.springframework.integration.endpoint.AbstractMessageSource; import org.springframework.integration.file.FileReadingMessageSource; import org.springframework.integration.file.filters.AcceptOnceFileListFilter; import org.springframework.integration.file.filters.CompositeFileListFilter; @@ -55,8 +54,7 @@ import org.springframework.util.Assert; * @author Oleg Zhurakousky * @author Gary Russell */ -public abstract class AbstractInboundFileSynchronizingMessageSource extends MessageProducerSupport - implements MessageSource { +public abstract class AbstractInboundFileSynchronizingMessageSource extends AbstractMessageSource { /** * Should the endpoint attempt to create the local directory? True by default. @@ -86,7 +84,8 @@ public abstract class AbstractInboundFileSynchronizingMessageSource extends M this(synchronizer, null); } - public AbstractInboundFileSynchronizingMessageSource(AbstractInboundFileSynchronizer synchronizer, Comparator comparator) { + public AbstractInboundFileSynchronizingMessageSource(AbstractInboundFileSynchronizer synchronizer, + Comparator comparator) { Assert.notNull(synchronizer, "synchronizer must not be null"); this.synchronizer = synchronizer; if (comparator == null){ @@ -122,7 +121,8 @@ public abstract class AbstractInboundFileSynchronizingMessageSource extends M } @Override - protected void onInit() { + public void afterPropertiesSet() throws Exception { + super.afterPropertiesSet(); Assert.notNull(this.localDirectory, "localDirectory must not be null"); try { if (!this.localDirectory.exists()) { @@ -149,7 +149,7 @@ public abstract class AbstractInboundFileSynchronizingMessageSource extends M } catch (Exception e) { throw new MessagingException( - "Failure during initialization of MessageSource for: " + this.getComponentType(), e); + "Failure during initialization of MessageSource for: " + this.getClass(), e); } } @@ -159,7 +159,7 @@ public abstract class AbstractInboundFileSynchronizingMessageSource extends M * Then, it polls the file source again and returns the result, whether or not it is null. */ @Override - public final Message receive() { + public final Message doReceive() { Assert.state(this.fileSource != null, "fileSource must not be null"); Assert.state(this.synchronizer != null, "synchronizer must not be null"); Message message = this.fileSource.receive();