diff --git a/samples/zip/README.md b/samples/zip/README.md deleted file mode 100644 index c878398..0000000 --- a/samples/zip/README.md +++ /dev/null @@ -1,56 +0,0 @@ -Spring Integration Zip Sample -=================== - -This sample illustrates the usage of the Spring Integration Zip Extension. It uses the following components: - -* zip-transformer -* unzip-transformer - -You can run the application by either - -* running the "Main" class from within STS (Right-click on Main class --> Run As --> Java Application) -* or from the command line: - - mvn package - - mvn exec:java - -You should see a screen as the following: - -``` -========================================================= - - Welcome to the Spring Integration Zip Sample - - For more information please visit: - https://www.springsource.org/spring-integration - -========================================================= -17:08:41.883 INFO [org.springframework.integration.samples.zip.Main.main()][org.springframework.integration.samples.zip.SpringIntegrationUtils] -========================================================= - - Intput directory is: '/dev/spring-integration-extensions/samples/zip/input-zip' - Intput directory is: '/dev/spring-integration-extensions/samples/zip/input-uncompressed' - Output directory is: 'target/output/decompressedFilesOut' - Output directory is: 'target/output/zipFilesOut' - -========================================================= -17:08:41.887 INFO [org.springframework.integration.samples.zip.Main.main()][org.springframework.integration.samples.zip.Main] -========================================================= - - Please press 'q + Enter' to quit the application. - -========================================================= -``` -## Compressing Files - -Drop an uncompressed file into the **input-uncompressed** directory. The file will be compressed and stored under **target/output/zipFilesOut**. - -## Uncompressing Files - -Drop a compressed file into the **input-zip** directory. The file will be decompressed and stored under **target/output/decompressedFilesOut**. - --------------------------------------------------------------------------------- - -For help please take a look at the Spring Integration documentation: - -https://www.springsource.org/spring-integration - diff --git a/samples/zip/pom.xml b/samples/zip/pom.xml deleted file mode 100644 index 5c15c98..0000000 --- a/samples/zip/pom.xml +++ /dev/null @@ -1,95 +0,0 @@ - - 4.0.0 - - org.springframework.integration.samples - zip-sample - 1.0.0.BUILD-SNAPSHOT - jar - - zip-sample - https://projects.spring.io/spring-integration/ - - - UTF-8 - 2.0.0 - 2.17.2 - 4.13.2 - - - - - repo.spring.io.milestone - Spring Framework Maven Milestone Repository - https://repo.spring.io/libs-milestone - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.10.1 - - 1.8 - 1.8 - -Xlint:all - true - true - - - - org.codehaus.mojo - exec-maven-plugin - 3.0.0 - - org.springframework.integration.samples.zip.Main - - - - - - - - - - - junit - junit - ${junit.version} - test - - - - - - org.springframework.integration - spring-integration-zip - ${spring.integration.zip.version} - - - - - - org.apache.logging.log4j - log4j-jcl - ${log4j.version} - - - - org.apache.logging.log4j - log4j-slf4j-impl - ${log4j.version} - - - - - - commons-io - commons-io - 2.11.0 - - - - diff --git a/samples/zip/src/main/java/org/springframework/integration/samples/zip/Main.java b/samples/zip/src/main/java/org/springframework/integration/samples/zip/Main.java deleted file mode 100644 index a779b44..0000000 --- a/samples/zip/src/main/java/org/springframework/integration/samples/zip/Main.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright 2015-2020 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 - * - * https://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.zip; - -import java.util.Scanner; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.springframework.context.support.AbstractApplicationContext; -import org.springframework.context.support.ClassPathXmlApplicationContext; - - -/** - * Starts the Spring Context and will initialize the Spring Integration routes. - * - * @author Gunnar Hillert - * @author Gary Russell - * @author Artem Bilan - * - * @since 1.0 - * - */ -public final class Main { - - private static final Log LOGGER = LogFactory.getLog(Main.class); - - private Main() { - } - - /** - * Load the Spring Integration Application Context - * - * @param args - command line arguments - */ - public static void main(final String... args) { - - if (LOGGER.isInfoEnabled()) { - LOGGER.info("\n=========================================================" - + "\n " - + "\n Welcome to the Spring Integration Zip Sample " - + "\n " - + "\n For more information please visit: " - + "\n https://www.springsource.org/spring-integration " - + "\n " - + "\n========================================================="); - } - - final AbstractApplicationContext context = - new ClassPathXmlApplicationContext("classpath:META-INF/spring/integration/*-context.xml"); - - context.registerShutdownHook(); - - SpringIntegrationUtils.displayDirectories(context); - - final Scanner scanner = new Scanner(System.in); - - if (LOGGER.isInfoEnabled()) { - LOGGER.info("\n=========================================================" - + "\n " - + "\n Please press 'q + Enter' to quit the application. " - + "\n " - + "\n========================================================="); - } - - while (true) { - if (scanner.hasNext("q")) { - if (LOGGER.isInfoEnabled()) { - LOGGER.info("Exiting application...bye."); - } - scanner.close(); - System.exit(0); - } - } - } - -} diff --git a/samples/zip/src/main/java/org/springframework/integration/samples/zip/SpringIntegrationUtils.java b/samples/zip/src/main/java/org/springframework/integration/samples/zip/SpringIntegrationUtils.java deleted file mode 100644 index 4da0428..0000000 --- a/samples/zip/src/main/java/org/springframework/integration/samples/zip/SpringIntegrationUtils.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright 2015 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 - * - * https://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.zip; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.springframework.beans.DirectFieldAccessor; -import org.springframework.context.ApplicationContext; -import org.springframework.expression.Expression; -import org.springframework.integration.file.FileReadingMessageSource; -import org.springframework.integration.file.FileWritingMessageHandler; - -/** - * Displays the names of the input and output directories. - * - * @author Gunnar Hillert - * @since 1.0 - * - */ -public final class SpringIntegrationUtils { - - private static final Log logger = LogFactory.getLog(SpringIntegrationUtils.class); - - private SpringIntegrationUtils() { } - - /** - * Helper Method to dynamically determine and display input and output - * directories as defined in the Spring Integration context. - * - * @param context Spring Application Context - */ - public static void displayDirectories(final ApplicationContext context) { - - Map fileReadingMessageSources = context.getBeansOfType(FileReadingMessageSource.class); - - List inputDirectories = new ArrayList<>(); - - for (FileReadingMessageSource source : fileReadingMessageSources.values()) { - final File inDir = (File) new DirectFieldAccessor(source).getPropertyValue("directory"); - inputDirectories.add(inDir.getAbsolutePath()); - } - - - Map fileWritingMessageHandlers = context.getBeansOfType(FileWritingMessageHandler.class); - - List outputDirectories = new ArrayList<>(); - - for (final FileWritingMessageHandler messageHandler : fileWritingMessageHandlers.values()) { - final Expression outDir = (Expression) new DirectFieldAccessor(messageHandler).getPropertyValue("destinationDirectoryExpression"); - outputDirectories.add(outDir.getExpressionString()); - } - - final StringBuilder stringBuilder = new StringBuilder(); - - stringBuilder.append("\n========================================================="); - stringBuilder.append("\n"); - - for (final String inputDirectory : inputDirectories) { - stringBuilder.append("\n Input directory is: '" + inputDirectory + "'"); - } - - for (final String outputDirectory : outputDirectories) { - stringBuilder.append("\n Output directory is: '" + outputDirectory + "'"); - } - - stringBuilder.append("\n\n========================================================="); - - logger.info(stringBuilder.toString()); - - } - -} diff --git a/samples/zip/src/main/java/org/springframework/integration/samples/zip/TransformationHandler.java b/samples/zip/src/main/java/org/springframework/integration/samples/zip/TransformationHandler.java deleted file mode 100644 index bd21924..0000000 --- a/samples/zip/src/main/java/org/springframework/integration/samples/zip/TransformationHandler.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2015 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 - * - * https://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.zip; - -import java.io.File; -import java.io.IOException; -import java.util.Locale; - -import org.apache.commons.io.FileUtils; -import org.apache.commons.io.FilenameUtils; -import org.springframework.integration.annotation.Transformer; -import org.springframework.integration.file.FileHeaders; -import org.springframework.integration.support.MessageBuilder; -import org.springframework.messaging.Message; - -/** - * This Spring Integration transformation handler takes the input file, converts - * the file into a string, converts the file contents into an upper-case string - * and then sets a few Spring Integration message headers. - * - * @author Gunnar Hillert - * @since 1.0 - */ -public class TransformationHandler { - - /** - * Actual Spring Integration transformation handler. - * - * @param inputMessage Spring Integration input message - * @return New Spring Integration message with updated headers - */ - @Transformer - public Message handleFile(final Message inputMessage) { - - final File inputFile = inputMessage.getPayload(); - final String filename = inputFile.getName(); - final String fileExtension = FilenameUtils.getExtension(filename); - - final String inputAsString; - - try { - inputAsString = FileUtils.readFileToString(inputFile); - } catch (IOException e) { - throw new IllegalStateException(e); - } - - return MessageBuilder.withPayload(inputAsString.toUpperCase(Locale.ENGLISH)) - .setHeader(FileHeaders.FILENAME, filename) - .setHeader(FileHeaders.ORIGINAL_FILE, inputFile) - .setHeader("file_size", inputFile.length()) - .setHeader("file_extension", fileExtension) - .build(); - } -} diff --git a/samples/zip/src/main/resources/META-INF/spring/integration/spring-integration-context.xml b/samples/zip/src/main/resources/META-INF/spring/integration/spring-integration-context.xml deleted file mode 100644 index 4cfdb24..0000000 --- a/samples/zip/src/main/resources/META-INF/spring/integration/spring-integration-context.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/samples/zip/src/main/resources/log4j2.xml b/samples/zip/src/main/resources/log4j2.xml deleted file mode 100644 index 138645e..0000000 --- a/samples/zip/src/main/resources/log4j2.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/samples/zip/src/test/java/org/springframework/integration/samples/zip/SpringIntegrationProjectStartupTest.java b/samples/zip/src/test/java/org/springframework/integration/samples/zip/SpringIntegrationProjectStartupTest.java deleted file mode 100644 index a4425de..0000000 --- a/samples/zip/src/test/java/org/springframework/integration/samples/zip/SpringIntegrationProjectStartupTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2015 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 - * - * https://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.zip; - -import org.junit.Test; -import org.springframework.context.ApplicationContext; -import org.springframework.context.support.ClassPathXmlApplicationContext; - -import org.springframework.integration.samples.zip.SpringIntegrationUtils; - -/** - * Verify that the Spring Integration Application Context starts successfully. - * - * @author Gunnar Hillert - * @since 1.0 - * - */ -public class SpringIntegrationProjectStartupTest { - - @Test - public void testStartupOfSpringIntegrationContext() throws Exception{ - final ApplicationContext context - = new ClassPathXmlApplicationContext("/META-INF/spring/integration/spring-integration-context.xml", - SpringIntegrationProjectStartupTest.class); - SpringIntegrationUtils.displayDirectories(context); - Thread.sleep(2000); - } - -}