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/1fbe1406
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/1fbe1406
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/1fbe1406

Branch: refs/heads/master
Commit: 1fbe1406129a8a04af28fcf15b1c6c7d4b78861f
Parents: b05aca9
Author: Claus Ibsen <davscl...@apache.org>
Authored: Wed Nov 26 10:23:24 2014 +0100
Committer: Claus Ibsen <davscl...@apache.org>
Committed: Wed Nov 26 10:23:24 2014 +0100

----------------------------------------------------------------------
 .../camel/component/hdfs/HdfsConfiguration.java | 45 +++++------
 .../component/hdfs2/HdfsConfiguration.java      | 45 +++++------
 .../infinispan/InfinispanEndpoint.java          |  2 +-
 .../apache/camel/component/jcr/JcrEndpoint.java | 83 +++++++++++++++-----
 .../component/jgroups/JGroupsEndpoint.java      |  2 +-
 5 files changed, 111 insertions(+), 66 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/1fbe1406/components/camel-hdfs/src/main/java/org/apache/camel/component/hdfs/HdfsConfiguration.java
----------------------------------------------------------------------
diff --git 
a/components/camel-hdfs/src/main/java/org/apache/camel/component/hdfs/HdfsConfiguration.java
 
b/components/camel-hdfs/src/main/java/org/apache/camel/component/hdfs/HdfsConfiguration.java
index 3c87468..189f20f 100644
--- 
a/components/camel-hdfs/src/main/java/org/apache/camel/component/hdfs/HdfsConfiguration.java
+++ 
b/components/camel-hdfs/src/main/java/org/apache/camel/component/hdfs/HdfsConfiguration.java
@@ -24,6 +24,7 @@ import java.util.Map;
 
 import org.apache.camel.spi.UriParam;
 import org.apache.camel.spi.UriParams;
+import org.apache.camel.spi.UriPath;
 import org.apache.camel.util.URISupport;
 import org.apache.hadoop.io.SequenceFile;
 
@@ -31,52 +32,52 @@ import org.apache.hadoop.io.SequenceFile;
 public class HdfsConfiguration {
 
     private URI uri;
-    @UriParam
+    @UriPath
     private String hostName;
-    @UriParam
+    @UriPath
     private int port = HdfsConstants.DEFAULT_PORT;
-    @UriParam
+    @UriPath
     private String path;
-    @UriParam
+    @UriParam(defaultValue = "true")
     private boolean overwrite = true;
-    @UriParam
+    @UriParam(defaultValue = "false")
     private boolean append;
-    @UriParam
+    @UriParam(defaultValue = "false")
     private boolean wantAppend;
-    @UriParam
+    @UriParam(defaultValue = "" + HdfsConstants.DEFAULT_BUFFERSIZE)
     private int bufferSize = HdfsConstants.DEFAULT_BUFFERSIZE;
-    @UriParam
+    @UriParam(defaultValue = "" + HdfsConstants.DEFAULT_REPLICATION)
     private short replication = HdfsConstants.DEFAULT_REPLICATION;
-    @UriParam
+    @UriParam(defaultValue = "" + HdfsConstants.DEFAULT_BLOCKSIZE)
     private long blockSize = HdfsConstants.DEFAULT_BLOCKSIZE;
-    @UriParam
+    @UriParam(defaultValue = "NONE")
     private SequenceFile.CompressionType compressionType = 
HdfsConstants.DEFAULT_COMPRESSIONTYPE;
-    @UriParam
+    @UriParam(defaultValue = "DEFAULT")
     private HdfsCompressionCodec compressionCodec = 
HdfsConstants.DEFAULT_CODEC;
-    @UriParam
+    @UriParam(defaultValue = "NORMAL_FILE")
     private HdfsFileType fileType = HdfsFileType.NORMAL_FILE;
-    @UriParam
+    @UriParam(defaultValue = "HDFS")
     private HdfsFileSystemType fileSystemType = HdfsFileSystemType.HDFS;
-    @UriParam
+    @UriParam(defaultValue = "NULL")
     private HdfsWritableFactories.WritableType keyType = 
HdfsWritableFactories.WritableType.NULL;
-    @UriParam
+    @UriParam(defaultValue = "BYTES")
     private HdfsWritableFactories.WritableType valueType = 
HdfsWritableFactories.WritableType.BYTES;
-    @UriParam
+    @UriParam(defaultValue = HdfsConstants.DEFAULT_OPENED_SUFFIX)
     private String openedSuffix = HdfsConstants.DEFAULT_OPENED_SUFFIX;
-    @UriParam
+    @UriParam(defaultValue = HdfsConstants.DEFAULT_READ_SUFFIX)
     private String readSuffix = HdfsConstants.DEFAULT_READ_SUFFIX;
     @UriParam
     private long initialDelay;
-    @UriParam
+    @UriParam(defaultValue = "" + HdfsConstants.DEFAULT_DELAY)
     private long delay = HdfsConstants.DEFAULT_DELAY;
-    @UriParam
+    @UriParam(defaultValue = HdfsConstants.DEFAULT_PATTERN)
     private String pattern = HdfsConstants.DEFAULT_PATTERN;
-    @UriParam
+    @UriParam(defaultValue = "" + HdfsConstants.DEFAULT_BUFFERSIZE)
     private int chunkSize = HdfsConstants.DEFAULT_BUFFERSIZE;
-    @UriParam
+    @UriParam(defaultValue = "" + HdfsConstants.DEFAULT_CHECK_IDLE_INTERVAL)
     private int checkIdleInterval = HdfsConstants.DEFAULT_CHECK_IDLE_INTERVAL;
     private List<HdfsProducer.SplitStrategy> splitStrategies;
-    @UriParam
+    @UriParam(defaultValue = "true")
     private boolean connectOnStartup = true;
     @UriParam
     private String owner;

http://git-wip-us.apache.org/repos/asf/camel/blob/1fbe1406/components/camel-hdfs2/src/main/java/org/apache/camel/component/hdfs2/HdfsConfiguration.java
----------------------------------------------------------------------
diff --git 
a/components/camel-hdfs2/src/main/java/org/apache/camel/component/hdfs2/HdfsConfiguration.java
 
b/components/camel-hdfs2/src/main/java/org/apache/camel/component/hdfs2/HdfsConfiguration.java
index 6110059..a528c22 100644
--- 
a/components/camel-hdfs2/src/main/java/org/apache/camel/component/hdfs2/HdfsConfiguration.java
+++ 
b/components/camel-hdfs2/src/main/java/org/apache/camel/component/hdfs2/HdfsConfiguration.java
@@ -24,6 +24,7 @@ import java.util.Map;
 
 import org.apache.camel.spi.UriParam;
 import org.apache.camel.spi.UriParams;
+import org.apache.camel.spi.UriPath;
 import org.apache.camel.util.URISupport;
 import org.apache.hadoop.io.SequenceFile;
 
@@ -31,52 +32,52 @@ import org.apache.hadoop.io.SequenceFile;
 public class HdfsConfiguration {
 
     private URI uri;
-    @UriParam
+    @UriPath
     private String hostName;
-    @UriParam
+    @UriPath
     private int port = HdfsConstants.DEFAULT_PORT;
-    @UriParam
+    @UriPath
     private String path;
-    @UriParam
+    @UriParam(defaultValue = "true")
     private boolean overwrite = true;
-    @UriParam
+    @UriParam(defaultValue = "false")
     private boolean append;
-    @UriParam
+    @UriParam(defaultValue = "false")
     private boolean wantAppend;
-    @UriParam
+    @UriParam(defaultValue = "" + HdfsConstants.DEFAULT_BUFFERSIZE)
     private int bufferSize = HdfsConstants.DEFAULT_BUFFERSIZE;
-    @UriParam
+    @UriParam(defaultValue = "" + HdfsConstants.DEFAULT_REPLICATION)
     private short replication = HdfsConstants.DEFAULT_REPLICATION;
-    @UriParam
+    @UriParam(defaultValue = "" + HdfsConstants.DEFAULT_BLOCKSIZE)
     private long blockSize = HdfsConstants.DEFAULT_BLOCKSIZE;
-    @UriParam
+    @UriParam(defaultValue = "NONE")
     private SequenceFile.CompressionType compressionType = 
HdfsConstants.DEFAULT_COMPRESSIONTYPE;
-    @UriParam
+    @UriParam(defaultValue = "DEFAULT")
     private HdfsCompressionCodec compressionCodec = 
HdfsConstants.DEFAULT_CODEC;
-    @UriParam
+    @UriParam(defaultValue = "NORMAL_FILE")
     private HdfsFileType fileType = HdfsFileType.NORMAL_FILE;
-    @UriParam
+    @UriParam(defaultValue = "HDFS")
     private HdfsFileSystemType fileSystemType = HdfsFileSystemType.HDFS;
-    @UriParam
+    @UriParam(defaultValue = "NULL")
     private HdfsWritableFactories.WritableType keyType = 
HdfsWritableFactories.WritableType.NULL;
-    @UriParam
+    @UriParam(defaultValue = "BYTES")
     private HdfsWritableFactories.WritableType valueType = 
HdfsWritableFactories.WritableType.BYTES;
-    @UriParam
+    @UriParam(defaultValue = HdfsConstants.DEFAULT_OPENED_SUFFIX)
     private String openedSuffix = HdfsConstants.DEFAULT_OPENED_SUFFIX;
-    @UriParam
+    @UriParam(defaultValue = HdfsConstants.DEFAULT_READ_SUFFIX)
     private String readSuffix = HdfsConstants.DEFAULT_READ_SUFFIX;
     @UriParam
     private long initialDelay;
-    @UriParam
+    @UriParam(defaultValue = "" + HdfsConstants.DEFAULT_DELAY)
     private long delay = HdfsConstants.DEFAULT_DELAY;
-    @UriParam
+    @UriParam(defaultValue = HdfsConstants.DEFAULT_PATTERN)
     private String pattern = HdfsConstants.DEFAULT_PATTERN;
-    @UriParam
+    @UriParam(defaultValue = "" + HdfsConstants.DEFAULT_BUFFERSIZE)
     private int chunkSize = HdfsConstants.DEFAULT_BUFFERSIZE;
-    @UriParam
+    @UriParam(defaultValue = "" + HdfsConstants.DEFAULT_CHECK_IDLE_INTERVAL)
     private int checkIdleInterval = HdfsConstants.DEFAULT_CHECK_IDLE_INTERVAL;
     private List<HdfsProducer.SplitStrategy> splitStrategies;
-    @UriParam
+    @UriParam(defaultValue = "true")
     private boolean connectOnStartup = true;
     @UriParam
     private String owner;

http://git-wip-us.apache.org/repos/asf/camel/blob/1fbe1406/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanEndpoint.java
----------------------------------------------------------------------
diff --git 
a/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanEndpoint.java
 
b/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanEndpoint.java
index 062e33f..2fbd97d 100644
--- 
a/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanEndpoint.java
+++ 
b/components/camel-infinispan/src/main/java/org/apache/camel/component/infinispan/InfinispanEndpoint.java
@@ -23,7 +23,7 @@ import org.apache.camel.impl.DefaultEndpoint;
 import org.apache.camel.spi.UriEndpoint;
 import org.apache.camel.spi.UriParam;
 
-@UriEndpoint(scheme = "infinispan", consumerClass = InfinispanConsumer.class, 
label = "cache,datagrid")
+@UriEndpoint(scheme = "infinispan", consumerClass = InfinispanConsumer.class, 
label = "cache,datagrid,clustering")
 public class InfinispanEndpoint extends DefaultEndpoint {
     @UriParam
     private InfinispanConfiguration configuration;

http://git-wip-us.apache.org/repos/asf/camel/blob/1fbe1406/components/camel-jcr/src/main/java/org/apache/camel/component/jcr/JcrEndpoint.java
----------------------------------------------------------------------
diff --git 
a/components/camel-jcr/src/main/java/org/apache/camel/component/jcr/JcrEndpoint.java
 
b/components/camel-jcr/src/main/java/org/apache/camel/component/jcr/JcrEndpoint.java
index 4a0f39d..ae2233d 100644
--- 
a/components/camel-jcr/src/main/java/org/apache/camel/component/jcr/JcrEndpoint.java
+++ 
b/components/camel-jcr/src/main/java/org/apache/camel/component/jcr/JcrEndpoint.java
@@ -18,7 +18,6 @@ package org.apache.camel.component.jcr;
 
 import java.net.URI;
 import java.net.URISyntaxException;
-
 import javax.jcr.Credentials;
 import javax.jcr.Repository;
 import javax.jcr.SimpleCredentials;
@@ -30,31 +29,39 @@ import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.impl.DefaultEndpoint;
 import org.apache.camel.spi.UriEndpoint;
 import org.apache.camel.spi.UriParam;
+import org.apache.camel.spi.UriPath;
 import org.apache.camel.util.ObjectHelper;
 
 /**
  * A JCR endpoint
  */
-@UriEndpoint(scheme = "jcr", consumerClass = JcrConsumer.class)
+@UriEndpoint(scheme = "jcr", consumerClass = JcrConsumer.class, label = 
"cms,database")
 public class JcrEndpoint extends DefaultEndpoint {
 
     private Credentials credentials;
     private Repository repository;
-    private String base;
 
+    @UriPath
+    private String host;
+    @UriPath
+    private String base;
     @UriParam
-    private int eventTypes;
+    private String username;
     @UriParam
+    private String password;
+    @UriParam
+    private int eventTypes;
+    @UriParam(defaultValue = "false")
     private boolean deep;
     @UriParam
     private String uuids;
     @UriParam
     private String nodeTypeNames;
-    @UriParam
+    @UriParam(defaultValue = "false")
     private boolean noLocal;
-    @UriParam
+    @UriParam(defaultValue = "3000")
     private long sessionLiveCheckIntervalOnStart = 3000L;
-    @UriParam
+    @UriParam(defaultValue = "60000")
     private long sessionLiveCheckInterval = 60000L;
 
     protected JcrEndpoint(String endpointUri, JcrComponent component) {
@@ -63,16 +70,10 @@ public class JcrEndpoint extends DefaultEndpoint {
             URI uri = new URI(endpointUri);
             if (uri.getUserInfo() != null) {
                 String[] creds = uri.getUserInfo().split(":");
-                if (creds != null) {
-                    String username = creds[0];
-                    String password = creds.length > 1 ? creds[1] : "";
-                    this.credentials = new SimpleCredentials(username, 
password.toCharArray());
-                }
-            }
-            this.repository = 
component.getCamelContext().getRegistry().lookupByNameAndType(uri.getHost(), 
Repository.class);
-            if (repository == null) {
-                throw new RuntimeCamelException("No JCR repository defined 
under '" + uri.getHost() + "'");
+                this.username = creds[0];
+                this.password = creds.length > 1 ? creds[1] : "";
             }
+            this.host = uri.getHost();
             this.base = uri.getPath().replaceAll("^/", "");
         } catch (URISyntaxException e) {
             throw new IllegalArgumentException("Invalid URI: " + endpointUri, 
e);
@@ -93,6 +94,31 @@ public class JcrEndpoint extends DefaultEndpoint {
         return true;
     }
 
+    @Override
+    protected void doStart() throws Exception {
+        super.doStart();
+        ObjectHelper.notEmpty(host, "host", this);
+
+        this.repository = 
getCamelContext().getRegistry().lookupByNameAndType(host, Repository.class);
+        if (repository == null) {
+            throw new RuntimeCamelException("No JCR repository defined under 
'" + host + "'");
+        }
+        if (username != null && password != null) {
+            this.credentials = new SimpleCredentials(username, 
password.toCharArray());
+        }
+    }
+
+    public String getHost() {
+        return host;
+    }
+
+    /**
+     * Name of the {@link javax.jcr.Repository} to lookup from the Camel 
registry to be used.
+     */
+    public void setHost(String host) {
+        this.host = host;
+    }
+
     /**
      * Get the {@link Repository}
      * 
@@ -112,7 +138,7 @@ public class JcrEndpoint extends DefaultEndpoint {
     }
 
     /**
-     * Get the base node when accessing the reposititory
+     * Get the base node when accessing the repository
      * 
      * @return the base node
      */
@@ -120,6 +146,26 @@ public class JcrEndpoint extends DefaultEndpoint {
         return base;
     }
 
+    public void setBase(String base) {
+        this.base = base;
+    }
+
+    public String getUsername() {
+        return username;
+    }
+
+    public void setUsername(String username) {
+        this.username = username;
+    }
+
+    public String getPassword() {
+        return password;
+    }
+
+    public void setPassword(String password) {
+        this.password = password;
+    }
+
     /**
      * <code>eventTypes</code> (a combination of one or more event types 
encoded
      * as a bit mask value such as javax.jcr.observation.Event.NODE_ADDED, 
javax.jcr.observation.Event.NODE_REMOVED, etc.).
@@ -166,7 +212,6 @@ public class JcrEndpoint extends DefaultEndpoint {
      * When a comma separated <code>nodeTypeName</code> list string is set, 
only events whose associated parent node has
      * one of the node types (or a subtype of one of the node types) in this
      * list will be received.
-     * @return
      */
     public String getNodeTypeNames() {
         return nodeTypeNames;
@@ -211,8 +256,6 @@ public class JcrEndpoint extends DefaultEndpoint {
     /**
      * Interval in milliseconds to wait before each session live checking
      * The default value is 60000 ms.
-     * 
-     * @return
      */
     public long getSessionLiveCheckInterval() {
         return sessionLiveCheckInterval;

http://git-wip-us.apache.org/repos/asf/camel/blob/1fbe1406/components/camel-jgroups/src/main/java/org/apache/camel/component/jgroups/JGroupsEndpoint.java
----------------------------------------------------------------------
diff --git 
a/components/camel-jgroups/src/main/java/org/apache/camel/component/jgroups/JGroupsEndpoint.java
 
b/components/camel-jgroups/src/main/java/org/apache/camel/component/jgroups/JGroupsEndpoint.java
index b6f7613..d823c1e 100644
--- 
a/components/camel-jgroups/src/main/java/org/apache/camel/component/jgroups/JGroupsEndpoint.java
+++ 
b/components/camel-jgroups/src/main/java/org/apache/camel/component/jgroups/JGroupsEndpoint.java
@@ -34,7 +34,7 @@ import org.jgroups.View;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-@UriEndpoint(scheme = "jgroups", consumerClass = JGroupsConsumer.class, label 
= "messaging")
+@UriEndpoint(scheme = "jgroups", consumerClass = JGroupsConsumer.class, label 
= "clustering,messaging")
 public class JGroupsEndpoint extends DefaultEndpoint {
 
     public static final String HEADER_JGROUPS_ORIGINAL_MESSAGE = 
"JGROUPS_ORIGINAL_MESSAGE";

Reply via email to