Added namespace support for the "file:outbound-channel-adapter" with FileOutboundChannelAdapterParser.
This commit is contained in:
@@ -27,6 +27,7 @@ public class FileNamespaceHandler extends NamespaceHandlerSupport {
|
||||
|
||||
public void init() {
|
||||
registerBeanDefinitionParser("inbound-channel-adapter", new FileInboundChannelAdapterParser());
|
||||
registerBeanDefinitionParser("outbound-channel-adapter", new FileOutboundChannelAdapterParser());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright 2002-2008 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.file.config;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionReaderUtils;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.integration.config.AbstractOutboundChannelAdapterParser;
|
||||
import org.springframework.integration.file.FileWritingMessageConsumer;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Parser for the <outbound-channel-adapter/> element of the 'file' namespace.
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class FileOutboundChannelAdapterParser extends AbstractOutboundChannelAdapterParser {
|
||||
|
||||
@Override
|
||||
protected String parseConsumer(Element element, ParserContext parserContext) {
|
||||
String directory = element.getAttribute("directory");
|
||||
Assert.hasText(directory, "directory is required");
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(FileWritingMessageConsumer.class);
|
||||
builder.addConstructorArgValue(directory);
|
||||
String fileNameGenerator = element.getAttribute("filename-generator");
|
||||
if (StringUtils.hasText(fileNameGenerator)) {
|
||||
builder.addPropertyReference("fileNameGenerator", fileNameGenerator);
|
||||
}
|
||||
return BeanDefinitionReaderUtils.registerWithGeneratedName(
|
||||
builder.getBeanDefinition(), parserContext.getRegistry());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -29,11 +29,25 @@
|
||||
<xsd:element ref="integration:poller" minOccurs="0" maxOccurs="1"/>
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="id" type="xsd:string"/>
|
||||
<xsd:attribute name="directory" type="xsd:string"/>
|
||||
<xsd:attribute name="channel" type="xsd:string"/>
|
||||
<xsd:attribute name="directory" type="xsd:string" use="required"/>
|
||||
<xsd:attribute name="filter" type="xsd:string"/>
|
||||
<xsd:attribute name="filename-pattern" type="xsd:string"/>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
<xsd:element name="outbound-channel-adapter">
|
||||
<xsd:complexType>
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Configures an outbound Channel Adapter that writes Message payloads to a File.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:attribute name="id" type="xsd:string"/>
|
||||
<xsd:attribute name="channel" type="xsd:string"/>
|
||||
<xsd:attribute name="directory" type="xsd:string" use="required"/>
|
||||
<xsd:attribute name="filename-generator" type="xsd:string"/>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
</xsd:schema>
|
||||
|
||||
Reference in New Issue
Block a user