Component docs - Allow to explict specify javaType of UriPath/UriParam property to specify the preferred type to use
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/367eb657 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/367eb657 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/367eb657 Branch: refs/heads/camel-2.16.x Commit: 367eb6573c6078682c570a3c2a2c58c67d888c39 Parents: 294bb23 Author: Claus Ibsen <davscl...@apache.org> Authored: Sun Jan 3 11:48:38 2016 +0100 Committer: Claus Ibsen <davscl...@apache.org> Committed: Sun Jan 3 11:51:40 2016 +0100 ---------------------------------------------------------------------- .../camel/component/file/GenericFileEndpoint.java | 17 +++++++++-------- .../tools/apt/EndpointAnnotationProcessor.java | 9 +++++++++ .../main/java/org/apache/camel/spi/UriParam.java | 7 +++++++ .../main/java/org/apache/camel/spi/UriPath.java | 7 +++++++ 4 files changed, 32 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/367eb657/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java b/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java index 434af2f..9e13726 100644 --- a/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java +++ b/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java @@ -42,6 +42,7 @@ import org.apache.camel.spi.ExceptionHandler; import org.apache.camel.spi.FactoryFinder; import org.apache.camel.spi.IdempotentRepository; import org.apache.camel.spi.Language; +import org.apache.camel.spi.Metadata; import org.apache.camel.spi.UriParam; import org.apache.camel.util.FileUtil; import org.apache.camel.util.IOHelper; @@ -73,7 +74,7 @@ public abstract class GenericFileEndpoint<T> extends ScheduledPollEndpoint imple protected int bufferSize = FileUtil.BUFFER_SIZE; @UriParam protected String charset; - @UriParam + @UriParam(javaType = "java.lang.String") protected Expression fileName; // producer options @@ -84,7 +85,7 @@ public abstract class GenericFileEndpoint<T> extends ScheduledPollEndpoint imple protected GenericFileExist fileExist = GenericFileExist.Override; @UriParam(label = "producer") protected String tempPrefix; - @UriParam(label = "producer") + @UriParam(label = "producer", javaType = "java.lang.String") protected Expression tempFileName; @UriParam(label = "producer,advanced", defaultValue = "true") protected boolean eagerDeleteTargetFile = true; @@ -129,17 +130,17 @@ public abstract class GenericFileEndpoint<T> extends ScheduledPollEndpoint imple protected String include; @UriParam(label = "consumer,filter") protected String exclude; - @UriParam(label = "consumer,filter") + @UriParam(label = "consumer,filter", javaType = "java.lang.String") protected Expression move; - @UriParam(label = "consumer") + @UriParam(label = "consumer", javaType = "java.lang.String") protected Expression moveFailed; - @UriParam(label = "consumer") + @UriParam(label = "consumer", javaType = "java.lang.String") protected Expression preMove; - @UriParam(label = "producer") + @UriParam(label = "producer", javaType = "java.lang.String") protected Expression moveExisting; @UriParam(label = "consumer,filter", defaultValue = "false") protected Boolean idempotent; - @UriParam(label = "consumer,filter") + @UriParam(label = "consumer,filter", javaType = "java.lang.String") protected Expression idempotentKey; @UriParam(label = "consumer,filter") protected IdempotentRepository<String> idempotentRepository; @@ -154,7 +155,7 @@ public abstract class GenericFileEndpoint<T> extends ScheduledPollEndpoint imple protected String antExclude; @UriParam(label = "consumer,sort") protected Comparator<GenericFile<T>> sorter; - @UriParam(label = "consumer,sort") + @UriParam(label = "consumer,sort", javaType = "java.lang.String") protected Comparator<Exchange> sortBy; @UriParam(label = "consumer,sort") protected boolean shuffle; http://git-wip-us.apache.org/repos/asf/camel/blob/367eb657/tooling/apt/src/main/java/org/apache/camel/tools/apt/EndpointAnnotationProcessor.java ---------------------------------------------------------------------- diff --git a/tooling/apt/src/main/java/org/apache/camel/tools/apt/EndpointAnnotationProcessor.java b/tooling/apt/src/main/java/org/apache/camel/tools/apt/EndpointAnnotationProcessor.java index e662217..a8304b3 100644 --- a/tooling/apt/src/main/java/org/apache/camel/tools/apt/EndpointAnnotationProcessor.java +++ b/tooling/apt/src/main/java/org/apache/camel/tools/apt/EndpointAnnotationProcessor.java @@ -636,6 +636,11 @@ public class EndpointAnnotationProcessor extends AbstractAnnotationProcessor { } } + // the field type may be overloaded by another type + if (!Strings.isNullOrEmpty(path.javaType())) { + fieldTypeName = path.javaType(); + } + String group = EndpointHelper.labelAsGroupName(label, componentModel.isConsumerOnly(), componentModel.isProducerOnly()); EndpointPath ep = new EndpointPath(name, fieldTypeName, required, defaultValue, docComment, deprecated, group, label, isEnum, enums); endpointPaths.add(ep); @@ -707,6 +712,10 @@ public class EndpointAnnotationProcessor extends AbstractAnnotationProcessor { } } + // the field type may be overloaded by another type + if (!Strings.isNullOrEmpty(param.javaType())) { + fieldTypeName = param.javaType(); + } String group = EndpointHelper.labelAsGroupName(label, componentModel.isConsumerOnly(), componentModel.isProducerOnly()); EndpointOption option = new EndpointOption(name, fieldTypeName, required, defaultValue, defaultValueNote, http://git-wip-us.apache.org/repos/asf/camel/blob/367eb657/tooling/spi-annotations/src/main/java/org/apache/camel/spi/UriParam.java ---------------------------------------------------------------------- diff --git a/tooling/spi-annotations/src/main/java/org/apache/camel/spi/UriParam.java b/tooling/spi-annotations/src/main/java/org/apache/camel/spi/UriParam.java index 13e067d..59e4bcd 100644 --- a/tooling/spi-annotations/src/main/java/org/apache/camel/spi/UriParam.java +++ b/tooling/spi-annotations/src/main/java/org/apache/camel/spi/UriParam.java @@ -77,4 +77,11 @@ public @interface UriParam { */ String label() default ""; + /** + * To re-associate the preferred Java type of this parameter. + * <p/> + * This is used for parameters which are of a specialized type but can be configured by another Java type, such as from a String. + */ + String javaType() default ""; + } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/367eb657/tooling/spi-annotations/src/main/java/org/apache/camel/spi/UriPath.java ---------------------------------------------------------------------- diff --git a/tooling/spi-annotations/src/main/java/org/apache/camel/spi/UriPath.java b/tooling/spi-annotations/src/main/java/org/apache/camel/spi/UriPath.java index 8432509..23dac1f 100644 --- a/tooling/spi-annotations/src/main/java/org/apache/camel/spi/UriPath.java +++ b/tooling/spi-annotations/src/main/java/org/apache/camel/spi/UriPath.java @@ -79,4 +79,11 @@ public @interface UriPath { */ String label() default ""; + /** + * To re-associate the preferred Java type of this parameter. + * <p/> + * This is used for parameters which are of a specialized type but can be configured by another Java type, such as from a String. + */ + String javaType() default ""; + } \ No newline at end of file