Added filecopy to samples

This commit is contained in:
Mark Fisher
2009-07-01 17:00:21 +00:00
parent bb542aaed6
commit 1d17e7eecb
13 changed files with 334 additions and 1 deletions

View File

@@ -18,6 +18,7 @@
<fileset dir="${basedir}">
<include name="cafe/**" />
<include name="errorhandling/**"/>
<include name="filecopy/**"/>
<include name="helloworld/**"/>
<include name="jms/**"/>
<include name="oddeven/**"/>

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>filecopy</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.maven.ide.eclipse.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.maven.ide.eclipse.maven2Nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@@ -0,0 +1,11 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>spring-integration-samples</artifactId>
<groupId>org.springframework.integration</groupId>
<version>1.0.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>filecopy</groupId>
<artifactId>filecopy</artifactId>
<version>1.0.3</version>
</project>

View File

@@ -0,0 +1,33 @@
/*
* 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.samples.filecopy;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
* Demonstrating the file copy scenario using binary file source and target.
*
* @author Marius Bogoevici
*/
public class BinaryFileCopyDemo {
public static void main(String[] args) {
FileCopyDemoCommon.setupDirectories();
new ClassPathXmlApplicationContext("fileCopyDemo-binary.xml", BinaryFileCopyDemo.class);
}
}

View File

@@ -0,0 +1,44 @@
/*
* 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.samples.filecopy;
import java.io.File;
/**
* A class providing several handling methods for different types of payloads.
*
* @author Mark Fisher
* @author Marius Bogoevici
*/
public class Exclaimer {
public String exclaim(String input) {
System.out.println("Copying text: " + input);
return input.toUpperCase();
}
public File exclaim(File input) {
System.out.println("Copying file: " + input.getAbsolutePath());
return input;
}
public byte[] exclaim(byte[] input) {
System.out.println("Copying " + input.length + " bytes ...");
return new String(input).toUpperCase().getBytes();
}
}

View File

@@ -0,0 +1,33 @@
/*
* 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.samples.filecopy;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
* Demonstrating the file copy scenario using file-based source and target.
*
* @author Marius Bogoevici
*/
public class FileBasedFileCopyDemo {
public static void main(String[] args) {
FileCopyDemoCommon.setupDirectories();
new ClassPathXmlApplicationContext("fileCopyDemo-file.xml", FileBasedFileCopyDemo.class);
}
}

View File

@@ -0,0 +1,43 @@
/*
* 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.samples.filecopy;
import java.io.File;
/**
* Common functionality for the file demo.
*
* @author Marius Bogoevici
*/
public class FileCopyDemoCommon {
public 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);
}
}
}

View File

@@ -0,0 +1,35 @@
/*
* 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.samples.filecopy;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
* Demo of file source and target adapters.
*
* @author Mark Fisher
* @author Marius Bogoevici
*/
public class TextFileCopyDemo {
public static void main(String[] args) {
FileCopyDemoCommon.setupDirectories();
new ClassPathXmlApplicationContext("fileCopyDemo-text.xml", TextFileCopyDemo.class);
}
}

View File

@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:integration="http://www.springframework.org/schema/integration"
xmlns:file="http://www.springframework.org/schema/integration/file"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
http://www.springframework.org/schema/integration/file
http://www.springframework.org/schema/integration/file/spring-integration-file-1.0.xsd">
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
<file:inbound-channel-adapter id="filesIn"
directory="file:${java.io.tmpdir}/spring-integration-samples/input"/>
<file:file-to-bytes-transformer input-channel="filesIn" output-channel="bytes" delete-files="true"/>
<integration:channel id="bytes"/>
<integration:service-activator input-channel="bytes"
output-channel="filesOut"
ref="exclaimer" method="exclaim"/>
<file:outbound-channel-adapter id="filesOut" directory="${java.io.tmpdir}/spring-integration-samples/output"/>
<bean id="exclaimer" class="org.springframework.integration.samples.filecopy.Exclaimer"/>
<integration:poller id="poller" default="true">
<integration:interval-trigger interval="5000"/>
</integration:poller>
</beans>

View File

@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:integration="http://www.springframework.org/schema/integration"
xmlns:file="http://www.springframework.org/schema/integration/file"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
http://www.springframework.org/schema/integration/file
http://www.springframework.org/schema/integration/file/spring-integration-file-1.0.xsd">
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
<file:inbound-channel-adapter id="filesIn"
directory="file:${java.io.tmpdir}/spring-integration-samples/input">
<integration:poller>
<integration:interval-trigger interval="5000"/>
</integration:poller>
</file:inbound-channel-adapter>
<integration:service-activator input-channel="filesIn"
output-channel="filesOut"
ref="exclaimer" method="exclaim"/>
<file:outbound-channel-adapter id="filesOut" directory="${java.io.tmpdir}/spring-integration-samples/output"/>
<bean id="exclaimer" class="org.springframework.integration.samples.filecopy.Exclaimer"/>
</beans>

View File

@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:integration="http://www.springframework.org/schema/integration"
xmlns:file="http://www.springframework.org/schema/integration/file"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
http://www.springframework.org/schema/integration/file
http://www.springframework.org/schema/integration/file/spring-integration-file-1.0.xsd">
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
<file:inbound-channel-adapter id="filesIn"
directory="file:${java.io.tmpdir}/spring-integration-samples/input"
filename-pattern="[a-z]+.txt">
<integration:poller>
<integration:interval-trigger interval="5000"/>
</integration:poller>
</file:inbound-channel-adapter>
<file:file-to-string-transformer input-channel="filesIn" output-channel="strings"/>
<integration:channel id="strings"/>
<integration:service-activator input-channel="strings"
output-channel="filesOut"
ref="exclaimer" method="exclaim"/>
<file:outbound-channel-adapter id="filesOut" directory="${java.io.tmpdir}/spring-integration-samples/output"/>
<bean id="exclaimer" class="org.springframework.integration.samples.filecopy.Exclaimer"/>
</beans>

View File

@@ -9,11 +9,12 @@
<packaging>pom</packaging>
<name>Spring Integration Samples</name>
<properties>
<release.version>1.0.3.BUILD-20090701033844</release.version>
<release.version>1.0.3.RELEASE</release.version>
</properties>
<modules>
<module>cafe</module>
<module>errorhandling</module>
<module>filecopy</module>
<module>helloworld</module>
<module>jms</module>
<module>oddeven</module>