diff --git a/spring-integration-core/src/main/java/org/springframework/integration/adapter/file/config/FileSourceAdapterParser.java b/spring-integration-core/src/main/java/org/springframework/integration/adapter/file/config/FileSourceAdapterParser.java
new file mode 100644
index 0000000000..b9ddf2216a
--- /dev/null
+++ b/spring-integration-core/src/main/java/org/springframework/integration/adapter/file/config/FileSourceAdapterParser.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2002-2007 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.adapter.file.config;
+
+import org.w3c.dom.Element;
+
+import org.springframework.beans.factory.support.BeanDefinitionBuilder;
+import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
+import org.springframework.integration.adapter.file.FileSourceAdapter;
+
+/**
+ * Parser for the <file-source/> element.
+ *
+ * @author Mark Fisher
+ */
+public class FileSourceAdapterParser extends AbstractSingleBeanDefinitionParser {
+
+ protected Class getBeanClass(Element element) {
+ return FileSourceAdapter.class;
+ }
+
+ protected boolean shouldGenerateId() {
+ return true;
+ }
+
+ protected void doParse(Element element, BeanDefinitionBuilder builder) {
+ String directory = element.getAttribute("directory");
+ String channel = element.getAttribute("channel");
+ String pollPeriod = element.getAttribute("poll-period");
+ builder.addConstructorArg(directory);
+ builder.addConstructorArgReference(channel);
+ builder.addConstructorArg(pollPeriod);
+ }
+
+}
diff --git a/spring-integration-core/src/main/java/org/springframework/integration/adapter/file/config/FileTargetAdapterParser.java b/spring-integration-core/src/main/java/org/springframework/integration/adapter/file/config/FileTargetAdapterParser.java
new file mode 100644
index 0000000000..b430cd0b6b
--- /dev/null
+++ b/spring-integration-core/src/main/java/org/springframework/integration/adapter/file/config/FileTargetAdapterParser.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2002-2007 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.adapter.file.config;
+
+import org.w3c.dom.Element;
+
+import org.springframework.beans.factory.support.BeanDefinitionBuilder;
+import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
+import org.springframework.integration.adapter.file.FileTargetAdapter;
+
+/**
+ * Parser for the <file-target/> element.
+ *
+ * @author Mark Fisher
+ */
+public class FileTargetAdapterParser extends AbstractSingleBeanDefinitionParser {
+
+ protected Class getBeanClass(Element element) {
+ return FileTargetAdapter.class;
+ }
+
+ protected boolean shouldGenerateId() {
+ return true;
+ }
+
+ protected void doParse(Element element, BeanDefinitionBuilder builder) {
+ String directory = element.getAttribute("directory");
+ String channel = element.getAttribute("channel");
+ builder.addConstructorArg(directory);
+ builder.addPropertyReference("channel", channel);
+ }
+
+}
diff --git a/spring-integration-core/src/main/java/org/springframework/integration/config/IntegrationNamespaceHandler.java b/spring-integration-core/src/main/java/org/springframework/integration/config/IntegrationNamespaceHandler.java
index 10cfca1e11..3f6c09ed0d 100644
--- a/spring-integration-core/src/main/java/org/springframework/integration/config/IntegrationNamespaceHandler.java
+++ b/spring-integration-core/src/main/java/org/springframework/integration/config/IntegrationNamespaceHandler.java
@@ -17,6 +17,8 @@
package org.springframework.integration.config;
import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
+import org.springframework.integration.adapter.file.config.FileSourceAdapterParser;
+import org.springframework.integration.adapter.file.config.FileTargetAdapterParser;
/**
* Namespace handler for the integration namespace.
@@ -32,6 +34,8 @@ public class IntegrationNamespaceHandler extends NamespaceHandlerSupport {
registerBeanDefinitionParser("source-adapter", new ChannelAdapterParser(true));
registerBeanDefinitionParser("target-adapter", new ChannelAdapterParser(false));
registerBeanDefinitionParser("endpoint", new EndpointParser());
+ registerBeanDefinitionParser("file-source", new FileSourceAdapterParser());
+ registerBeanDefinitionParser("file-target", new FileTargetAdapterParser());
}
}
diff --git a/spring-integration-core/src/main/java/org/springframework/integration/config/spring-integration-1.0.xsd b/spring-integration-core/src/main/java/org/springframework/integration/config/spring-integration-1.0.xsd
index be79e8161c..7616728793 100644
--- a/spring-integration-core/src/main/java/org/springframework/integration/config/spring-integration-1.0.xsd
+++ b/spring-integration-core/src/main/java/org/springframework/integration/config/spring-integration-1.0.xsd
@@ -134,4 +134,29 @@
+
+
+
+
+ Defines a file-based source channel adapter.
+
+
+
+
+
+
+
+
+
+
+
+
+ Defines a file-based target channel adapter.
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/spring-integration-samples/src/main/java/org/springframework/integration/samples/filecopy/FileCopyDemo.java b/spring-integration-samples/src/main/java/org/springframework/integration/samples/filecopy/FileCopyDemo.java
new file mode 100644
index 0000000000..a5954548ea
--- /dev/null
+++ b/spring-integration-samples/src/main/java/org/springframework/integration/samples/filecopy/FileCopyDemo.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2002-2007 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.samples.filecopy;
+
+import java.io.File;
+
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ * Demo of file source and target adapters.
+ *
+ * @author Mark Fisher
+ */
+public class FileCopyDemo {
+
+ public static void main(String[] args) {
+ setupDirectories();
+ ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("fileCopyDemo.xml", FileCopyDemo.class);
+ context.start();
+ }
+
+ private static void setupDirectories() {
+ String tmpDirPath = System.getProperty("java.io.tmpdir");
+ File parentDir = new File(tmpDirPath + File.separator + "spring-integration-samples");
+ File inDir = new File(parentDir, "input");
+ File outDir = new File(parentDir, "output");
+ if ((inDir.exists() || inDir.mkdirs()) && (outDir.exists() || outDir.mkdirs())) {
+ System.out.println("input directory is: " + inDir.getAbsolutePath());
+ System.out.println("output directory is: " + outDir.getAbsolutePath());
+ }
+ else {
+ System.err.println("failed to create directories within tmp dir: " + tmpDirPath);
+ System.exit(0);
+ }
+ }
+
+}
diff --git a/spring-integration-samples/src/main/java/org/springframework/integration/samples/filecopy/fileCopyDemo.xml b/spring-integration-samples/src/main/java/org/springframework/integration/samples/filecopy/fileCopyDemo.xml
new file mode 100644
index 0000000000..e1ac923ae8
--- /dev/null
+++ b/spring-integration-samples/src/main/java/org/springframework/integration/samples/filecopy/fileCopyDemo.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+