INT-3699: RemoteFileTemplate Javadocs

JIRA: https://jira.spring.io/browse/INT-3699

Also javadocs for related classes.

INT-3699: Polishing - PR Comments
This commit is contained in:
Gary Russell
2015-04-15 12:49:29 +03:00
committed by Artem Bilan
parent 3e851d2e1b
commit 15150ac499
4 changed files with 126 additions and 1 deletions

View File

@@ -45,6 +45,8 @@ import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
/**
* A general abstraction for dealing with remote files.
*
* @author Iwein Fuld
* @author Mark Fisher
* @author Josh Long
@@ -87,60 +89,121 @@ public class RemoteFileTemplate<F> implements RemoteFileOperations<F>, Initializ
private volatile BeanFactory beanFactory;
/**
* Construct a {@link RemoteFileTemplate} with the supplied session factory.
* @param sessionFactory the session factory.
*/
public RemoteFileTemplate(SessionFactory<F> sessionFactory) {
Assert.notNull(sessionFactory, "sessionFactory must not be null");
this.sessionFactory = sessionFactory;
}
/**
* Determine whether the remote directory should automatically be created when
* sending files to the remote system.
* @param autoCreateDirectory true to create the directory.
*/
public void setAutoCreateDirectory(boolean autoCreateDirectory) {
this.autoCreateDirectory = autoCreateDirectory;
}
/**
* Set the file separator when dealing with remote files; default '/'.
* @param remoteFileSeparator the separator.
*/
public void setRemoteFileSeparator(String remoteFileSeparator) {
Assert.notNull(remoteFileSeparator, "'remoteFileSeparator' must not be null");
this.remoteFileSeparator = remoteFileSeparator;
}
/**
* @return the remote file separator.
*/
public final String getRemoteFileSeparator() {
return remoteFileSeparator;
}
/**
* Set the remote directory expression used to determine the remote directory to which
* files will be sent.
* @param remoteDirectoryExpression the remote directory expression.
*/
public void setRemoteDirectoryExpression(Expression remoteDirectoryExpression) {
Assert.notNull(remoteDirectoryExpression, "remoteDirectoryExpression must not be null");
this.directoryExpressionProcessor = new ExpressionEvaluatingMessageProcessor<String>(remoteDirectoryExpression, String.class);
}
/**
* Set a temporary remote directory expression; used when transferring files to the remote
* system. After a successful transfer the file is renamed using the
* {@link #setRemoteDirectoryExpression(Expression) remoteDirectoryExpression}.
* @param temporaryRemoteDirectoryExpression the temporary remote directory expression.
*/
public void setTemporaryRemoteDirectoryExpression(Expression temporaryRemoteDirectoryExpression) {
Assert.notNull(temporaryRemoteDirectoryExpression, "temporaryRemoteDirectoryExpression must not be null");
this.temporaryDirectoryExpressionProcessor = new ExpressionEvaluatingMessageProcessor<String>(temporaryRemoteDirectoryExpression, String.class);
}
/**
* Set the file name expression to determine the full path to the remote file when retrieving
* a file using the {@link #get(Message, InputStreamCallback)} method, with the message
* being the root object of the evaluation.
* @param fileNameExpression the file name expression.
*/
public void setFileNameExpression(Expression fileNameExpression) {
Assert.notNull(fileNameExpression, "fileNameExpression must not be null");
this.fileNameProcessor = new ExpressionEvaluatingMessageProcessor<String>(fileNameExpression, String.class);
}
/**
* @return the temporary file suffix.
*/
public String getTemporaryFileSuffix() {
return this.temporaryFileSuffix;
}
/**
* @return whether a temporary file name is used when sending files to the remote
* system.
*/
public boolean isUseTemporaryFileName() {
return useTemporaryFileName;
}
/**
* Set whether a temporary file name is used when sending files to the remote system.
* @param useTemporaryFileName true to use a temporary file name.
* @see #setTemporaryFileSuffix(String)
*/
public void setUseTemporaryFileName(boolean useTemporaryFileName) {
this.useTemporaryFileName = useTemporaryFileName;
}
/**
* Set the file name generator used to generate the remote filename to be used when transferring
* files to the remote system. Default {@link DefaultFileNameGenerator}.
* @param fileNameGenerator the file name generator.
*/
public void setFileNameGenerator(FileNameGenerator fileNameGenerator) {
this.fileNameGenerator = (fileNameGenerator != null) ? fileNameGenerator : new DefaultFileNameGenerator();
this.fileNameGeneratorSet = fileNameGenerator != null;
}
/**
* Set the charset to use when converting String payloads to bytes as the content of the
* remote file. Default {@code UTF-8}.
* @param charset the charset.
*/
public void setCharset(String charset) {
this.charset = charset;
}
/**
* Set the temporary suffix to use when transferring files to the remote system.
* Default ".writing".
* @param temporaryFileSuffix the suffix
* @see #setUseTemporaryFileName(boolean)
*/
public void setTemporaryFileSuffix(String temporaryFileSuffix) {
Assert.notNull(temporaryFileSuffix, "'temporaryFileSuffix' must not be null");
this.hasExplicitlySetSuffix = true;
@@ -302,6 +365,9 @@ public class RemoteFileTemplate<F> implements RemoteFileOperations<F>, Initializ
});
}
/**
* @see #setFileNameExpression(Expression)
*/
@Override
public boolean get(Message<?> message, InputStreamCallback callback) {
Assert.notNull(this.fileNameProcessor, "A 'fileNameExpression' is needed to use get");

View File

@@ -265,6 +265,7 @@ public abstract class AbstractRemoteFileOutboundGateway<F> extends AbstractReply
/**
* @param remoteFileSeparator the remoteFileSeparator to set
* @see RemoteFileTemplate#setRemoteFileSeparator(String)
*/
public void setRemoteFileSeparator(String remoteFileSeparator) {
this.remoteFileTemplate.setRemoteFileSeparator(remoteFileSeparator);
@@ -292,6 +293,7 @@ public abstract class AbstractRemoteFileOutboundGateway<F> extends AbstractReply
/**
* @param temporaryFileSuffix the temporaryFileSuffix to set
* @see RemoteFileTemplate#setTemporaryFileSuffix(String)
*/
public void setTemporaryFileSuffix(String temporaryFileSuffix) {
this.remoteFileTemplate.setTemporaryFileSuffix(temporaryFileSuffix);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2015 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.
@@ -59,18 +59,34 @@ public class FileTransferringMessageHandler<F> extends AbstractMessageHandler {
}
/**
* @param autoCreateDirectory true to automatically create the direcotory.
* @see RemoteFileTemplate#setAutoCreateDirectory(boolean)
*/
public void setAutoCreateDirectory(boolean autoCreateDirectory) {
this.remoteFileTemplate.setAutoCreateDirectory(autoCreateDirectory);
}
/**
* @param remoteFileSeparator the remote file separator.
* @see RemoteFileTemplate#setRemoteFileSeparator(String)
*/
public void setRemoteFileSeparator(String remoteFileSeparator) {
this.remoteFileTemplate.setRemoteFileSeparator(remoteFileSeparator);
}
/**
* @param remoteDirectoryExpression the remote directory expression
* @see RemoteFileTemplate#setRemoteDirectoryExpression(Expression)
*/
public void setRemoteDirectoryExpression(Expression remoteDirectoryExpression) {
this.remoteFileTemplate.setRemoteDirectoryExpression(remoteDirectoryExpression);
}
/**
* @param temporaryRemoteDirectoryExpression the temporary remote directory expression
* @see RemoteFileTemplate#setTemporaryRemoteDirectoryExpression(Expression)
*/
public void setTemporaryRemoteDirectoryExpression(Expression temporaryRemoteDirectoryExpression) {
this.remoteFileTemplate.setTemporaryRemoteDirectoryExpression(temporaryRemoteDirectoryExpression);
}
@@ -83,18 +99,34 @@ public class FileTransferringMessageHandler<F> extends AbstractMessageHandler {
return this.remoteFileTemplate.isUseTemporaryFileName();
}
/**
* @param useTemporaryFileName true to use a temporary file name.
* @see RemoteFileTemplate#setUseTemporaryFileName(boolean)
*/
public void setUseTemporaryFileName(boolean useTemporaryFileName) {
this.remoteFileTemplate.setUseTemporaryFileName(useTemporaryFileName);
}
/**
* @param fileNameGenerator the file name generator.
* @see RemoteFileTemplate#setFileNameGenerator(FileNameGenerator)
*/
public void setFileNameGenerator(FileNameGenerator fileNameGenerator) {
this.remoteFileTemplate.setFileNameGenerator(fileNameGenerator);
}
/**
* @param charset the charset.
* @see RemoteFileTemplate#setCharset(String)
*/
public void setCharset(String charset) {
this.remoteFileTemplate.setCharset(charset);
}
/**
* @param temporaryFileSuffix the temporary file suffix.
* @see RemoteFileTemplate#setTemporaryFileSuffix(String)
*/
public void setTemporaryFileSuffix(String temporaryFileSuffix) {
this.remoteFileTemplate.setTemporaryFileSuffix(temporaryFileSuffix);
}

View File

@@ -108,16 +108,28 @@ public abstract class AbstractInboundFileSynchronizer<F> implements InboundFileS
}
/**
* @param remoteFileSeparator the remote file separator.
* @see RemoteFileTemplate#setRemoteFileSeparator(String)
*/
public void setRemoteFileSeparator(String remoteFileSeparator) {
Assert.notNull(remoteFileSeparator, "'remoteFileSeparator' must not be null");
this.remoteFileSeparator = remoteFileSeparator;
}
/**
* Set an expression used to determine the local file name.
* @param localFilenameGeneratorExpression the expression.
*/
public void setLocalFilenameGeneratorExpression(Expression localFilenameGeneratorExpression) {
Assert.notNull(localFilenameGeneratorExpression, "'localFilenameGeneratorExpression' must not be null");
this.localFilenameGeneratorExpression = localFilenameGeneratorExpression;
}
/**
* Set a temporary file suffix to be used while transferring files. Default ".writing".
* @param temporaryFileSuffix the file suffix.
*/
public void setTemporaryFileSuffix(String temporaryFileSuffix) {
this.temporaryFileSuffix = temporaryFileSuffix;
}
@@ -131,14 +143,27 @@ public abstract class AbstractInboundFileSynchronizer<F> implements InboundFileS
this.remoteDirectory = remoteDirectory;
}
/**
* Set the filter to be applied to the remote files before transferring.
* @param filter the file list filter.
*/
public void setFilter(FileListFilter<F> filter) {
this.filter = filter;
}
/**
* Set to true to enable deletion of remote files after successful transfer.
* @param deleteRemoteFiles true to delete.
*/
public void setDeleteRemoteFiles(boolean deleteRemoteFiles) {
this.deleteRemoteFiles = deleteRemoteFiles;
}
/**
* Set to true to enable the preservation of the remote file timestamp when
* transferring.
* @param preserveTimestamp true to preserve.
*/
public void setPreserveTimestamp(boolean preserveTimestamp) {
this.preserveTimestamp = preserveTimestamp;
}