INT-1614 FtpSendingMessageHandler now takes the SessionFactory in its sole constructor
This commit is contained in:
@@ -50,12 +50,13 @@ public class FtpSendingMessageHandler extends AbstractMessageHandler {
|
||||
|
||||
private static final String TEMPORARY_FILE_SUFFIX = ".writing";
|
||||
|
||||
|
||||
private final SessionFactory sessionFactory;
|
||||
|
||||
private volatile ExpressionEvaluatingMessageProcessor<String> 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 =
|
||||
|
||||
@@ -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
|
||||
@@ -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;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user