diff --git a/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/outbound/FtpSendingMessageHandler.java b/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/outbound/FtpSendingMessageHandler.java index 4312e868b0..31a4518276 100644 --- a/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/outbound/FtpSendingMessageHandler.java +++ b/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/outbound/FtpSendingMessageHandler.java @@ -50,12 +50,13 @@ public class FtpSendingMessageHandler extends AbstractMessageHandler { private static final String TEMPORARY_FILE_SUFFIX = ".writing"; + + private final SessionFactory sessionFactory; + private volatile ExpressionEvaluatingMessageProcessor directoryExpressionProcesor; private volatile Expression remoteDirectoryExpression; - private volatile SessionFactory sessionFactory; - private volatile FileNameGenerator fileNameGenerator = new DefaultFileNameGenerator(); private volatile File temporaryBufferFolderFile; @@ -66,18 +67,12 @@ public class FtpSendingMessageHandler extends AbstractMessageHandler { private volatile String charset = Charset.defaultCharset().name(); - public FtpSendingMessageHandler() { - } - public FtpSendingMessageHandler(SessionFactory sessionFactory) { + Assert.notNull(sessionFactory, "sessionFactory must not be null"); this.sessionFactory = sessionFactory; } - public void setSessionFactory(SessionFactory sessionFactory) { - this.sessionFactory = sessionFactory; - } - public void setRemoteDirectoryExpression(Expression remoteDirectoryExpression) { this.remoteDirectoryExpression = remoteDirectoryExpression; } @@ -95,9 +90,7 @@ public class FtpSendingMessageHandler extends AbstractMessageHandler { } protected void onInit() throws Exception { - Assert.notNull(this.sessionFactory, "sessionFactory must not be null"); - Assert.notNull(this.temporaryBufferFolder, - "'temporaryBufferFolder' must not be null"); + Assert.notNull(this.temporaryBufferFolder, "'temporaryBufferFolder' must not be null"); this.temporaryBufferFolderFile = this.temporaryBufferFolder.getFile(); if (this.remoteDirectoryExpression != null) { this.directoryExpressionProcesor = diff --git a/spring-integration-ftp/src/test/java/log4j.properties b/spring-integration-ftp/src/test/java/log4j.properties deleted file mode 100644 index c4672eb722..0000000000 --- a/spring-integration-ftp/src/test/java/log4j.properties +++ /dev/null @@ -1,8 +0,0 @@ -log4j.rootCategory=WARN, stdout - -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %t %c{2}:%L - %m%n - -log4j.category.org.springframework=WARN -log4j.category.org.springframework.integration=DEBUG diff --git a/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/config/FtpsInboundChannelAdapterParserTests.java b/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/config/FtpsInboundChannelAdapterParserTests.java index b45612a9d6..8ffd7f3bec 100644 --- a/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/config/FtpsInboundChannelAdapterParserTests.java +++ b/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/config/FtpsInboundChannelAdapterParserTests.java @@ -26,7 +26,6 @@ import org.junit.Test; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.integration.endpoint.SourcePollingChannelAdapter; -import org.springframework.integration.ftp.filters.FtpPatternMatchingFileListFilter; import org.springframework.integration.ftp.inbound.FtpInboundFileSynchronizer; import org.springframework.integration.ftp.inbound.FtpInboundFileSynchronizingMessageSource; import org.springframework.integration.test.util.TestUtils; diff --git a/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/config/FtpsOutboundChannelAdapterParserTests.java b/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/config/FtpsOutboundChannelAdapterParserTests.java index 61efdc91e0..12a5d0eb0b 100644 --- a/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/config/FtpsOutboundChannelAdapterParserTests.java +++ b/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/config/FtpsOutboundChannelAdapterParserTests.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.springframework.integration.ftp.config; import static junit.framework.Assert.assertEquals; @@ -26,13 +27,12 @@ import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.integration.endpoint.EventDrivenConsumer; import org.springframework.integration.file.remote.session.CachingSessionFactory; import org.springframework.integration.ftp.outbound.FtpSendingMessageHandler; -import org.springframework.integration.ftp.session.DefaultFtpSessionFactory; import org.springframework.integration.ftp.session.DefaultFtpsSessionFactory; import org.springframework.integration.test.util.TestUtils; /** * @author Oleg Zhurakousky - * + * @since 2.0 */ public class FtpsOutboundChannelAdapterParserTests { diff --git a/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/outbound/FtpSendingMessageHandlerTest.java b/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/outbound/FtpSendingMessageHandlerTest.java index 99d16e9373..5cf32a66a3 100644 --- a/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/outbound/FtpSendingMessageHandlerTest.java +++ b/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/outbound/FtpSendingMessageHandlerTest.java @@ -65,8 +65,7 @@ public class FtpSendingMessageHandlerTest { file.delete(); } assertFalse(file.exists()); - FtpSendingMessageHandler handler = new FtpSendingMessageHandler(); - handler.setSessionFactory(sessionFactory); + FtpSendingMessageHandler handler = new FtpSendingMessageHandler(sessionFactory); handler.setRemoteDirectoryExpression(new LiteralExpression("remote-target-dir")); handler.setFileNameGenerator(new FileNameGenerator() { public String generateFileName(Message message) { @@ -84,8 +83,7 @@ public class FtpSendingMessageHandlerTest { file.delete(); } assertFalse(file.exists()); - FtpSendingMessageHandler handler = new FtpSendingMessageHandler(); - handler.setSessionFactory(sessionFactory); + FtpSendingMessageHandler handler = new FtpSendingMessageHandler(sessionFactory); handler.setRemoteDirectoryExpression(new LiteralExpression("remote-target-dir")); handler.setFileNameGenerator(new FileNameGenerator() { public String generateFileName(Message message) { @@ -104,8 +102,7 @@ public class FtpSendingMessageHandlerTest { file.delete(); } assertFalse(file.exists()); - FtpSendingMessageHandler handler = new FtpSendingMessageHandler(); - handler.setSessionFactory(sessionFactory); + FtpSendingMessageHandler handler = new FtpSendingMessageHandler(sessionFactory); handler.setRemoteDirectoryExpression(new LiteralExpression("remote-target-dir")); handler.setFileNameGenerator(new FileNameGenerator() { public String generateFileName(Message message) {