This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push:
new ddb28b7 camel-arangodb: add components attributes (#4028)
ddb28b7 is described below
commit ddb28b739cd5968eabf1889724889217bfe968e8
Author: Zineb BENDHIBA <[email protected]>
AuthorDate: Wed Jul 22 15:29:55 2020 +0200
camel-arangodb: add components attributes (#4028)
---
.../arangodb/ArangoDbComponentConfigurer.java | 28 +++++
.../arangodb/ArangoDbEndpointConfigurer.java | 24 ++---
.../apache/camel/component/arangodb/arangodb.json | 21 ++--
.../src/main/docs/arangodb-component.adoc | 11 +-
.../component/arangodb/ArangoDbComponent.java | 38 ++++++-
...oDbEndpoint.java => ArangoDbConfiguration.java} | 85 +++------------
.../camel/component/arangodb/ArangoDbEndpoint.java | 119 +++------------------
.../camel/component/arangodb/ArangoDbProducer.java | 8 +-
.../arangodb/ArangoCollectionDeleteTest.java | 2 +-
.../arangodb/ArangoCollectionFindByKeyTest.java | 2 +-
.../arangodb/ArangoCollectionQueryTest.java | 2 +-
.../arangodb/ArangoCollectionSaveTest.java | 2 +-
.../arangodb/ArangoCollectionUpdateTest.java | 2 +-
.../component/arangodb/ArangoDbComponentTest.java | 46 ++++++++
.../dsl/ArangodbComponentBuilderFactory.java | 96 +++++++++++++++++
.../builder/endpoint/StaticEndpointBuilders.java | 4 +-
16 files changed, 280 insertions(+), 210 deletions(-)
diff --git
a/components/camel-arangodb/src/generated/java/org/apache/camel/component/arangodb/ArangoDbComponentConfigurer.java
b/components/camel-arangodb/src/generated/java/org/apache/camel/component/arangodb/ArangoDbComponentConfigurer.java
index 01d06dd..41876bb 100644
---
a/components/camel-arangodb/src/generated/java/org/apache/camel/component/arangodb/ArangoDbComponentConfigurer.java
+++
b/components/camel-arangodb/src/generated/java/org/apache/camel/component/arangodb/ArangoDbComponentConfigurer.java
@@ -15,14 +15,28 @@ import
org.apache.camel.support.component.PropertyConfigurerSupport;
@SuppressWarnings("unchecked")
public class ArangoDbComponentConfigurer extends PropertyConfigurerSupport
implements GeneratedPropertyConfigurer, PropertyConfigurerGetter {
+ private org.apache.camel.component.arangodb.ArangoDbConfiguration
getOrCreateConfiguration(ArangoDbComponent target) {
+ if (target.getConfiguration() == null) {
+ target.setConfiguration(new
org.apache.camel.component.arangodb.ArangoDbConfiguration());
+ }
+ return target.getConfiguration();
+ }
+
@Override
public boolean configure(CamelContext camelContext, Object obj, String
name, Object value, boolean ignoreCase) {
ArangoDbComponent target = (ArangoDbComponent) obj;
switch (ignoreCase ? name.toLowerCase() : name) {
case "basicpropertybinding":
case "basicPropertyBinding":
target.setBasicPropertyBinding(property(camelContext, boolean.class, value));
return true;
+ case "collection":
getOrCreateConfiguration(target).setCollection(property(camelContext,
java.lang.String.class, value)); return true;
+ case "configuration": target.setConfiguration(property(camelContext,
org.apache.camel.component.arangodb.ArangoDbConfiguration.class, value));
return true;
+ case "host":
getOrCreateConfiguration(target).setHost(property(camelContext,
java.lang.String.class, value)); return true;
case "lazystartproducer":
case "lazyStartProducer":
target.setLazyStartProducer(property(camelContext, boolean.class, value));
return true;
+ case "operation":
getOrCreateConfiguration(target).setOperation(property(camelContext,
org.apache.camel.component.arangodb.ArangoDbOperation.class, value)); return
true;
+ case "password":
getOrCreateConfiguration(target).setPassword(property(camelContext,
java.lang.String.class, value)); return true;
+ case "port":
getOrCreateConfiguration(target).setPort(property(camelContext, int.class,
value)); return true;
+ case "user":
getOrCreateConfiguration(target).setUser(property(camelContext,
java.lang.String.class, value)); return true;
default: return false;
}
}
@@ -31,7 +45,14 @@ public class ArangoDbComponentConfigurer extends
PropertyConfigurerSupport imple
public Map<String, Object> getAllOptions(Object target) {
Map<String, Object> answer = new CaseInsensitiveMap();
answer.put("basicPropertyBinding", boolean.class);
+ answer.put("collection", java.lang.String.class);
+ answer.put("configuration",
org.apache.camel.component.arangodb.ArangoDbConfiguration.class);
+ answer.put("host", java.lang.String.class);
answer.put("lazyStartProducer", boolean.class);
+ answer.put("operation",
org.apache.camel.component.arangodb.ArangoDbOperation.class);
+ answer.put("password", java.lang.String.class);
+ answer.put("port", int.class);
+ answer.put("user", java.lang.String.class);
return answer;
}
@@ -41,8 +62,15 @@ public class ArangoDbComponentConfigurer extends
PropertyConfigurerSupport imple
switch (ignoreCase ? name.toLowerCase() : name) {
case "basicpropertybinding":
case "basicPropertyBinding": return target.isBasicPropertyBinding();
+ case "collection": return
getOrCreateConfiguration(target).getCollection();
+ case "configuration": return target.getConfiguration();
+ case "host": return getOrCreateConfiguration(target).getHost();
case "lazystartproducer":
case "lazyStartProducer": return target.isLazyStartProducer();
+ case "operation": return
getOrCreateConfiguration(target).getOperation();
+ case "password": return getOrCreateConfiguration(target).getPassword();
+ case "port": return getOrCreateConfiguration(target).getPort();
+ case "user": return getOrCreateConfiguration(target).getUser();
default: return null;
}
}
diff --git
a/components/camel-arangodb/src/generated/java/org/apache/camel/component/arangodb/ArangoDbEndpointConfigurer.java
b/components/camel-arangodb/src/generated/java/org/apache/camel/component/arangodb/ArangoDbEndpointConfigurer.java
index 21ea05e..a6bf854 100644
---
a/components/camel-arangodb/src/generated/java/org/apache/camel/component/arangodb/ArangoDbEndpointConfigurer.java
+++
b/components/camel-arangodb/src/generated/java/org/apache/camel/component/arangodb/ArangoDbEndpointConfigurer.java
@@ -21,15 +21,15 @@ public class ArangoDbEndpointConfigurer extends
PropertyConfigurerSupport implem
switch (ignoreCase ? name.toLowerCase() : name) {
case "basicpropertybinding":
case "basicPropertyBinding":
target.setBasicPropertyBinding(property(camelContext, boolean.class, value));
return true;
- case "collection": target.setCollection(property(camelContext,
java.lang.String.class, value)); return true;
- case "host": target.setHost(property(camelContext,
java.lang.String.class, value)); return true;
+ case "collection":
target.getConfiguration().setCollection(property(camelContext,
java.lang.String.class, value)); return true;
+ case "host": target.getConfiguration().setHost(property(camelContext,
java.lang.String.class, value)); return true;
case "lazystartproducer":
case "lazyStartProducer":
target.setLazyStartProducer(property(camelContext, boolean.class, value));
return true;
- case "operation": target.setOperation(property(camelContext,
org.apache.camel.component.arangodb.ArangoDbOperation.class, value)); return
true;
- case "password": target.setPassword(property(camelContext,
java.lang.String.class, value)); return true;
- case "port": target.setPort(property(camelContext, int.class, value));
return true;
+ case "operation":
target.getConfiguration().setOperation(property(camelContext,
org.apache.camel.component.arangodb.ArangoDbOperation.class, value)); return
true;
+ case "password":
target.getConfiguration().setPassword(property(camelContext,
java.lang.String.class, value)); return true;
+ case "port": target.getConfiguration().setPort(property(camelContext,
int.class, value)); return true;
case "synchronous": target.setSynchronous(property(camelContext,
boolean.class, value)); return true;
- case "user": target.setUser(property(camelContext,
java.lang.String.class, value)); return true;
+ case "user": target.getConfiguration().setUser(property(camelContext,
java.lang.String.class, value)); return true;
default: return false;
}
}
@@ -55,15 +55,15 @@ public class ArangoDbEndpointConfigurer extends
PropertyConfigurerSupport implem
switch (ignoreCase ? name.toLowerCase() : name) {
case "basicpropertybinding":
case "basicPropertyBinding": return target.isBasicPropertyBinding();
- case "collection": return target.getCollection();
- case "host": return target.getHost();
+ case "collection": return target.getConfiguration().getCollection();
+ case "host": return target.getConfiguration().getHost();
case "lazystartproducer":
case "lazyStartProducer": return target.isLazyStartProducer();
- case "operation": return target.getOperation();
- case "password": return target.getPassword();
- case "port": return target.getPort();
+ case "operation": return target.getConfiguration().getOperation();
+ case "password": return target.getConfiguration().getPassword();
+ case "port": return target.getConfiguration().getPort();
case "synchronous": return target.isSynchronous();
- case "user": return target.getUser();
+ case "user": return target.getConfiguration().getUser();
default: return null;
}
}
diff --git
a/components/camel-arangodb/src/generated/resources/org/apache/camel/component/arangodb/arangodb.json
b/components/camel-arangodb/src/generated/resources/org/apache/camel/component/arangodb/arangodb.json
index c872459..de469e3 100644
---
a/components/camel-arangodb/src/generated/resources/org/apache/camel/component/arangodb/arangodb.json
+++
b/components/camel-arangodb/src/generated/resources/org/apache/camel/component/arangodb/arangodb.json
@@ -21,19 +21,26 @@
"lenientProperties": false
},
"componentProperties": {
+ "collection": { "kind": "property", "displayName": "Collection", "group":
"producer", "label": "producer", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "secret": false,
"configurationClass":
"org.apache.camel.component.arangodb.ArangoDbConfiguration",
"configurationField": "configuration", "description": "collection in the
database" },
+ "configuration": { "kind": "property", "displayName": "Configuration",
"group": "producer", "label": "", "required": false, "type": "object",
"javaType": "org.apache.camel.component.arangodb.ArangoDbConfiguration",
"deprecated": false, "secret": false, "description": "Component configuration"
},
+ "host": { "kind": "property", "displayName": "Host", "group": "producer",
"label": "producer", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "secret": false, "configurationClass":
"org.apache.camel.component.arangodb.ArangoDbConfiguration",
"configurationField": "configuration", "description": "host if host and\/or
port different from default" },
"lazyStartProducer": { "kind": "property", "displayName": "Lazy Start
Producer", "group": "producer", "label": "producer", "required": false, "type":
"boolean", "javaType": "boolean", "deprecated": false, "secret": false,
"defaultValue": false, "description": "Whether the producer should be started
lazy (on the first message). By starting lazy you can use this to allow
CamelContext and routes to startup in situations where a producer may otherwise
fail during starting and cause the r [...]
- "basicPropertyBinding": { "kind": "property", "displayName": "Basic
Property Binding", "group": "advanced", "label": "advanced", "required": false,
"type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false,
"defaultValue": false, "description": "Whether the component should use basic
property binding (Camel 2.x) or the newer property binding with additional
capabilities" }
+ "operation": { "kind": "property", "displayName": "Operation", "group":
"producer", "label": "producer", "required": false, "type": "object",
"javaType": "org.apache.camel.component.arangodb.ArangoDbOperation", "enum": [
"SAVE_DOCUMENT", "FIND_DOCUMENT_BY_KEY", "UPDATE_DOCUMENT", "DELETE_DOCUMENT",
"AQL_QUERY" ], "deprecated": false, "secret": false, "configurationClass":
"org.apache.camel.component.arangodb.ArangoDbConfiguration",
"configurationField": "configuration", "description" [...]
+ "port": { "kind": "property", "displayName": "Port", "group": "producer",
"label": "producer", "required": false, "type": "integer", "javaType": "int",
"deprecated": false, "secret": false, "configurationClass":
"org.apache.camel.component.arangodb.ArangoDbConfiguration",
"configurationField": "configuration", "description": "port if host and\/or
port different from default" },
+ "basicPropertyBinding": { "kind": "property", "displayName": "Basic
Property Binding", "group": "advanced", "label": "advanced", "required": false,
"type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false,
"defaultValue": false, "description": "Whether the component should use basic
property binding (Camel 2.x) or the newer property binding with additional
capabilities" },
+ "password": { "kind": "property", "displayName": "Password", "group":
"security", "label": "security", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "secret": true,
"configurationClass":
"org.apache.camel.component.arangodb.ArangoDbConfiguration",
"configurationField": "configuration", "description": "password if user and\/or
password different from default" },
+ "user": { "kind": "property", "displayName": "User", "group": "security",
"label": "security", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "secret": true, "configurationClass":
"org.apache.camel.component.arangodb.ArangoDbConfiguration",
"configurationField": "configuration", "description": "user if user and\/or
password different from default" }
},
"properties": {
"database": { "kind": "path", "displayName": "Database", "group":
"producer", "label": "", "required": true, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "deprecationNote": "", "secret":
false, "description": "database name" },
- "collection": { "kind": "parameter", "displayName": "Collection", "group":
"producer", "label": "", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "secret": false, "description":
"collection in the database" },
- "host": { "kind": "parameter", "displayName": "Host", "group": "producer",
"label": "", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "secret": false, "description": "host
if host and\/or port different from default" },
+ "collection": { "kind": "parameter", "displayName": "Collection", "group":
"producer", "label": "producer", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "secret": false,
"configurationClass":
"org.apache.camel.component.arangodb.ArangoDbConfiguration",
"configurationField": "configuration", "description": "collection in the
database" },
+ "host": { "kind": "parameter", "displayName": "Host", "group": "producer",
"label": "producer", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "secret": false, "configurationClass":
"org.apache.camel.component.arangodb.ArangoDbConfiguration",
"configurationField": "configuration", "description": "host if host and\/or
port different from default" },
"lazyStartProducer": { "kind": "parameter", "displayName": "Lazy Start
Producer", "group": "producer", "label": "producer", "required": false, "type":
"boolean", "javaType": "boolean", "deprecated": false, "secret": false,
"defaultValue": false, "description": "Whether the producer should be started
lazy (on the first message). By starting lazy you can use this to allow
CamelContext and routes to startup in situations where a producer may otherwise
fail during starting and cause the [...]
- "operation": { "kind": "parameter", "displayName": "Operation", "group":
"producer", "label": "", "required": false, "type": "object", "javaType":
"org.apache.camel.component.arangodb.ArangoDbOperation", "enum": [
"SAVE_DOCUMENT", "FIND_DOCUMENT_BY_KEY", "UPDATE_DOCUMENT", "DELETE_DOCUMENT",
"AQL_QUERY" ], "deprecated": false, "secret": false, "description": "operation
to perform" },
- "port": { "kind": "parameter", "displayName": "Port", "group": "producer",
"label": "", "required": false, "type": "integer", "javaType": "int",
"deprecated": false, "secret": false, "description": "port if host and\/or port
different from default" },
+ "operation": { "kind": "parameter", "displayName": "Operation", "group":
"producer", "label": "producer", "required": false, "type": "object",
"javaType": "org.apache.camel.component.arangodb.ArangoDbOperation", "enum": [
"SAVE_DOCUMENT", "FIND_DOCUMENT_BY_KEY", "UPDATE_DOCUMENT", "DELETE_DOCUMENT",
"AQL_QUERY" ], "deprecated": false, "secret": false, "configurationClass":
"org.apache.camel.component.arangodb.ArangoDbConfiguration",
"configurationField": "configuration", "description [...]
+ "port": { "kind": "parameter", "displayName": "Port", "group": "producer",
"label": "producer", "required": false, "type": "integer", "javaType": "int",
"deprecated": false, "secret": false, "configurationClass":
"org.apache.camel.component.arangodb.ArangoDbConfiguration",
"configurationField": "configuration", "description": "port if host and\/or
port different from default" },
"basicPropertyBinding": { "kind": "parameter", "displayName": "Basic
Property Binding", "group": "advanced", "label": "advanced", "required": false,
"type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false,
"defaultValue": false, "description": "Whether the endpoint should use basic
property binding (Camel 2.x) or the newer property binding with additional
capabilities" },
"synchronous": { "kind": "parameter", "displayName": "Synchronous",
"group": "advanced", "label": "advanced", "required": false, "type": "boolean",
"javaType": "boolean", "deprecated": false, "secret": false, "defaultValue":
"false", "description": "Sets whether synchronous processing should be strictly
used, or Camel is allowed to use asynchronous processing (if supported)." },
- "password": { "kind": "parameter", "displayName": "Password", "group":
"security", "label": "security", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "secret": true,
"description": "password if user and\/or password different from default" },
- "user": { "kind": "parameter", "displayName": "User", "group": "security",
"label": "security", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "secret": true, "description": "user
if user and\/or password different from default" }
+ "password": { "kind": "parameter", "displayName": "Password", "group":
"security", "label": "security", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "secret": true,
"configurationClass":
"org.apache.camel.component.arangodb.ArangoDbConfiguration",
"configurationField": "configuration", "description": "password if user and\/or
password different from default" },
+ "user": { "kind": "parameter", "displayName": "User", "group": "security",
"label": "security", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "secret": true, "configurationClass":
"org.apache.camel.component.arangodb.ArangoDbConfiguration",
"configurationField": "configuration", "description": "user if user and\/or
password different from default" }
}
}
diff --git a/components/camel-arangodb/src/main/docs/arangodb-component.adoc
b/components/camel-arangodb/src/main/docs/arangodb-component.adoc
index da47100..9b0be1a 100644
--- a/components/camel-arangodb/src/main/docs/arangodb-component.adoc
+++ b/components/camel-arangodb/src/main/docs/arangodb-component.adoc
@@ -31,22 +31,29 @@ for this component:
[source,java]
---------------------------
-arangodb:name[?options]
+arangodb:database[?options]
---------------------------
== ArangoDB options
// component options: START
-The ArangoDb component supports 2 options, which are listed below.
+The ArangoDb component supports 9 options, which are listed below.
[width="100%",cols="2,5,^1,2",options="header"]
|===
| Name | Description | Default | Type
+| *collection* (producer) | collection in the database | | String
+| *configuration* (producer) | Component configuration | |
ArangoDbConfiguration
+| *host* (producer) | host if host and/or port different from default | |
String
| *lazyStartProducer* (producer) | Whether the producer should be started lazy
(on the first message). By starting lazy you can use this to allow CamelContext
and routes to startup in situations where a producer may otherwise fail during
starting and cause the route to fail being started. By deferring this startup
to be lazy then the startup failure can be handled during routing messages via
Camel's routing error handlers. Beware that when the first message is processed
then creating and [...]
+| *operation* (producer) | operation to perform. The value can be one of:
SAVE_DOCUMENT, FIND_DOCUMENT_BY_KEY, UPDATE_DOCUMENT, DELETE_DOCUMENT,
AQL_QUERY | | ArangoDbOperation
+| *port* (producer) | port if host and/or port different from default | | int
| *basicPropertyBinding* (advanced) | Whether the component should use basic
property binding (Camel 2.x) or the newer property binding with additional
capabilities | false | boolean
+| *password* (security) | password if user and/or password different from
default | | String
+| *user* (security) | user if user and/or password different from default | |
String
|===
// component options: END
diff --git
a/components/camel-arangodb/src/main/java/org/apache/camel/component/arangodb/ArangoDbComponent.java
b/components/camel-arangodb/src/main/java/org/apache/camel/component/arangodb/ArangoDbComponent.java
index 3e39389..bde63e2 100644
---
a/components/camel-arangodb/src/main/java/org/apache/camel/component/arangodb/ArangoDbComponent.java
+++
b/components/camel-arangodb/src/main/java/org/apache/camel/component/arangodb/ArangoDbComponent.java
@@ -18,15 +18,49 @@ package org.apache.camel.component.arangodb;
import java.util.Map;
+import org.apache.camel.CamelContext;
import org.apache.camel.Endpoint;
+import org.apache.camel.spi.Metadata;
+import org.apache.camel.spi.annotations.Component;
import org.apache.camel.support.DefaultComponent;
+import org.apache.camel.util.ObjectHelper;
[email protected]("arangodb")
+@Component("arangodb")
public class ArangoDbComponent extends DefaultComponent {
+ @Metadata
+ private ArangoDbConfiguration configuration = new ArangoDbConfiguration();
+
+ public ArangoDbComponent() {
+ this(null);
+ }
+
+ public ArangoDbComponent(CamelContext context) {
+ super(context);
+ }
+
protected Endpoint createEndpoint(String uri, String remaining,
Map<String, Object> parameters) throws Exception {
- Endpoint endpoint = new ArangoDbEndpoint(uri, this);
+ if (ObjectHelper.isEmpty(remaining)) {
+ throw new IllegalArgumentException("Database name must be
specified.");
+ }
+
+ final ArangoDbConfiguration configuration = this.configuration != null
? this.configuration.copy() : new ArangoDbConfiguration();
+ configuration.setDatabase(remaining);
+ Endpoint endpoint = new ArangoDbEndpoint(uri, this, configuration);
setProperties(endpoint, parameters);
return endpoint;
}
+
+ public ArangoDbConfiguration getConfiguration() {
+ return configuration;
+ }
+
+ /**
+ * Component configuration
+ *
+ * @param configuration
+ */
+ public void setConfiguration(ArangoDbConfiguration configuration) {
+ this.configuration = configuration;
+ }
}
diff --git
a/components/camel-arangodb/src/main/java/org/apache/camel/component/arangodb/ArangoDbEndpoint.java
b/components/camel-arangodb/src/main/java/org/apache/camel/component/arangodb/ArangoDbConfiguration.java
similarity index 58%
copy from
components/camel-arangodb/src/main/java/org/apache/camel/component/arangodb/ArangoDbEndpoint.java
copy to
components/camel-arangodb/src/main/java/org/apache/camel/component/arangodb/ArangoDbConfiguration.java
index 1f4efac..62ff4b2 100644
---
a/components/camel-arangodb/src/main/java/org/apache/camel/component/arangodb/ArangoDbEndpoint.java
+++
b/components/camel-arangodb/src/main/java/org/apache/camel/component/arangodb/ArangoDbConfiguration.java
@@ -16,54 +16,27 @@
*/
package org.apache.camel.component.arangodb;
-import com.arangodb.ArangoDB;
-import org.apache.camel.Category;
-import org.apache.camel.Consumer;
-import org.apache.camel.Processor;
-import org.apache.camel.Producer;
-import org.apache.camel.spi.Metadata;
-import org.apache.camel.spi.UriEndpoint;
+import org.apache.camel.RuntimeCamelException;
import org.apache.camel.spi.UriParam;
-import org.apache.camel.spi.UriPath;
-import org.apache.camel.support.DefaultEndpoint;
-import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.spi.UriParams;
-/**
- * Perform operations on ArangoDb documents, collections and graphs.
- */
-@UriEndpoint(firstVersion = "3.5.0-SNAPSHOT", scheme = "arangodb", title =
"ArangoDb", syntax = "arangodb:database", category = {Category.DATABASE,
Category.NOSQL}, producerOnly = true)
-public class ArangoDbEndpoint extends DefaultEndpoint {
- private ArangoDB arango;
-
- @UriPath
- @Metadata(required = true)
+@UriParams
+public class ArangoDbConfiguration implements Cloneable {
private String database;
- @UriParam
+ @UriParam(label = "producer")
private String host;
- @UriParam
+ @UriParam(label = "producer")
private int port;
@UriParam(label = "security", secret = true)
private String user;
@UriParam(label = "security", secret = true)
private String password;
- @UriParam
+ @UriParam(label = "producer")
private String collection;
- @UriParam
+ @UriParam(label = "producer")
private ArangoDbOperation operation;
- public ArangoDbEndpoint() {
- }
-
- public ArangoDbEndpoint(String uri, ArangoDbComponent component) {
- super(uri, component);
- }
-
- public Producer createProducer() {
- return new ArangoDbProducer(this);
- }
-
- public Consumer createConsumer(Processor processor) {
- throw new UnsupportedOperationException("You cannot receive messages
at this endpoint: " + getEndpointUri());
+ public ArangoDbConfiguration() {
}
public String getDatabase() {
@@ -79,14 +52,6 @@ public class ArangoDbEndpoint extends DefaultEndpoint {
this.database = database;
}
- public ArangoDB getArango() {
- return arango;
- }
-
- public void setArango(ArangoDB arango) {
- this.arango = arango;
- }
-
public String getHost() {
return host;
}
@@ -166,33 +131,11 @@ public class ArangoDbEndpoint extends DefaultEndpoint {
this.operation = operation;
}
- @Override
- protected void doStart() throws Exception {
- super.doStart();
-
- if (arango == null) {
-
- final ArangoDB.Builder builder = new ArangoDB.Builder();
-
- if (ObjectHelper.isNotEmpty(host) &&
ObjectHelper.isNotEmpty(port)) {
- builder.host(host, port);
- }
-
- if (ObjectHelper.isNotEmpty(user) &&
ObjectHelper.isNotEmpty(password)) {
- builder.user(user).password(password);
- }
-
- arango = builder.build();
+ public ArangoDbConfiguration copy() {
+ try {
+ return (ArangoDbConfiguration) super.clone();
+ } catch (CloneNotSupportedException e) {
+ throw new RuntimeCamelException(e);
}
-
}
-
- @Override
- protected void doShutdown() throws Exception {
- super.doShutdown();
- if (arango != null) {
- arango.shutdown();
- }
- }
-
}
diff --git
a/components/camel-arangodb/src/main/java/org/apache/camel/component/arangodb/ArangoDbEndpoint.java
b/components/camel-arangodb/src/main/java/org/apache/camel/component/arangodb/ArangoDbEndpoint.java
index 1f4efac..e09732d 100644
---
a/components/camel-arangodb/src/main/java/org/apache/camel/component/arangodb/ArangoDbEndpoint.java
+++
b/components/camel-arangodb/src/main/java/org/apache/camel/component/arangodb/ArangoDbEndpoint.java
@@ -35,27 +35,20 @@ import org.apache.camel.util.ObjectHelper;
public class ArangoDbEndpoint extends DefaultEndpoint {
private ArangoDB arango;
- @UriPath
+ @UriPath(description = "database name")
@Metadata(required = true)
private String database;
+
@UriParam
- private String host;
- @UriParam
- private int port;
- @UriParam(label = "security", secret = true)
- private String user;
- @UriParam(label = "security", secret = true)
- private String password;
- @UriParam
- private String collection;
- @UriParam
- private ArangoDbOperation operation;
+ private ArangoDbConfiguration configuration;
+
public ArangoDbEndpoint() {
}
- public ArangoDbEndpoint(String uri, ArangoDbComponent component) {
+ public ArangoDbEndpoint(String uri, ArangoDbComponent component,
ArangoDbConfiguration configuration) {
super(uri, component);
+ this.configuration = configuration;
}
public Producer createProducer() {
@@ -66,19 +59,6 @@ public class ArangoDbEndpoint extends DefaultEndpoint {
throw new UnsupportedOperationException("You cannot receive messages
at this endpoint: " + getEndpointUri());
}
- public String getDatabase() {
- return database;
- }
-
- /**
- * database name
- *
- * @param database
- */
- public void setDatabase(String database) {
- this.database = database;
- }
-
public ArangoDB getArango() {
return arango;
}
@@ -87,83 +67,12 @@ public class ArangoDbEndpoint extends DefaultEndpoint {
this.arango = arango;
}
- public String getHost() {
- return host;
- }
-
- /**
- * host if host and/or port different from default
- *
- * @param host
- */
- public void setHost(String host) {
- this.host = host;
- }
-
- public int getPort() {
- return port;
- }
-
- /**
- * port if host and/or port different from default
- *
- * @param port
- */
- public void setPort(int port) {
- this.port = port;
- }
-
- public String getUser() {
- return user;
- }
-
- /**
- * user if user and/or password different from default
- *
- * @param user
- */
- public void setUser(String user) {
- this.user = user;
- }
-
- public String getPassword() {
- return password;
- }
-
- /**
- * password if user and/or password different from default
- *
- * @param password
- */
- public void setPassword(String password) {
- this.password = password;
- }
-
-
- public String getCollection() {
- return collection;
- }
-
- /**
- * collection in the database
- *
- * @param collection
- */
- public void setCollection(String collection) {
- this.collection = collection;
- }
-
- public ArangoDbOperation getOperation() {
- return operation;
+ public ArangoDbConfiguration getConfiguration() {
+ return configuration;
}
- /**
- * operation to perform
- *
- * @param operation
- */
- public void setOperation(ArangoDbOperation operation) {
- this.operation = operation;
+ public void setConfiguration(ArangoDbConfiguration configuration) {
+ this.configuration = configuration;
}
@Override
@@ -174,12 +83,12 @@ public class ArangoDbEndpoint extends DefaultEndpoint {
final ArangoDB.Builder builder = new ArangoDB.Builder();
- if (ObjectHelper.isNotEmpty(host) &&
ObjectHelper.isNotEmpty(port)) {
- builder.host(host, port);
+ if (ObjectHelper.isNotEmpty(configuration.getHost()) &&
ObjectHelper.isNotEmpty(configuration.getPort())) {
+ builder.host(configuration.getHost(), configuration.getPort());
}
- if (ObjectHelper.isNotEmpty(user) &&
ObjectHelper.isNotEmpty(password)) {
- builder.user(user).password(password);
+ if (ObjectHelper.isNotEmpty(configuration.getUser()) &&
ObjectHelper.isNotEmpty(configuration.getPassword())) {
+
builder.user(configuration.getUser()).password(configuration.getPassword());
}
arango = builder.build();
diff --git
a/components/camel-arangodb/src/main/java/org/apache/camel/component/arangodb/ArangoDbProducer.java
b/components/camel-arangodb/src/main/java/org/apache/camel/component/arangodb/ArangoDbProducer.java
index 8866624..3c4957e 100644
---
a/components/camel-arangodb/src/main/java/org/apache/camel/component/arangodb/ArangoDbProducer.java
+++
b/components/camel-arangodb/src/main/java/org/apache/camel/component/arangodb/ArangoDbProducer.java
@@ -63,7 +63,7 @@ public class ArangoDbProducer extends DefaultProducer {
public void process(Exchange exchange) throws Exception {
System.out.println(exchange.getIn().getBody());
- ArangoDbOperation operation = endpoint.getOperation();
+ ArangoDbOperation operation =
endpoint.getConfiguration().getOperation();
invokeOperation(operation, exchange);
}
@@ -184,7 +184,7 @@ public class ArangoDbProducer extends DefaultProducer {
private Function<Exchange, Object> aqlQuery() {
return exchange -> {
try {
- ArangoDatabase database =
endpoint.getArango().db(endpoint.getDatabase());
+ ArangoDatabase database =
endpoint.getArango().db(endpoint.getConfiguration().getDatabase());
// AQL query
String query = (String)
exchange.getMessage().getHeader(AQL_QUERY);
@@ -214,8 +214,8 @@ public class ArangoDbProducer extends DefaultProducer {
* retrieve collection from endpoints params
*/
private ArangoCollection calculateCollection() {
- String database = endpoint.getDatabase();
- String collection = endpoint.getCollection();
+ String database = endpoint.getConfiguration().getDatabase();
+ String collection = endpoint.getConfiguration().getCollection();
// return collection
return endpoint.getArango().db(database).collection(collection);
diff --git
a/components/camel-arangodb/src/test/java/org/apache/camel/component/arangodb/ArangoCollectionDeleteTest.java
b/components/camel-arangodb/src/test/java/org/apache/camel/component/arangodb/ArangoCollectionDeleteTest.java
index 5c617e6..5cca4ed 100644
---
a/components/camel-arangodb/src/test/java/org/apache/camel/component/arangodb/ArangoCollectionDeleteTest.java
+++
b/components/camel-arangodb/src/test/java/org/apache/camel/component/arangodb/ArangoCollectionDeleteTest.java
@@ -50,7 +50,7 @@ public class ArangoCollectionDeleteTest extends
AbstractArangoDbTest {
return new RouteBuilder() {
public void configure() {
from("direct:delete")
-
.to("arangodb:mydb?database={{arangodb.testDb}}&collection={{arangodb.testCollection}}&operation=DELETE_DOCUMENT");
+
.to("arangodb:{{arangodb.testDb}}?collection={{arangodb.testCollection}}&operation=DELETE_DOCUMENT");
}
};
}
diff --git
a/components/camel-arangodb/src/test/java/org/apache/camel/component/arangodb/ArangoCollectionFindByKeyTest.java
b/components/camel-arangodb/src/test/java/org/apache/camel/component/arangodb/ArangoCollectionFindByKeyTest.java
index 10d0c04..67e046a 100644
---
a/components/camel-arangodb/src/test/java/org/apache/camel/component/arangodb/ArangoCollectionFindByKeyTest.java
+++
b/components/camel-arangodb/src/test/java/org/apache/camel/component/arangodb/ArangoCollectionFindByKeyTest.java
@@ -60,7 +60,7 @@ public class ArangoCollectionFindByKeyTest extends
AbstractArangoDbTest {
return new RouteBuilder() {
public void configure() {
from("direct:findDocByKey")
-
.to("arangodb:mydb?database={{arangodb.testDb}}&collection={{arangodb.testCollection}}&operation=FIND_DOCUMENT_BY_KEY");
+
.to("arangodb://dbTest?collection={{arangodb.testCollection}}&operation=FIND_DOCUMENT_BY_KEY");
}
};
}
diff --git
a/components/camel-arangodb/src/test/java/org/apache/camel/component/arangodb/ArangoCollectionQueryTest.java
b/components/camel-arangodb/src/test/java/org/apache/camel/component/arangodb/ArangoCollectionQueryTest.java
index 788a830..6806125 100644
---
a/components/camel-arangodb/src/test/java/org/apache/camel/component/arangodb/ArangoCollectionQueryTest.java
+++
b/components/camel-arangodb/src/test/java/org/apache/camel/component/arangodb/ArangoCollectionQueryTest.java
@@ -50,7 +50,7 @@ public class ArangoCollectionQueryTest extends
AbstractArangoDbTest {
return new RouteBuilder() {
public void configure() {
from("direct:query")
-
.to("arangodb:mydb?database={{arangodb.testDb}}&operation=AQL_QUERY");
+
.to("arangodb:{{arangodb.testDb}}?operation=AQL_QUERY");
}
};
}
diff --git
a/components/camel-arangodb/src/test/java/org/apache/camel/component/arangodb/ArangoCollectionSaveTest.java
b/components/camel-arangodb/src/test/java/org/apache/camel/component/arangodb/ArangoCollectionSaveTest.java
index 912f9c3..58154f5 100644
---
a/components/camel-arangodb/src/test/java/org/apache/camel/component/arangodb/ArangoCollectionSaveTest.java
+++
b/components/camel-arangodb/src/test/java/org/apache/camel/component/arangodb/ArangoCollectionSaveTest.java
@@ -59,7 +59,7 @@ public class ArangoCollectionSaveTest extends
AbstractArangoDbTest {
return new RouteBuilder() {
public void configure() {
from("direct:insert")
-
.to("arangodb:mydb?database={{arangodb.testDb}}&collection={{arangodb.testCollection}}&operation=SAVE_DOCUMENT");
+
.to("arangodb:{{arangodb.testDb}}?collection={{arangodb.testCollection}}&operation=SAVE_DOCUMENT");
}
};
}
diff --git
a/components/camel-arangodb/src/test/java/org/apache/camel/component/arangodb/ArangoCollectionUpdateTest.java
b/components/camel-arangodb/src/test/java/org/apache/camel/component/arangodb/ArangoCollectionUpdateTest.java
index 0e008bf..79c76dc 100644
---
a/components/camel-arangodb/src/test/java/org/apache/camel/component/arangodb/ArangoCollectionUpdateTest.java
+++
b/components/camel-arangodb/src/test/java/org/apache/camel/component/arangodb/ArangoCollectionUpdateTest.java
@@ -52,7 +52,7 @@ public class ArangoCollectionUpdateTest extends
AbstractArangoDbTest {
return new RouteBuilder() {
public void configure() {
from("direct:update")
-
.to("arangodb:mydb?database={{arangodb.testDb}}&collection={{arangodb.testCollection}}&operation=UPDATE_DOCUMENT");
+
.to("arangodb:{{arangodb.testDb}}?collection={{arangodb.testCollection}}&operation=UPDATE_DOCUMENT");
}
};
}
diff --git
a/components/camel-arangodb/src/test/java/org/apache/camel/component/arangodb/ArangoDbComponentTest.java
b/components/camel-arangodb/src/test/java/org/apache/camel/component/arangodb/ArangoDbComponentTest.java
new file mode 100644
index 0000000..f5ce518
--- /dev/null
+++
b/components/camel-arangodb/src/test/java/org/apache/camel/component/arangodb/ArangoDbComponentTest.java
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+package org.apache.camel.component.arangodb;
+
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThrows;
+
+
+public class ArangoDbComponentTest extends CamelTestSupport {
+
+ @Test
+ public void createEndpointWithMinimalConfiguration() throws Exception {
+ ArangoDbComponent component = context.getComponent("arangodb",
ArangoDbComponent.class);
+ ArangoDbEndpoint endpoint = (ArangoDbEndpoint) component
+ .createEndpoint("arangodb:testDb?collection=myCollection");
+ assertEquals("testDb", endpoint.getConfiguration().getDatabase());
+ assertEquals("myCollection",
endpoint.getConfiguration().getCollection());
+ }
+
+ @Test
+ public void testRouteWithNoDatabaseName() throws Exception {
+ ArangoDbComponent component = context.getComponent("arangodb",
ArangoDbComponent.class);
+ assertThrows(IllegalArgumentException.class, () -> {
+ component
+ .createEndpoint("arangodb?collection=myCollection");
+ });
+ }
+}
diff --git
a/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/ArangodbComponentBuilderFactory.java
b/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/ArangodbComponentBuilderFactory.java
index 0e0e893..af396a6 100644
---
a/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/ArangodbComponentBuilderFactory.java
+++
b/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/ArangodbComponentBuilderFactory.java
@@ -49,6 +49,41 @@ public interface ArangodbComponentBuilderFactory {
extends
ComponentBuilder<ArangoDbComponent> {
/**
+ * collection in the database.
+ *
+ * The option is a: <code>java.lang.String</code> type.
+ *
+ * Group: producer
+ */
+ default ArangodbComponentBuilder collection(java.lang.String
collection) {
+ doSetProperty("collection", collection);
+ return this;
+ }
+ /**
+ * Component configuration.
+ *
+ * The option is a:
+ *
<code>org.apache.camel.component.arangodb.ArangoDbConfiguration</code> type.
+ *
+ * Group: producer
+ */
+ default ArangodbComponentBuilder configuration(
+ org.apache.camel.component.arangodb.ArangoDbConfiguration
configuration) {
+ doSetProperty("configuration", configuration);
+ return this;
+ }
+ /**
+ * host if host and/or port different from default.
+ *
+ * The option is a: <code>java.lang.String</code> type.
+ *
+ * Group: producer
+ */
+ default ArangodbComponentBuilder host(java.lang.String host) {
+ doSetProperty("host", host);
+ return this;
+ }
+ /**
* Whether the producer should be started lazy (on the first message).
* By starting lazy you can use this to allow CamelContext and routes
to
* startup in situations where a producer may otherwise fail during
@@ -70,6 +105,31 @@ public interface ArangodbComponentBuilderFactory {
return this;
}
/**
+ * operation to perform.
+ *
+ * The option is a:
+ * <code>org.apache.camel.component.arangodb.ArangoDbOperation</code>
+ * type.
+ *
+ * Group: producer
+ */
+ default ArangodbComponentBuilder operation(
+ org.apache.camel.component.arangodb.ArangoDbOperation
operation) {
+ doSetProperty("operation", operation);
+ return this;
+ }
+ /**
+ * port if host and/or port different from default.
+ *
+ * The option is a: <code>int</code> type.
+ *
+ * Group: producer
+ */
+ default ArangodbComponentBuilder port(int port) {
+ doSetProperty("port", port);
+ return this;
+ }
+ /**
* Whether the component should use basic property binding (Camel 2.x)
* or the newer property binding with additional capabilities.
*
@@ -83,6 +143,28 @@ public interface ArangodbComponentBuilderFactory {
doSetProperty("basicPropertyBinding", basicPropertyBinding);
return this;
}
+ /**
+ * password if user and/or password different from default.
+ *
+ * The option is a: <code>java.lang.String</code> type.
+ *
+ * Group: security
+ */
+ default ArangodbComponentBuilder password(java.lang.String password) {
+ doSetProperty("password", password);
+ return this;
+ }
+ /**
+ * user if user and/or password different from default.
+ *
+ * The option is a: <code>java.lang.String</code> type.
+ *
+ * Group: security
+ */
+ default ArangodbComponentBuilder user(java.lang.String user) {
+ doSetProperty("user", user);
+ return this;
+ }
}
class ArangodbComponentBuilderImpl
@@ -94,14 +176,28 @@ public interface ArangodbComponentBuilderFactory {
protected ArangoDbComponent buildConcreteComponent() {
return new ArangoDbComponent();
}
+ private org.apache.camel.component.arangodb.ArangoDbConfiguration
getOrCreateConfiguration(
+ org.apache.camel.component.arangodb.ArangoDbComponent
component) {
+ if (component.getConfiguration() == null) {
+ component.setConfiguration(new
org.apache.camel.component.arangodb.ArangoDbConfiguration());
+ }
+ return component.getConfiguration();
+ }
@Override
protected boolean setPropertyOnComponent(
Component component,
String name,
Object value) {
switch (name) {
+ case "collection": getOrCreateConfiguration((ArangoDbComponent)
component).setCollection((java.lang.String) value); return true;
+ case "configuration": ((ArangoDbComponent)
component).setConfiguration((org.apache.camel.component.arangodb.ArangoDbConfiguration)
value); return true;
+ case "host": getOrCreateConfiguration((ArangoDbComponent)
component).setHost((java.lang.String) value); return true;
case "lazyStartProducer": ((ArangoDbComponent)
component).setLazyStartProducer((boolean) value); return true;
+ case "operation": getOrCreateConfiguration((ArangoDbComponent)
component).setOperation((org.apache.camel.component.arangodb.ArangoDbOperation)
value); return true;
+ case "port": getOrCreateConfiguration((ArangoDbComponent)
component).setPort((int) value); return true;
case "basicPropertyBinding": ((ArangoDbComponent)
component).setBasicPropertyBinding((boolean) value); return true;
+ case "password": getOrCreateConfiguration((ArangoDbComponent)
component).setPassword((java.lang.String) value); return true;
+ case "user": getOrCreateConfiguration((ArangoDbComponent)
component).setUser((java.lang.String) value); return true;
default: return false;
}
}
diff --git
a/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/StaticEndpointBuilders.java
b/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/StaticEndpointBuilders.java
index 6588463..5610bf1 100644
---
a/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/StaticEndpointBuilders.java
+++
b/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/StaticEndpointBuilders.java
@@ -267,7 +267,7 @@ public class StaticEndpointBuilders {
*
* @param path database
*/
- public static
org.apache.camel.builder.endpoint.dsl.ArangoDbEndpointBuilderFactory.ArangoDbEndpointBuilder
arangodb(
+ static
org.apache.camel.builder.endpoint.dsl.ArangoDbEndpointBuilderFactory.ArangoDbEndpointBuilder
arangodb(
String path) {
return
org.apache.camel.builder.endpoint.dsl.ArangoDbEndpointBuilderFactory.endpointBuilder("arangodb",
path);
}
@@ -288,7 +288,7 @@ public class StaticEndpointBuilders {
* instead of the default name
* @param path database
*/
- public static
org.apache.camel.builder.endpoint.dsl.ArangoDbEndpointBuilderFactory.ArangoDbEndpointBuilder
arangodb(
+ static
org.apache.camel.builder.endpoint.dsl.ArangoDbEndpointBuilderFactory.ArangoDbEndpointBuilder
arangodb(
String componentName,
String path) {
return
org.apache.camel.builder.endpoint.dsl.ArangoDbEndpointBuilderFactory.endpointBuilder(componentName,
path);