From 00ba9d016aa88d8f1e20a0c495001c754d8391c7 Mon Sep 17 00:00:00 2001 From: Oleg Zhurakousky Date: Thu, 18 Nov 2010 04:38:07 -0500 Subject: [PATCH] INT-1629 fixed FTP/SFTP/FTPS docs to reflect the recent changes --- docs/src/reference/docbook/ftp.xml | 150 ++++++++++++++++------------ docs/src/reference/docbook/sftp.xml | 93 +++++++++-------- 2 files changed, 140 insertions(+), 103 deletions(-) diff --git a/docs/src/reference/docbook/ftp.xml b/docs/src/reference/docbook/ftp.xml index c8d18d6425..a553d99bbc 100644 --- a/docs/src/reference/docbook/ftp.xml +++ b/docs/src/reference/docbook/ftp.xml @@ -39,28 +39,85 @@ xsi:schemaLocation="http://www.springframework.org/schema/integration/ftps + +
+ FTP Client Factory + + Before configuring FTP adapters you must configure Ftp Client Factory. You configure + Ftp Client Factory via regular bean configuration by configuring org.springframework.integration.ftp.client.DefaultFtpClientFactory: + Below is a basic configuration: + + + + + + + + + +]]> + + + For FTPS connections all you need to do is use org.springframework.integration.ftp.client.DefaultFtpsClientFactory. + Below is the complete configuration sample: + + + + + + + + + + + + + + + + + + + + +]]> + + + + Now all you need to do is inject these client factories into your adapters. Obviously the protocol (FTP or FTPS) adapter will use depends + on the type of client factory you are using. + + + + A more practical way to provide values for Ftp/Ftps Client Factory would be via Spring's property + placeholder (http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/beans.html#beans-factory-placeholderconfigurer) + + +
+
FTP Inbound Channel Adapter FTP Inbound Channel Adapter is a special listener that will connect to the FTP server and will listen for the remote directory events (e.g., new file created) at which point it will initiate a file transfer. - - -]]> + + +]]> As you can see form the configuration above you can configure FTP Inbound Channel Adapter via inbound-channel-adapter - element while also providing values for various attributes such as username and password to connect to an FTP server, - as well as other attributes. Please refer to the schema for more details on these attributes. + element while also providing values for various attributes such as local-working-directory, filename-pattern (Regular expression) + and of course the reference to a client-factory. + Please refer to the schema for more details on these attributes. + It is also important to understand that FTP Inbound Channel Adapter is a polling consumer and therefore you must configure a poller (global or local). @@ -69,27 +126,6 @@ xsi:schemaLocation="http://www.springframework.org/schema/integration/ftps
-
- FTPS Inbound Channel Adapter - - FTPS Inbound Channel Adapter adds support for secured file receive operations with - FTP servers that support Transport Layer Security (TLS). Configuration of the adapter itself is very similar to the - FTP Inbound Channel Adapter and is use the same inbound-channel-adapter element but from the FTPS namespace. - - - -]]> - -
-
FTP Outbound Channel Adapter @@ -99,39 +135,25 @@ xsi:schemaLocation="http://www.springframework.org/schema/integration/ftps representation of the File so you are not limited only to the File object. FTP Outbound Channel Adapter supports the following payloads: 1) java.io.File - the actual file object; 2) byte[] - byte array that represents the file contents; 3) java.lang.String - - represents the file path. + represents the file contents. - ]]> + ]]> + As you can see form the configuration above you can configure FTP Outbound Channel Adapter via - outbound-channel-adapter element while also providing values for various attributes such as username - and password to connect to an FTP server, as well as other attributes. Please refer to the schema for - more details on these attributes. + outbound-channel-adapter element while also providing values for various attributes such as filename-generator + (implementation of org.springframework.integration.file.FileNameGenerator), reference to a client-factory + as well as other attributes. Please refer to the schema for more details on these attributes. + + By default Spring Integration will use org.springframework.integration.file.DefaultFileNameGenerator (if non specified). + DefaultFileNameGenerator will determine the file name based on the value of the file_name header (if exists) in your + MessageHeaders or if the payload of the Message is java.io.File, then it will use the original name of the file. + +
- -
- FTPS Outbound Channel Adapter - - FTPS Outbound Channel Adapter adds support for secured file send operations with FTP servers that support - Transport Layer Security (TLS). Configuration of the adapter itself is very similar to the - FTP Outbound Channel Adapter and is use the same outbound-channel-adapter element but - from the FTPS namespace: - -
- - - - A more practical way to configure these types of adapters would be via Spring's property - placeholder (http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/beans.html#beans-factory-placeholderconfigurer) - - diff --git a/docs/src/reference/docbook/sftp.xml b/docs/src/reference/docbook/sftp.xml index 30c7433674..c502cfe5e7 100644 --- a/docs/src/reference/docbook/sftp.xml +++ b/docs/src/reference/docbook/sftp.xml @@ -13,8 +13,7 @@ - Similar to FTP, SFTP requires two actors - client and server. The protocol also requires - secure channel, such as SSH, as well as visibility to client's identity throughout SFTP session. + SFTP protocol requires secure channel, such as SSH, as well as visibility to client's identity throughout SFTP session. @@ -29,6 +28,32 @@ xsi:schemaLocation="http://www.springframework.org/schema/integration/sftp +
+ SFTP Session Factory + + Before configuring SFTP adapters you must configure Sftp Session Factory. You configure + Sftp Session Factory via regular bean configuration: + Below is a basic configuration: + + + + + + + +]]> + + + Now all you need to do is inject this Sftp Session Factory into your adapters. + + + + A more practical way to provide values for Sftp Session Factory would be via Spring's property + placeholder (http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/beans.html#beans-factory-placeholderconfigurer) + + +
+
SFTP Inbound Channel Adapter @@ -36,33 +61,28 @@ xsi:schemaLocation="http://www.springframework.org/schema/integration/sftp the remote directory events (e.g., new file created) at which point it will initiate a file transfer. ]]> As you can see form the configuration above you can configure SFTP Inbound Channel Adapter via - inbound-channel-adapter element while also providing values for various attributes such as username and - password to connect to an FTP server, key-file attributes as well as other attributes. + inbound-channel-adapter element while also providing values for various attributes such as local-directory-path + - where files are going to be transfered TO and remote-directory - the remote source directory + as well as other attributes including session-factory which we configured earlier. Please refer to the schema for more details on these attributes. It is also important to understand that SFTP Inbound Channel Adapter is a polling consumer and therefore you must configure a poller (global or local) - Once the file has been transferred a Message with java.io.File being a payload will be generated and sent to the channel - identified with channel attribute. + Once the file has been transferred to a local directory a Message with java.io.File being a + payload will be generated and sent to the channel identified with channel attribute.
@@ -72,38 +92,33 @@ xsi:schemaLocation="http://www.springframework.org/schema/integration/sftp SFTP Outbound Channel Adapter is a special MessageHandler that will connect to the - FTP server and will initiate an FTP transfer for every file it will receive as a payload of the Message. + remote directory and will initiate a file transfer for every file it will receive as a payload of the Message. It also supports several representation of the File so you are not limited to the File object. Similar to FTP outbound adapter SFTP Outbound Channel Adapter supports the following payloads: 1) java.io.File - the actual file object; 2) byte[] - byte array that represents - the file contents; 3) java.lang.String - represents the file path. + the file contents; 3) java.lang.String - represents the file contents. - ]]> + ]]> As you can see form the configuration above you can configure SFTP Outbound Channel Adapter via - outbound-channel-adapter element while also providing values for various attributes such as username and - password to connect to an FTP server, key-file attributes as well as other attributes. + outbound-channel-adapter. Please refer to the schema for more details on these attributes. + + SpEL and SFTP Outbound Adapter + + + As with many other components in Spring Integration, you can benefit from Spring Expression Language (SpEL) when configuring + SFTP Outbound Channel Adapter, by specifying two attributes remote-directory-expression and + remote-file-expression (see above). Expression evaluation context will have Message as its root object, thus allowing + you to provide expressions which can dynamically compute the file name or the directory path + based on the data in the Message. In the example above we are defining remote-file-expression attribute with expression + value which computes the file name based on its original name while also appending suffix '-foo'. + - - - - A more practical way to configure these types of adapters would be via Spring's property - placeholder (http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/beans.html#beans-factory-placeholderconfigurer) - -