INT-1631 changed remote-filename-expression to remote-filename-generation-expression, adjusted tests and docs

This commit is contained in:
Oleg Zhurakousky
2010-11-18 08:43:19 -05:00
parent 24781476f3
commit 454eed23d1
7 changed files with 17 additions and 30 deletions

View File

@@ -103,7 +103,7 @@ xsi:schemaLocation="http://www.springframework.org/schema/integration/sftp
channel="inputChannel"
charset="UTF-8"
remote-directory="foo/bar"
remote-filename-expression="payload.getName() + '-foo'"/>]]></programlisting>
remote-filename-generator-expression="payload.getName() + '-foo'"/>]]></programlisting>
As you can see form the configuration above you can configure <emphasis>SFTP Outbound Channel Adapter</emphasis> via
<code>outbound-channel-adapter</code>.
@@ -115,9 +115,9 @@ xsi:schemaLocation="http://www.springframework.org/schema/integration/sftp
<para>
As with many other components in Spring Integration, you can benefit from Spring Expression Language (SpEL) when configuring
<emphasis>SFTP Outbound Channel Adapter</emphasis>, by specifying two attributes <code>remote-directory-expression</code> and
<code>remote-filename-expression</code> (see above). Expression evaluation context will have Message as its root object, thus allowing
<code>remote-filename-generator-expression</code> (see above). Expression evaluation context will have Message as its root object, thus allowing
you to provide expressions which can dynamically compute the <emphasis>file name</emphasis> or the existing <emphasis>directory path</emphasis>
based on the data in the Message. In the example above we are defining <code>remote-filename-expression</code> attribute with expression
based on the data in the Message. In the example above we are defining <code>remote-filename-generator-expression</code> attribute with expression
value which computes the <emphasis>file name</emphasis> based on its original name while also appending suffix '-foo'.
</para>
</section>

View File

@@ -68,13 +68,13 @@ public class SftpOutboundChannelAdapterParser extends AbstractOutboundChannelAda
}
handlerBuilder.addPropertyValue("remoteDirectoryExpression", expressionDef);
String remoteFileExpression = element.getAttribute("remote-filename-expression");
String fileNameGenerator = element.getAttribute("filename-generator");
String remoteFileExpression = element.getAttribute("remote-filename-generator-expression");
String fileNameGenerator = element.getAttribute("remote-filename-generator");
boolean hasRemoteFileExp = StringUtils.hasText(remoteFileExpression);
boolean hasFileNameGener = StringUtils.hasText(fileNameGenerator);
if (hasRemoteFileExp | hasFileNameGener){
if (!(hasRemoteFileExp ^ hasFileNameGener)) {
throw new BeanDefinitionStoreException("exactly one of 'remote-filename-expression' or 'filename-generator' " +
throw new BeanDefinitionStoreException("exactly one of 'remote-filename-generator-expression' or 'remote-filename-generator' " +
"is allowed on SFTP outbound adapter");
}
if (StringUtils.hasText(remoteFileExpression)){
@@ -86,7 +86,7 @@ public class SftpOutboundChannelAdapterParser extends AbstractOutboundChannelAda
}
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(handlerBuilder, element, "filename-generator");
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(handlerBuilder, element, "remote-filename-generator", "filenameGenerator");
return handlerBuilder.getBeanDefinition();
}
}

View File

@@ -40,7 +40,7 @@
</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="filename-generator" type="xsd:string">
<xsd:attribute name="remote-filename-generator" type="xsd:string">
<xsd:annotation>
<xsd:documentation>
Allows you to specify a reference to
@@ -55,7 +55,7 @@
</xsd:attribute>
<xsd:attribute name="remote-directory" type="xsd:string"/>
<xsd:attribute name="remote-directory-expression" type="xsd:string"/>
<xsd:attribute name="remote-filename-expression" type="xsd:string"/>
<xsd:attribute name="remote-filename-generator-expression" type="xsd:string"/>
<xsd:attribute name="charset" type="xsd:string"/>
</xsd:complexType>
</xsd:element>

View File

@@ -24,9 +24,9 @@
session-factory="sftpSessionFactory"
channel="inputChannel"
charset="UTF-8"
filename-generator="fileNameGenerator"
remote-filename-generator="fileNameGenerator"
remote-directory-expression="'foo' + '/' + 'bar'"
remote-filename-expression="payload.getName() + '-foo'"/>
remote-filename-generator-expression="payload.getName() + '-foo'"/>
<bean id="fileNameGenerator" class="org.mockito.Mockito" factory-method="mock">

View File

@@ -24,7 +24,7 @@
session-factory="sftpSessionFactory"
channel="inputChannel"
charset="UTF-8"
filename-generator="fileNameGenerator"
remote-filename-generator="fileNameGenerator"
remote-directory="foo/bar"
remote-directory-expression="'foo'"/>

View File

@@ -24,7 +24,7 @@
session-factory="sftpSessionFactory"
channel="inputChannel"
charset="UTF-8"
filename-generator="fileNameGenerator"
remote-filename-generator="fileNameGenerator"
remote-directory="foo/bar"/>
<int-sftp:outbound-channel-adapter id="sftpOutboundAdapterWithExpression"
@@ -32,7 +32,7 @@
channel="inputChannel"
charset="UTF-8"
remote-directory-expression="'foo' + '/' + 'bar'"
remote-filename-expression="payload.getName() + '-foo'"/>
remote-filename-generator-expression="payload.getName() + '-foo'"/>
<int-sftp:outbound-channel-adapter
session-factory="sftpSessionFactory"

View File

@@ -10,10 +10,8 @@
<bean id="sftpSessionFactory" class="org.springframework.integration.sftp.session.SftpSessionFactory">
<property name="host" value="localhost"/>
<!-- <property name="knownHosts" value="local, foo.com, bar.foo"/>-->
<property name="privateKey" value="file:/Users/ozhurakousky/.ssh/sftp_rsa"/>
<property name="privateKeyPassphrase" value="seva@1994"/>
<!-- <property name="password" value="hello"/>-->
<property name="privateKeyPassphrase" value="xxxx"/>
<property name="port" value="22"/>
<property name="user" value="ozhurakousky"/>
</bean>
@@ -24,18 +22,7 @@
session-factory="sftpSessionFactory"
channel="inputChannel"
charset="UTF-8"
remote-file-expression="payload.getName() + '_foo'"
remote-file-generator-expression="payload.getName() + '_foo'"
remote-directory="/Users/ozhurakousky/workspace-sts-2.3.3.M2/si/spring-integration/spring-integration-sftp/remote-test-dir"/>
<!-- <int-sftp:outbound-channel-adapter id="sftpOutboundAdapterWithExpression"-->
<!-- session-factory="sftpSessionFactory"-->
<!-- channel="inputChannel"-->
<!-- charset="UTF-8"-->
<!-- filename-generator="fileNameGenerator"-->
<!-- remote-directory-expression="'foo' + '/' + 'bar'"/>-->
<bean id="fileNameGenerator" class="org.mockito.Mockito" factory-method="mock">
<constructor-arg value="org.springframework.integration.file.FileNameGenerator"/>
</bean>
</beans>