CAMEL-8090: camel-chunk added to kit
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/01056c16 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/01056c16 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/01056c16 Branch: refs/heads/master Commit: 01056c16e82918e30d8fa185e6be78ff9ff10b62 Parents: 7cf0422 Author: Claus Ibsen <davscl...@apache.org> Authored: Tue Dec 2 11:22:40 2014 +0100 Committer: Claus Ibsen <davscl...@apache.org> Committed: Tue Dec 2 11:22:40 2014 +0100 ---------------------------------------------------------------------- apache-camel/pom.xml | 4 +++ .../src/main/descriptors/common-bin.xml | 1 + .../camel/component/chunk/ChunkComponent.java | 34 ++++---------------- .../camel/component/chunk/ChunkEndpoint.java | 9 ++---- .../src/test/resources/log4j.properties | 29 +++++++++++++++-- parent/pom.xml | 5 +++ 6 files changed, 45 insertions(+), 37 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/01056c16/apache-camel/pom.xml ---------------------------------------------------------------------- diff --git a/apache-camel/pom.xml b/apache-camel/pom.xml index 966f375..ad7500b 100644 --- a/apache-camel/pom.xml +++ b/apache-camel/pom.xml @@ -133,6 +133,10 @@ </dependency> <dependency> <groupId>org.apache.camel</groupId> + <artifactId>camel-chunk</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> <artifactId>camel-cmis</artifactId> </dependency> <dependency> http://git-wip-us.apache.org/repos/asf/camel/blob/01056c16/apache-camel/src/main/descriptors/common-bin.xml ---------------------------------------------------------------------- diff --git a/apache-camel/src/main/descriptors/common-bin.xml b/apache-camel/src/main/descriptors/common-bin.xml index 6e25e10..f5422c7 100644 --- a/apache-camel/src/main/descriptors/common-bin.xml +++ b/apache-camel/src/main/descriptors/common-bin.xml @@ -44,6 +44,7 @@ <include>org.apache.camel:camel-cache</include> <include>org.apache.camel:camel-castor</include> <include>org.apache.camel:camel-cdi</include> + <include>org.apache.camel:camel-chunk</include> <include>org.apache.camel:camel-cmis</include> <include>org.apache.camel:camel-core</include> <include>org.apache.camel:camel-core-osgi</include> http://git-wip-us.apache.org/repos/asf/camel/blob/01056c16/components/camel-chunk/src/main/java/org/apache/camel/component/chunk/ChunkComponent.java ---------------------------------------------------------------------- diff --git a/components/camel-chunk/src/main/java/org/apache/camel/component/chunk/ChunkComponent.java b/components/camel-chunk/src/main/java/org/apache/camel/component/chunk/ChunkComponent.java index 24648a8..40b6fee 100644 --- a/components/camel-chunk/src/main/java/org/apache/camel/component/chunk/ChunkComponent.java +++ b/components/camel-chunk/src/main/java/org/apache/camel/component/chunk/ChunkComponent.java @@ -19,39 +19,17 @@ package org.apache.camel.component.chunk; import java.util.Map; import org.apache.camel.Endpoint; -import org.apache.camel.impl.DefaultComponent; -import org.apache.camel.util.ObjectHelper; +import org.apache.camel.impl.UriEndpointComponent; -/** - * Represents the component that manages {@link ChunksEndpoint}. - * - * @version - */ -public class ChunkComponent extends DefaultComponent { +public class ChunkComponent extends UriEndpointComponent { + + public ChunkComponent() { + super(ChunkEndpoint.class); + } @Override protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { ChunkEndpoint endpoint = new ChunkEndpoint(uri, this, remaining); - String encoding = getAndRemoveParameter(parameters, "encoding", String.class); - if (ObjectHelper.isNotEmpty(encoding)) { - endpoint.setEncoding(encoding); - } - String themesFolder = getAndRemoveParameter(parameters, "themesFolder", String.class); - if (ObjectHelper.isNotEmpty(themesFolder)) { - endpoint.setThemeFolder(themesFolder); - } - String themeSubfolder = getAndRemoveParameter(parameters, "themeSubfolder", String.class); - if (ObjectHelper.isNotEmpty(themeSubfolder)) { - endpoint.setThemeSubfolder(themeSubfolder); - } - String themeLayer = getAndRemoveParameter(parameters, "themeLayer", String.class); - if (ObjectHelper.isNotEmpty(themeLayer)) { - endpoint.setThemeLayer(themeLayer); - } - String extension = getAndRemoveParameter(parameters, "extension", String.class); - if (ObjectHelper.isNotEmpty(extension)) { - endpoint.setExtension(extension); - } setProperties(endpoint, parameters); return endpoint; } http://git-wip-us.apache.org/repos/asf/camel/blob/01056c16/components/camel-chunk/src/main/java/org/apache/camel/component/chunk/ChunkEndpoint.java ---------------------------------------------------------------------- diff --git a/components/camel-chunk/src/main/java/org/apache/camel/component/chunk/ChunkEndpoint.java b/components/camel-chunk/src/main/java/org/apache/camel/component/chunk/ChunkEndpoint.java index 4a9cd93..a9024cf 100644 --- a/components/camel-chunk/src/main/java/org/apache/camel/component/chunk/ChunkEndpoint.java +++ b/components/camel-chunk/src/main/java/org/apache/camel/component/chunk/ChunkEndpoint.java @@ -41,10 +41,7 @@ import static org.apache.camel.component.chunk.ChunkConstants.CHUNK_LAYER_SEPARA import static org.apache.camel.component.chunk.ChunkConstants.CHUNK_RESOURCE_URI; import static org.apache.camel.component.chunk.ChunkConstants.CHUNK_TEMPLATE; -/** - * Represents a Camel Chunk endpoint - */ -@UriEndpoint(scheme = "chunk", label = "templating") +@UriEndpoint(scheme = "chunk", label = "transformation") public class ChunkEndpoint extends ResourceEndpoint { private Theme theme; @@ -135,7 +132,7 @@ public class ChunkEndpoint extends ResourceEndpoint { * Create a Chunk template * * @param resourceReader Reader used to get template - * @param Theme The theme + * @param theme The theme * @return Chunk */ private Chunk createChunk(Reader resourceReader, Theme theme, boolean fromTemplate) throws IOException { @@ -145,7 +142,7 @@ public class ChunkEndpoint extends ResourceEndpoint { if (apcl != null) { Thread.currentThread().setContextClassLoader(apcl); } - Chunk newChunk = null; + Chunk newChunk; if (fromTemplate) { newChunk = theme.makeChunk(); String targetString = IOUtils.toString(resourceReader); http://git-wip-us.apache.org/repos/asf/camel/blob/01056c16/components/camel-chunk/src/test/resources/log4j.properties ---------------------------------------------------------------------- diff --git a/components/camel-chunk/src/test/resources/log4j.properties b/components/camel-chunk/src/test/resources/log4j.properties index 3b1bd38..aa6b147 100644 --- a/components/camel-chunk/src/test/resources/log4j.properties +++ b/components/camel-chunk/src/test/resources/log4j.properties @@ -1,10 +1,27 @@ +## ------------------------------------------------------------------------ +## Licensed to the Apache Software Foundation (ASF) under one or more +## contributor license agreements. See the NOTICE file distributed with +## this work for additional information regarding copyright ownership. +## The ASF licenses this file to You 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. +## ------------------------------------------------------------------------ + # -# The logging properties used +# The logging properties used for testing. # -log4j.rootLogger=INFO, out +log4j.rootLogger=INFO, file -# uncomment the following line to turn on Camel debugging #log4j.logger.org.apache.camel=DEBUG +#log4j.logger.org.apache.camel.component.chunk=DEBUG # CONSOLE appender not used by default log4j.appender.out=org.apache.log4j.ConsoleAppender @@ -12,3 +29,9 @@ log4j.appender.out.layout=org.apache.log4j.PatternLayout log4j.appender.out.layout.ConversionPattern=[%30.30t] %-30.30c{1} %-5p %m%n #log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n +# File appender +log4j.appender.file=org.apache.log4j.FileAppender +log4j.appender.file.layout=org.apache.log4j.PatternLayout +log4j.appender.file.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n +log4j.appender.file.file=target/camel-chunk-test.log +log4j.appender.file.append=true http://git-wip-us.apache.org/repos/asf/camel/blob/01056c16/parent/pom.xml ---------------------------------------------------------------------- diff --git a/parent/pom.xml b/parent/pom.xml index 9fdafb1..4d2e17a 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -654,6 +654,11 @@ <artifactId>camel-cdi</artifactId> <version>${project.version}</version> </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-chunk</artifactId> + <version>${project.version}</version> + </dependency> <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-cmis</artifactId>