FileTargetAdapterParser is now FileTargetParser.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
console-source=org.springframework.integration.adapter.stream.config.ConsoleSourceParser
|
||||
console-target=org.springframework.integration.adapter.stream.config.ConsoleTargetParser
|
||||
file-source=org.springframework.integration.adapter.file.config.FileSourceParser
|
||||
file-target=org.springframework.integration.adapter.file.config.FileTargetAdapterParser
|
||||
file-target=org.springframework.integration.adapter.file.config.FileTargetParser
|
||||
ftp-source=org.springframework.integration.adapter.ftp.config.FtpSourceParser
|
||||
httpinvoker-source=org.springframework.integration.adapter.httpinvoker.config.HttpInvokerSourceAdapterParser
|
||||
httpinvoker-target=org.springframework.integration.adapter.httpinvoker.config.HttpInvokerTargetAdapterParser
|
||||
|
||||
@@ -32,12 +32,11 @@
|
||||
<xsd:complexType>
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Defines a file-based target channel adapter.
|
||||
Defines a file-based target.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
<xsd:attribute name="id" type="xsd:string"/>
|
||||
<xsd:attribute name="directory" type="xsd:string" use="required"/>
|
||||
<xsd:attribute name="channel" type="xsd:string" use="required"/>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
|
||||
@@ -18,24 +18,20 @@ package org.springframework.integration.adapter.file.config;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
import org.springframework.beans.factory.parsing.BeanComponentDefinition;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.support.RootBeanDefinition;
|
||||
import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.integration.adapter.file.FileTarget;
|
||||
import org.springframework.integration.endpoint.TargetEndpoint;
|
||||
import org.springframework.integration.scheduling.Subscription;
|
||||
|
||||
/**
|
||||
* Parser for the <file-target/> element.
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class FileTargetAdapterParser extends AbstractSingleBeanDefinitionParser {
|
||||
public class FileTargetParser extends AbstractSingleBeanDefinitionParser {
|
||||
|
||||
protected Class<?> getBeanClass(Element element) {
|
||||
return TargetEndpoint.class;
|
||||
return FileTarget.class;
|
||||
}
|
||||
|
||||
protected boolean shouldGenerateId() {
|
||||
@@ -47,14 +43,7 @@ public class FileTargetAdapterParser extends AbstractSingleBeanDefinitionParser
|
||||
}
|
||||
|
||||
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
|
||||
RootBeanDefinition adapterDef = new RootBeanDefinition(FileTarget.class);
|
||||
adapterDef.getConstructorArgumentValues().addGenericArgumentValue(element.getAttribute("directory"));
|
||||
String adapterBeanName = parserContext.getReaderContext().generateBeanName(adapterDef);
|
||||
parserContext.registerBeanComponent(new BeanComponentDefinition(adapterDef, adapterBeanName));
|
||||
builder.addConstructorArgReference(adapterBeanName);
|
||||
String channel = element.getAttribute("channel");
|
||||
Subscription subscription = new Subscription(channel);
|
||||
builder.addPropertyValue("subscription", subscription);
|
||||
builder.addConstructorArgValue(element.getAttribute("directory"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -30,11 +30,11 @@ import org.springframework.integration.adapter.file.FileSource;
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class FileSourceAdapterParserTests {
|
||||
public class FileSourceParserTests {
|
||||
|
||||
@Test
|
||||
public void testFileSourceAdapterParser() {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext("fileSourceAdapterParserTests.xml", this.getClass());
|
||||
public void testFileSource() {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext("fileSourceParserTests.xml", this.getClass());
|
||||
FileSource fileSource = (FileSource) context.getBean("fileSource");
|
||||
DirectFieldAccessor sourceAccessor = new DirectFieldAccessor(fileSource);
|
||||
File directory = (File) sourceAccessor.getPropertyValue("directory");
|
||||
@@ -23,20 +23,18 @@ import org.junit.Test;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.integration.adapter.file.FileTarget;
|
||||
import org.springframework.integration.endpoint.TargetEndpoint;
|
||||
import org.springframework.integration.message.Target;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class FileTargetAdapterParserTests {
|
||||
public class FileTargetParserTests {
|
||||
|
||||
@Test
|
||||
public void testFileTargetAdapterParser() {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext("fileTargetAdapterParserTests.xml", this.getClass());
|
||||
TargetEndpoint endpoint = (TargetEndpoint) context.getBean("adapter");
|
||||
assertEquals(FileTarget.class, endpoint.getTarget().getClass());
|
||||
assertEquals("adapter", endpoint.getName());
|
||||
assertEquals("testChannel", endpoint.getSubscription().getChannelName());
|
||||
public void testFileTarget() {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext("fileTargetParserTests.xml", this.getClass());
|
||||
Target target = (Target) context.getBean("target");
|
||||
assertEquals(FileTarget.class, target.getClass());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
<si:channel id="testChannel"/>
|
||||
|
||||
<si:file-target id="adapter" directory="${java.io.tmpdir}" channel="testChannel"/>
|
||||
<si:file-target id="target" directory="${java.io.tmpdir}"/>
|
||||
|
||||
<context:property-placeholder/>
|
||||
|
||||
@@ -22,9 +22,11 @@
|
||||
<handler-endpoint input-channel="channel1" output-channel="channel2"
|
||||
handler="exclaimer" method="exclaim"/>
|
||||
|
||||
<target-endpoint input-channel="channel2" target="fileTarget"/>
|
||||
|
||||
<file-source id="fileSource" directory="${java.io.tmpdir}/spring-integration-samples/input"/>
|
||||
|
||||
<file-target directory="${java.io.tmpdir}/spring-integration-samples/output" channel="channel2"/>
|
||||
<file-target id="fileTarget" directory="${java.io.tmpdir}/spring-integration-samples/output"/>
|
||||
|
||||
<beans:bean id="exclaimer" class="org.springframework.integration.samples.filecopy.Exclaimer"/>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user