Solving INT-185, INT-207, INT 201 - refactoring FileSource and FileTarget, splitting AbstractFileMapper in MessageCreator and MessageMapper, adding namespace support for configurable MessageCreator in FileSource and filename generator in FileTarget. Backup directory is not supported anymore, instead FileSource will not delete files and will ignore files already processed.
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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();
|
||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("fileCopyDemo-binary.xml",
|
||||
BinaryFileCopyDemo.class);
|
||||
context.start();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,13 +16,29 @@
|
||||
|
||||
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) {
|
||||
return input.toUpperCase() + "!!!";
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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 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();
|
||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("fileCopyDemo-file.xml",
|
||||
FileBasedFileCopyDemo.class);
|
||||
context.start();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,22 +18,14 @@ package org.springframework.integration.samples.filecopy;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
||||
/**
|
||||
* Demo of file source and target adapters.
|
||||
* Common functionality for the file demo.
|
||||
*
|
||||
* @author Mark Fisher
|
||||
* @author Marius Bogoevici
|
||||
*/
|
||||
public class FileCopyDemo {
|
||||
public class FileCopyDemoCommon {
|
||||
|
||||
public static void main(String[] args) {
|
||||
setupDirectories();
|
||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("fileCopyDemo.xml", FileCopyDemo.class);
|
||||
context.start();
|
||||
}
|
||||
|
||||
private static void setupDirectories() {
|
||||
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");
|
||||
@@ -47,5 +39,5 @@ public class FileCopyDemo {
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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 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();
|
||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("fileCopyDemo-text.xml",
|
||||
TextFileCopyDemo.class);
|
||||
context.start();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans:beans xmlns="http://www.springframework.org/schema/integration"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
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">
|
||||
|
||||
<beans:import resource="fileCopyDemo-common.xml"/>
|
||||
|
||||
<file-source id="fileSource" type="binary" directory="${java.io.tmpdir}/spring-integration-samples/input"/>
|
||||
|
||||
</beans:beans>
|
||||
@@ -24,8 +24,6 @@
|
||||
|
||||
<target-endpoint input-channel="channel2" target="fileTarget"/>
|
||||
|
||||
<file-source id="fileSource" directory="${java.io.tmpdir}/spring-integration-samples/input"/>
|
||||
|
||||
<file-target id="fileTarget" directory="${java.io.tmpdir}/spring-integration-samples/output"/>
|
||||
|
||||
<beans:bean id="exclaimer" class="org.springframework.integration.samples.filecopy.Exclaimer"/>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans:beans xmlns="http://www.springframework.org/schema/integration"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
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">
|
||||
|
||||
<beans:import resource="fileCopyDemo-common.xml"/>
|
||||
|
||||
<file-source id="fileSource" type="file" directory="${java.io.tmpdir}/spring-integration-samples/input"/>
|
||||
|
||||
</beans:beans>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans:beans xmlns="http://www.springframework.org/schema/integration"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
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">
|
||||
|
||||
<beans:import resource="fileCopyDemo-common.xml"/>
|
||||
|
||||
<file-source id="fileSource" type="text" directory="${java.io.tmpdir}/spring-integration-samples/input"/>
|
||||
|
||||
</beans:beans>
|
||||
Reference in New Issue
Block a user