Repository: camel Updated Branches: refs/heads/master a765a1628 -> 37a31c283
CAMEL-8038: Fixed @UriPath Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/b05aca90 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/b05aca90 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/b05aca90 Branch: refs/heads/master Commit: b05aca90fef796137016df17f44e506dbd169efa Parents: a765a16 Author: Claus Ibsen <davscl...@apache.org> Authored: Wed Nov 26 10:00:40 2014 +0100 Committer: Claus Ibsen <davscl...@apache.org> Committed: Wed Nov 26 10:00:40 2014 +0100 ---------------------------------------------------------------------- .../component/weather/WeatherConfiguration.java | 15 +++- .../component/weather/WeatherEndpoint.java | 2 +- .../camel/component/yammer/YammerComponent.java | 1 + .../component/yammer/YammerConfiguration.java | 14 +++- .../camel/component/yammer/YammerEndpoint.java | 4 +- .../zookeeper/ZooKeeperConfiguration.java | 43 +++++++--- .../component/zookeeper/ZooKeeperEndpoint.java | 2 +- .../tools/apt/EndpointAnnotationProcessor.java | 87 +++++++++++--------- 8 files changed, 111 insertions(+), 57 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/b05aca90/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherConfiguration.java ---------------------------------------------------------------------- diff --git a/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherConfiguration.java b/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherConfiguration.java index a86b97e..a47b7d3 100644 --- a/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherConfiguration.java +++ b/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherConfiguration.java @@ -21,6 +21,7 @@ import java.util.Scanner; import org.apache.camel.spi.UriParam; import org.apache.camel.spi.UriParams; +import org.apache.camel.spi.UriPath; import org.codehaus.jackson.JsonNode; import org.codehaus.jackson.map.ObjectMapper; @@ -34,6 +35,8 @@ public class WeatherConfiguration { private final WeatherComponent component; + @UriPath(description = "The name value is not used.") + private String name; @UriParam private String location = ""; @UriParam @@ -42,9 +45,9 @@ public class WeatherConfiguration { private String lon; @UriParam private String period = ""; - @UriParam + @UriParam(defaultValue = "JSON") private WeatherMode mode = JSON; - @UriParam + @UriParam(defaultValue = "METRIC") private WeatherUnits units = METRIC; @UriParam private String headerName; @@ -70,6 +73,14 @@ public class WeatherConfiguration { } } + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + public WeatherMode getMode() { return mode; } http://git-wip-us.apache.org/repos/asf/camel/blob/b05aca90/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherEndpoint.java ---------------------------------------------------------------------- diff --git a/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherEndpoint.java b/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherEndpoint.java index 6caa8f4..d7a7e10 100644 --- a/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherEndpoint.java +++ b/components/camel-weather/src/main/java/org/apache/camel/component/weather/WeatherEndpoint.java @@ -26,7 +26,7 @@ import org.apache.camel.spi.UriParam; /** * Weather Endpoint */ -@UriEndpoint(scheme = "weather", consumerClass = WeatherConsumer.class) +@UriEndpoint(scheme = "weather", consumerClass = WeatherConsumer.class, label = "api") public class WeatherEndpoint extends DefaultPollingEndpoint { @UriParam http://git-wip-us.apache.org/repos/asf/camel/blob/b05aca90/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/YammerComponent.java ---------------------------------------------------------------------- diff --git a/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/YammerComponent.java b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/YammerComponent.java index fce7c94..2655beb 100644 --- a/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/YammerComponent.java +++ b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/YammerComponent.java @@ -43,6 +43,7 @@ public class YammerComponent extends DefaultComponent { endpointConfig.setConsumerSecret(consumerSecret); endpointConfig.setAccessToken(accessToken); endpointConfig.setFunction(remaining); + endpointConfig.setFunctionType(YammerFunctionType.fromUri(remaining)); // and then override from parameters setProperties(endpointConfig, parameters); http://git-wip-us.apache.org/repos/asf/camel/blob/b05aca90/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/YammerConfiguration.java ---------------------------------------------------------------------- diff --git a/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/YammerConfiguration.java b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/YammerConfiguration.java index f2b813e..d679d72 100644 --- a/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/YammerConfiguration.java +++ b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/YammerConfiguration.java @@ -18,10 +18,14 @@ package org.apache.camel.component.yammer; import org.apache.camel.spi.UriParam; import org.apache.camel.spi.UriParams; +import org.apache.camel.spi.UriPath; @UriParams public class YammerConfiguration { + @UriPath(name = "function") + private YammerFunctionType functionType; + private String function; @UriParam private String consumerKey; @UriParam @@ -42,8 +46,6 @@ public class YammerConfiguration { private String threaded; @UriParam private String userId; - - private String function; private ApiRequestor requestor; public String getConsumerKey() { @@ -78,6 +80,14 @@ public class YammerConfiguration { this.accessToken = accessToken; } + public YammerFunctionType getFunctionType() { + return functionType; + } + + public void setFunctionType(YammerFunctionType functionType) { + this.functionType = functionType; + } + public String getFunction() { return function; } http://git-wip-us.apache.org/repos/asf/camel/blob/b05aca90/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/YammerEndpoint.java ---------------------------------------------------------------------- diff --git a/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/YammerEndpoint.java b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/YammerEndpoint.java index 663c4ac..95be167 100644 --- a/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/YammerEndpoint.java +++ b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/YammerEndpoint.java @@ -26,7 +26,7 @@ import org.apache.camel.spi.UriParam; /** * Represents a Yammer endpoint. */ -@UriEndpoint(scheme = "yammer", consumerClass = YammerMessagePollingConsumer.class) +@UriEndpoint(scheme = "yammer", consumerClass = YammerMessagePollingConsumer.class, label = "social") public class YammerEndpoint extends ScheduledPollEndpoint { @UriParam @@ -48,7 +48,7 @@ public class YammerEndpoint extends ScheduledPollEndpoint { } public Consumer createConsumer(Processor processor) throws Exception { - switch (YammerFunctionType.fromUri(config.getFunction())) { + switch (config.getFunctionType()) { case MESSAGES: case ALGO: case FOLLOWING: http://git-wip-us.apache.org/repos/asf/camel/blob/b05aca90/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/ZooKeeperConfiguration.java ---------------------------------------------------------------------- diff --git a/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/ZooKeeperConfiguration.java b/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/ZooKeeperConfiguration.java index 242101f..65b1cab 100644 --- a/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/ZooKeeperConfiguration.java +++ b/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/ZooKeeperConfiguration.java @@ -22,6 +22,8 @@ import java.util.List; import org.apache.camel.RuntimeCamelException; import org.apache.camel.spi.UriParam; import org.apache.camel.spi.UriParams; +import org.apache.camel.spi.UriPath; +import org.apache.camel.util.CollectionStringBuffer; /** * <code>ZookeeperConfiguration</code> encapsulates the configuration used to @@ -35,24 +37,26 @@ public class ZooKeeperConfiguration implements Cloneable { private transient boolean changed; - @UriParam - private int timeout = 5000; - @UriParam - private long backoff = 5000; + @UriPath + private String serverUrls; private List<String> servers; - @UriParam + @UriPath private String path; - @UriParam + @UriParam(defaultValue = "5000") + private int timeout = 5000; + @UriParam(defaultValue = "5000") + private long backoff = 5000; + @UriParam(defaultValue = "true") private boolean awaitExistence = true; - @UriParam + @UriParam(defaultValue = "false") private boolean repeat; - @UriParam + @UriParam(defaultValue = "false") private boolean listChildren; - @UriParam + @UriParam(defaultValue = "false") private boolean shouldCreate; - @UriParam + @UriParam(defaultValue = "false") private String createMode; - @UriParam + @UriParam(defaultValue = "true") private boolean sendEmptyMessageOnDelete = true; public void addZookeeperServer(String server) { @@ -67,6 +71,20 @@ public class ZooKeeperConfiguration implements Cloneable { return servers; } + /** + * The zookeeper server hosts (multiple servers can be separated by comma) + */ + public String getServerUrls() { + if (servers != null) { + CollectionStringBuffer csb = new CollectionStringBuffer(","); + for (String server : servers) { + csb.append(server); + } + return csb.toString(); + } + return null; + } + public void setServers(List<String> servers) { this.servers = servers; } @@ -106,6 +124,9 @@ public class ZooKeeperConfiguration implements Cloneable { } + /** + * The zookeeper path + */ public void setPath(String path) { this.path = path; } http://git-wip-us.apache.org/repos/asf/camel/blob/b05aca90/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/ZooKeeperEndpoint.java ---------------------------------------------------------------------- diff --git a/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/ZooKeeperEndpoint.java b/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/ZooKeeperEndpoint.java index 04eea3d..5086736 100644 --- a/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/ZooKeeperEndpoint.java +++ b/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/ZooKeeperEndpoint.java @@ -33,7 +33,7 @@ import org.apache.camel.spi.UriParam; * <code>ZooKeeperEndpoint</code> */ @ManagedResource(description = "ZooKeeper Endpoint") -@UriEndpoint(scheme = "zookeeper", consumerClass = ZooKeeperConsumer.class) +@UriEndpoint(scheme = "zookeeper", consumerClass = ZooKeeperConsumer.class, label = "clustering") public class ZooKeeperEndpoint extends DefaultEndpoint { @UriParam private ZooKeeperConfiguration configuration; http://git-wip-us.apache.org/repos/asf/camel/blob/b05aca90/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 7042ea0..7273b44 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 @@ -351,25 +351,7 @@ public class EndpointAnnotationProcessor extends AbstractProcessor { String fieldTypeName = fieldType.toString(); TypeElement fieldTypeElement = findTypeElement(roundEnv, fieldTypeName); - String docComment = elementUtils.getDocComment(fieldElement); - if (isNullOrEmpty(docComment)) { - String setter = "set" + fieldName.substring(0, 1).toUpperCase(); - if (fieldName.length() > 1) { - setter += fieldName.substring(1); - } - // lets find the setter - List<ExecutableElement> methods = ElementFilter.methodsIn(classElement.getEnclosedElements()); - for (ExecutableElement method : methods) { - String methodName = method.getSimpleName().toString(); - if (setter.equals(methodName) && method.getParameters().size() == 1) { - String doc = elementUtils.getDocComment(method); - if (!isNullOrEmpty(doc)) { - docComment = doc; - break; - } - } - } - } + String docComment = findJavaDoc(elementUtils, fieldElement, fieldName, classElement); if (isNullOrEmpty(docComment)) { docComment = path.description(); } @@ -421,25 +403,7 @@ public class EndpointAnnotationProcessor extends AbstractProcessor { } findClassProperties(writer, roundEnv, endpointPaths, endpointOptions, fieldTypeElement, nestedPrefix); } else { - String docComment = elementUtils.getDocComment(fieldElement); - if (isNullOrEmpty(docComment)) { - String setter = "set" + fieldName.substring(0, 1).toUpperCase(); - if (fieldName.length() > 1) { - setter += fieldName.substring(1); - } - // lets find the setter - List<ExecutableElement> methods = ElementFilter.methodsIn(classElement.getEnclosedElements()); - for (ExecutableElement method : methods) { - String methodName = method.getSimpleName().toString(); - if (setter.equals(methodName) && method.getParameters().size() == 1) { - String doc = elementUtils.getDocComment(method); - if (!isNullOrEmpty(doc)) { - docComment = doc; - break; - } - } - } - } + String docComment = findJavaDoc(elementUtils, fieldElement, fieldName, classElement); if (isNullOrEmpty(docComment)) { docComment = param.description(); } @@ -480,6 +444,53 @@ public class EndpointAnnotationProcessor extends AbstractProcessor { } } + protected String findJavaDoc(Elements elementUtils, VariableElement fieldElement, String fieldName, TypeElement classElement) { + String answer = elementUtils.getDocComment(fieldElement); + if (isNullOrEmpty(answer)) { + String setter = "set" + fieldName.substring(0, 1).toUpperCase(); + if (fieldName.length() > 1) { + setter += fieldName.substring(1); + } + // lets find the setter + List<ExecutableElement> methods = ElementFilter.methodsIn(classElement.getEnclosedElements()); + for (ExecutableElement method : methods) { + String methodName = method.getSimpleName().toString(); + if (setter.equals(methodName) && method.getParameters().size() == 1) { + String doc = elementUtils.getDocComment(method); + if (!isNullOrEmpty(doc)) { + answer = doc; + break; + } + } + } + + // lets find the getter + if (answer == null) { + String getter1 = "get" + fieldName.substring(0, 1).toUpperCase(); + if (fieldName.length() > 1) { + getter1 += fieldName.substring(1); + } + String getter2 = "is" + fieldName.substring(0, 1).toUpperCase(); + if (fieldName.length() > 1) { + getter2 += fieldName.substring(1); + } + // lets find the getter + methods = ElementFilter.methodsIn(classElement.getEnclosedElements()); + for (ExecutableElement method : methods) { + String methodName = method.getSimpleName().toString(); + if ((getter1.equals(methodName) || getter2.equals(methodName)) && method.getParameters().size() == 0) { + String doc = elementUtils.getDocComment(method); + if (!isNullOrEmpty(doc)) { + answer = doc; + break; + } + } + } + } + } + return answer; + } + protected TypeElement findTypeElement(RoundEnvironment roundEnv, String className) { if (isNullOrEmpty(className) || "java.lang.Object".equals(className)) { return null;