From b28ec1788540c55125d9737f4c4f9bbe0d9f8cb7 Mon Sep 17 00:00:00 2001 From: Mark Fisher Date: Wed, 19 Oct 2011 15:46:15 -0400 Subject: [PATCH] polishing --- docs/src/reference/docbook/ftp.xml | 8 +++--- docs/src/reference/docbook/sftp.xml | 8 +++--- .../AbstractInboundFileSynchronizer.java | 28 ++++++++++--------- .../ftp/config/spring-integration-ftp-2.1.xsd | 23 +++++++-------- .../config/spring-integration-sftp-2.1.xsd | 27 +++++++++--------- 5 files changed, 49 insertions(+), 45 deletions(-) diff --git a/docs/src/reference/docbook/ftp.xml b/docs/src/reference/docbook/ftp.xml index ea8918dbd8..fbe16e72dd 100644 --- a/docs/src/reference/docbook/ftp.xml +++ b/docs/src/reference/docbook/ftp.xml @@ -127,11 +127,11 @@ xsi:schemaLocation="http://www.springframework.org/schema/integration/ftp By default the transferred file will carry the same name as the original file. If you want to override this behavior you - can set local-filename-generator-expression attribute which allows you to provide SpEL Expression to generate + can set the local-filename-generator-expression attribute which allows you to provide a SpEL Expression to generate the name of the local file. Unlike outbound gateways and adapters where the root object of the SpEL Evaluation Context - is Message, Inbound adapter generates Message based on the transferred file - which means that Message does not exist yet at the time of Expression evaluation. So the root object - of the SpEL Evaluation Context is the original name of the remote file (String) + is a Message, this inbound adapter does not yet have the Message at the time of evaluation since + that's what it ultimately generates with the transferred file as its payload. So, the root object of the SpEL Evaluation Context + is the original name of the remote file (String). diff --git a/docs/src/reference/docbook/sftp.xml b/docs/src/reference/docbook/sftp.xml index 4408d08c5d..2c4505fca0 100644 --- a/docs/src/reference/docbook/sftp.xml +++ b/docs/src/reference/docbook/sftp.xml @@ -93,11 +93,11 @@ xsi:schemaLocation="http://www.springframework.org/schema/integration/sftp By default the transferred file will carry the same name as the original file. If you want to override this behavior you - can set local-filename-generator-expression attribute which allows you to provide SpEL Expression to generate + can set the local-filename-generator-expression attribute which allows you to provide a SpEL Expression to generate the name of the local file. Unlike outbound gateways and adapters where the root object of the SpEL Evaluation Context - is Message, Inbound adapter generates Message based on the transferred file - which means that Message does not exist yet at the time of Expression evaluation. So the root object - of the SpEL Evaluation Context is the original name of the remote file (String) + is a Message, this inbound adapter does not yet have the Message at the time of evaluation since + that's what it ultimately generates with the transferred file as its payload. So, the root object of the SpEL Evaluation Context + is the original name of the remote file (String). Some times file filtering based on the simple pattern specified via filename-pattern attribute might not be diff --git a/spring-integration-file/src/main/java/org/springframework/integration/file/remote/synchronizer/AbstractInboundFileSynchronizer.java b/spring-integration-file/src/main/java/org/springframework/integration/file/remote/synchronizer/AbstractInboundFileSynchronizer.java index 3cb1392186..d5b4ee0a23 100644 --- a/spring-integration-file/src/main/java/org/springframework/integration/file/remote/synchronizer/AbstractInboundFileSynchronizer.java +++ b/spring-integration-file/src/main/java/org/springframework/integration/file/remote/synchronizer/AbstractInboundFileSynchronizer.java @@ -26,6 +26,7 @@ import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.springframework.beans.factory.InitializingBean; import org.springframework.expression.Expression; import org.springframework.expression.spel.support.StandardEvaluationContext; @@ -50,17 +51,18 @@ import org.springframework.util.ObjectUtils; * @since 2.0 */ public abstract class AbstractInboundFileSynchronizer implements InboundFileSynchronizer, InitializingBean { - - private static final StandardEvaluationContext context = new StandardEvaluationContext(); - private String remoteFileSeparator = "/"; + protected final Log logger = LogFactory.getLog(this.getClass()); + + private final StandardEvaluationContext evaluationContext = new StandardEvaluationContext(); + + private volatile String remoteFileSeparator = "/"; + /** * Extension used when downloading files. We change it right after we know it's downloaded. */ private volatile String temporaryFileSuffix =".writing"; - protected final Log logger = LogFactory.getLog(this.getClass()); - private volatile Expression localFilenameGeneratorExpression; /** @@ -82,14 +84,9 @@ public abstract class AbstractInboundFileSynchronizer implements InboundFileS * Should we delete the remote source files * after copying to the local directory? By default this is false. */ - private boolean deleteRemoteFiles; + private volatile boolean deleteRemoteFiles; - public void setLocalFilenameGeneratorExpression(Expression localFilenameGeneratorExpression) { - Assert.notNull(localFilenameGeneratorExpression, "'localFilenameGeneratorExpression' must not be null"); - this.localFilenameGeneratorExpression = localFilenameGeneratorExpression; - } - /** * Create a synchronizer with the {@link SessionFactory} used to acquire {@link Session} instances. */ @@ -103,7 +100,12 @@ public abstract class AbstractInboundFileSynchronizer implements InboundFileS Assert.notNull(remoteFileSeparator, "'remoteFileSeparator' must not be null"); this.remoteFileSeparator = remoteFileSeparator; } - + + public void setLocalFilenameGeneratorExpression(Expression localFilenameGeneratorExpression) { + Assert.notNull(localFilenameGeneratorExpression, "'localFilenameGeneratorExpression' must not be null"); + this.localFilenameGeneratorExpression = localFilenameGeneratorExpression; + } + public void setTemporaryFileSuffix(String temporaryFileSuffix) { this.temporaryFileSuffix = temporaryFileSuffix; } @@ -223,7 +225,7 @@ public abstract class AbstractInboundFileSynchronizer implements InboundFileS private String generateLocalFileName(String remoteFileName){ if (this.localFilenameGeneratorExpression != null){ - return this.localFilenameGeneratorExpression.getValue(context, remoteFileName, String.class); + return this.localFilenameGeneratorExpression.getValue(evaluationContext, remoteFileName, String.class); } return remoteFileName; } diff --git a/spring-integration-ftp/src/main/resources/org/springframework/integration/ftp/config/spring-integration-ftp-2.1.xsd b/spring-integration-ftp/src/main/resources/org/springframework/integration/ftp/config/spring-integration-ftp-2.1.xsd index 47314f5442..73f0b230e4 100644 --- a/spring-integration-ftp/src/main/resources/org/springframework/integration/ftp/config/spring-integration-ftp-2.1.xsd +++ b/spring-integration-ftp/src/main/resources/org/springframework/integration/ftp/config/spring-integration-ftp-2.1.xsd @@ -110,24 +110,25 @@ endpoint itself is a Polling Consumer for a channel with a queue. - Allows you to provide file name pattern to determine the file names that needs to be scanned - and is based on simple pattern matching algorithm (e.g., "*.txt, fo*.txt" etc.) + Allows you to provide a file name pattern to determine the file names that need to be scanned. + This is based on simple pattern matching (e.g., "*.txt, fo*.txt" etc.) - Allows you to provide SpEL expression which will compute the file name of - the local file (transfered file). Root object of SpEL is the name of the original - file (e.g., "#this.toUpperCase() + '.a'" where #this represents the original name of the remote file) + Allows you to provide a SpEL expression to generate the file name of + the local (transferred) file. The root object of the SpEL evaluation is the name of the original + file. For example, a valid expression would be "#this.toUpperCase() + '.a'" where #this represents the + original name of the remote file. - Allows you to provide Regular Expression to determine the file names that needs to be scanned. + Allows you to provide a Regular Expression to determine the file names that need to be scanned. (e.g., "f[o]+\.txt" etc.) @@ -156,7 +157,7 @@ endpoint itself is a Polling Consumer for a channel with a queue. - Allows you to specify a reference to + Allows you to specify a reference to a [org.springframework.integration.file.filters.FileListFilter] bean. @@ -171,28 +172,28 @@ endpoint itself is a Polling Consumer for a channel with a queue. - Identifies directory path (e.g., "/temp/mytransfers") where file will be transferred FROM. + Identifies the directory path (e.g., "/temp/mytransfers") where files will be transferred FROM. - Allows you to provide remote file/directory separator character. DEFAULT: '/' + Allows you to provide a remote file/directory separator character. DEFAULT: '/' - Identifies directory path (e.g., "/local/mytransfers") where file will be transferred TO. + Identifies the directory path (e.g., "/local/mytransfers") where files will be transferred TO. - Tells this adapter if local directory must be auto-created if it doesn''t exist. Default is TRUE. + Tells this adapter if the local directory must be auto-created if it doesn't exist. Default is TRUE. diff --git a/spring-integration-sftp/src/main/resources/org/springframework/integration/sftp/config/spring-integration-sftp-2.1.xsd b/spring-integration-sftp/src/main/resources/org/springframework/integration/sftp/config/spring-integration-sftp-2.1.xsd index 4ce5d2ee63..4b69190db9 100644 --- a/spring-integration-sftp/src/main/resources/org/springframework/integration/sftp/config/spring-integration-sftp-2.1.xsd +++ b/spring-integration-sftp/src/main/resources/org/springframework/integration/sftp/config/spring-integration-sftp-2.1.xsd @@ -195,8 +195,8 @@ endpoint itself is a Polling Consumer for a channel with a queue. - Identifies channel attached to this adapter. Depending on the type of the adapter - this channel could be the receiving channel (e.g., outbound-channel-adapter) or channel where + Identifies the channel attached to this adapter. Depending on the type of the adapter + this channel could be the receiving channel (e.g., outbound-channel-adapter) or the channel where messages will be sent to by this adapter (e.g., inbound-channel-adapter). @@ -209,7 +209,7 @@ endpoint itself is a Polling Consumer for a channel with a queue. - Allows you to specify a reference to + Allows you to specify a reference to a [org.springframework.integration.file.filters.FileListFilter] bean. @@ -217,24 +217,25 @@ endpoint itself is a Polling Consumer for a channel with a queue. - Allows you to provide file name pattern to determine the file names that needs to be scanned - and is based on simple pattern matching algorithm (e.g., "*.txt, fo*.txt" etc.) + Allows you to provide a file name pattern to determine the file names that need to be scanned. + This is based on simple pattern matching (e.g., "*.txt, fo*.txt" etc.) - Allows you to provide SpEL expression which will compute the file name of - the local file (transfered file). Root object of SpEL is the name of the original - file (e.g., "#this.toUpperCase() + '.a'" where #this represents the original name of the remote file) + Allows you to provide a SpEL expression to generate the file name of + the local (transferred) file. The root object of the SpEL evaluation is the name of the original + file. For example, a valid expression would be "#this.toUpperCase() + '.a'" where #this represents the + original name of the remote file. - Allows you to provide Regular Expression to determine the file names that needs to be scanned. + Allows you to provide a Regular Expression to determine the file names that need to be scanned. (e.g., "f[o]+\.txt" etc.) @@ -242,28 +243,28 @@ endpoint itself is a Polling Consumer for a channel with a queue. - Allows you to provide remote file/directory separator character. DEFAULT: '/' + Allows you to provide a remote file/directory separator character. DEFAULT: '/' - Identifies directory path (e.g., "/temp/mytransfers") where file will be transferred FROM. + Identifies the directory path (e.g., "/temp/mytransfers") where files will be transferred FROM. - Identifies directory path (e.g., "/local/mytransfers") where file will be transferred TO. + Identifies the directory path (e.g., "/local/mytransfers") where files will be transferred TO. - Tells this adapter if local directory must be auto-created if it doesn''t exist. Default is TRUE. + Tells this adapter if the local directory must be auto-created if it doesn't exist. Default is TRUE.