Added namespace support for 'file-filter' and 'filename-filter' properties of FileSource (INT-242).
This commit is contained in:
@@ -27,6 +27,8 @@
|
||||
<xsd:attribute name="directory" type="xsd:string" use="required"/>
|
||||
<xsd:attribute name="type" type="fileSourceType" use="optional"/>
|
||||
<xsd:attribute name="message-creator" type="xsd:string" use="optional"/>
|
||||
<xsd:attribute name="file-filter" type="xsd:string"/>
|
||||
<xsd:attribute name="filename-filter" type="xsd:string"/>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
|
||||
@@ -19,7 +19,9 @@ package org.springframework.integration.adapter.file.config;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.integration.ConfigurationException;
|
||||
import org.springframework.integration.adapter.file.FileSource;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Parser for the <file-source/> element.
|
||||
@@ -31,6 +33,10 @@ public class FileSourceParser extends AbstractDirectorySourceParser {
|
||||
|
||||
public static final String DIRECTORY_ATTRIBUTE = "directory";
|
||||
|
||||
public static final String FILE_FILTER_ATTRIBUTE = "file-filter";
|
||||
|
||||
public static final String FILENAME_FILTER_ATTRIBUTE = "filename-filter";
|
||||
|
||||
|
||||
public FileSourceParser() {
|
||||
super(false);
|
||||
@@ -44,12 +50,27 @@ public class FileSourceParser extends AbstractDirectorySourceParser {
|
||||
|
||||
@Override
|
||||
protected boolean isEligibleAttribute(String attributeName) {
|
||||
return !DIRECTORY_ATTRIBUTE.equals(attributeName) && super.isEligibleAttribute(attributeName);
|
||||
return !DIRECTORY_ATTRIBUTE.equals(attributeName) &&
|
||||
!FILE_FILTER_ATTRIBUTE.equals(attributeName) &&
|
||||
!FILENAME_FILTER_ATTRIBUTE.equals(attributeName) &&
|
||||
super.isEligibleAttribute(attributeName);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void postProcess(BeanDefinitionBuilder beanDefinition, Element element) {
|
||||
beanDefinition.addConstructorArgValue(element.getAttribute(DIRECTORY_ATTRIBUTE));
|
||||
beanDefinition.addConstructorArgValue(element.getAttribute(DIRECTORY_ATTRIBUTE));
|
||||
String fileFilter = element.getAttribute(FILE_FILTER_ATTRIBUTE);
|
||||
String filenameFilter = element.getAttribute(FILENAME_FILTER_ATTRIBUTE);
|
||||
if (StringUtils.hasText(fileFilter) && StringUtils.hasText(filenameFilter)) {
|
||||
throw new ConfigurationException("FileSource does not support both '" +
|
||||
FILE_FILTER_ATTRIBUTE + "' and '" + FILENAME_FILTER_ATTRIBUTE + "'.");
|
||||
}
|
||||
else if (StringUtils.hasText(fileFilter)) {
|
||||
beanDefinition.addPropertyReference("fileFilter", fileFilter);
|
||||
}
|
||||
else if (StringUtils.hasText(filenameFilter)) {
|
||||
beanDefinition.addPropertyReference("filenameFilter", filenameFilter);
|
||||
}
|
||||
super.postProcess(beanDefinition, element);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user