This is an automated email from the ASF dual-hosted git repository. davsclaus 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 7d98feb CAMEL-14565: Add docs for missing option 7d98feb is described below commit 7d98feb7ba038ed8206f3c9449cc793f6e106f84 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Mon Feb 17 10:52:09 2020 +0100 CAMEL-14565: Add docs for missing option --- .../component/corda/CordaEndpointConfigurer.java | 13 +++ .../org/apache/camel/component/corda/corda.json | 7 ++ .../camel-corda/src/main/docs/corda-component.adoc | 24 ++++-- .../camel/component/corda/CordaConfiguration.java | 96 +++++++++++----------- .../camel/component/corda/CordaConsumer.java | 4 +- .../camel/component/corda/CordaEndpoint.java | 7 +- 6 files changed, 87 insertions(+), 64 deletions(-) diff --git a/components/camel-corda/src/generated/java/org/apache/camel/component/corda/CordaEndpointConfigurer.java b/components/camel-corda/src/generated/java/org/apache/camel/component/corda/CordaEndpointConfigurer.java index 457f3cd..6aff744 100644 --- a/components/camel-corda/src/generated/java/org/apache/camel/component/corda/CordaEndpointConfigurer.java +++ b/components/camel-corda/src/generated/java/org/apache/camel/component/corda/CordaEndpointConfigurer.java @@ -17,10 +17,23 @@ public class CordaEndpointConfigurer extends PropertyConfigurerSupport implement switch (ignoreCase ? name.toLowerCase() : name) { case "bridgeerrorhandler": case "bridgeErrorHandler": target.setBridgeErrorHandler(property(camelContext, boolean.class, value)); return true; + case "pagespecification": + case "pageSpecification": target.getConfiguration().setPageSpecification(property(camelContext, net.corda.core.node.services.vault.PageSpecification.class, value)); return true; + case "processsnapshot": + case "processSnapshot": target.getConfiguration().setProcessSnapshot(property(camelContext, boolean.class, value)); return true; + case "sort": target.getConfiguration().setSort(property(camelContext, net.corda.core.node.services.vault.Sort.class, value)); return true; + case "contractstateclass": + case "contractStateClass": target.getConfiguration().setContractStateClass(property(camelContext, java.lang.Class.class, value)); return true; case "exceptionhandler": case "exceptionHandler": target.setExceptionHandler(property(camelContext, org.apache.camel.spi.ExceptionHandler.class, value)); return true; case "exchangepattern": case "exchangePattern": target.setExchangePattern(property(camelContext, org.apache.camel.ExchangePattern.class, value)); return true; + case "flowlogicarguments": + case "flowLogicArguments": target.getConfiguration().setFlowLogicArguments(property(camelContext, java.lang.Object[].class, value)); return true; + case "flowlogicclass": + case "flowLogicClass": target.getConfiguration().setFlowLogicClass(property(camelContext, java.lang.Class.class, value)); return true; + case "querycriteria": + case "queryCriteria": target.getConfiguration().setQueryCriteria(property(camelContext, net.corda.core.node.services.vault.QueryCriteria.class, value)); return true; case "lazystartproducer": case "lazyStartProducer": target.setLazyStartProducer(property(camelContext, boolean.class, value)); return true; case "operation": target.getConfiguration().setOperation(property(camelContext, java.lang.String.class, value)); return true; diff --git a/components/camel-corda/src/generated/resources/org/apache/camel/component/corda/corda.json b/components/camel-corda/src/generated/resources/org/apache/camel/component/corda/corda.json index ee55193..267882f 100644 --- a/components/camel-corda/src/generated/resources/org/apache/camel/component/corda/corda.json +++ b/components/camel-corda/src/generated/resources/org/apache/camel/component/corda/corda.json @@ -27,8 +27,15 @@ "properties": { "node": { "kind": "path", "displayName": "Node", "group": "common", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "secret": false, "configurationClass": "org.apache.camel.component.corda.CordaConfiguration", "configurationField": "configuration", "description": "The url for the corda node" }, "bridgeErrorHandler": { "kind": "parameter", "displayName": "Bridge Error Handler", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled b [...] + "pageSpecification": { "kind": "parameter", "displayName": "Page Specification", "group": "consumer", "label": "consumer", "required": false, "type": "object", "javaType": "net.corda.core.node.services.vault.PageSpecification", "deprecated": false, "secret": false, "defaultValue": "200", "configurationClass": "org.apache.camel.component.corda.CordaConfiguration", "configurationField": "configuration", "description": "PageSpecification allows specification of a page number (starting f [...] + "processSnapshot": { "kind": "parameter", "displayName": "Process Snapshot", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": "true", "configurationClass": "org.apache.camel.component.corda.CordaConfiguration", "configurationField": "configuration", "description": "Whether to process snapshots or not" }, + "sort": { "kind": "parameter", "displayName": "Sort", "group": "consumer", "label": "consumer", "required": false, "type": "object", "javaType": "net.corda.core.node.services.vault.Sort", "enum": [ "ASC", "DESC" ], "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.corda.CordaConfiguration", "configurationField": "configuration", "description": "Sort allows specification of a set of entity attribute names and their associated directionality and nu [...] + "contractStateClass": { "kind": "parameter", "displayName": "Contract State Class", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.Class<net.corda.core.contracts.ContractState>", "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.corda.CordaConfiguration", "configurationField": "configuration", "description": "A contract state (or just state) contains opaque data used by a [...] "exceptionHandler": { "kind": "parameter", "displayName": "Exception Handler", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "object", "javaType": "org.apache.camel.spi.ExceptionHandler", "optionalPrefix": "consumer.", "deprecated": false, "secret": false, "description": "To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By default the consumer will deal with [...] "exchangePattern": { "kind": "parameter", "displayName": "Exchange Pattern", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "object", "javaType": "org.apache.camel.ExchangePattern", "enum": [ "InOnly", "InOut", "InOptionalOut" ], "deprecated": false, "secret": false, "description": "Sets the exchange pattern when the consumer creates an exchange." }, + "flowLogicArguments": { "kind": "parameter", "displayName": "Flow Logic Arguments", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "array", "javaType": "java.lang.Object[]", "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.corda.CordaConfiguration", "configurationField": "configuration", "description": "Start the given flow with the given arguments, returning an Observable with a single observation of th [...] + "flowLogicClass": { "kind": "parameter", "displayName": "Flow Logic Class", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "string", "javaType": "java.lang.Class<net.corda.core.flows.FlowLogic<java.lang.Object>>", "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.corda.CordaConfiguration", "configurationField": "configuration", "description": "Start the given flow with the given arguments, returning an Ob [...] + "queryCriteria": { "kind": "parameter", "displayName": "Query Criteria", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "object", "javaType": "net.corda.core.node.services.vault.QueryCriteria", "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.corda.CordaConfiguration", "configurationField": "configuration", "description": "QueryCriteria assumes underlying schema tables are correctly indexed for performance." }, "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": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.corda.CordaConfiguration", "configurationField": "configuration", "description": "Operation to use" }, "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" }, diff --git a/components/camel-corda/src/main/docs/corda-component.adoc b/components/camel-corda/src/main/docs/corda-component.adoc index 3cebb48..ba2384e 100644 --- a/components/camel-corda/src/main/docs/corda-component.adoc +++ b/components/camel-corda/src/main/docs/corda-component.adoc @@ -1,7 +1,8 @@ [[corda-component]] = Corda Component -= Corda Component *Since Camel 2.23* +*Since Camel 2.23* + // HEADER START *Both producer and consumer is supported* @@ -17,14 +18,14 @@ Maven users will need to add the following dependency to their `pom.xml` for this component: [source,xml] ------------------------------------------------------------- +---- <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-corda</artifactId> <version>x.x.x</version> <!-- use the same version as your Camel core version --> </dependency> ------------------------------------------------------------- +---- == URI Format @@ -71,15 +72,22 @@ with the following path and query parameters: |=== -=== Query Parameters (9 parameters): +=== Query Parameters (16 parameters): [width="100%",cols="2,5,^1,2",options="header"] |=== | Name | Description | Default | Type | *bridgeErrorHandler* (consumer) | Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored. | false | boolean +| *pageSpecification* (consumer) | PageSpecification allows specification of a page number (starting from 1) and page size (defaulting to 200 with a maximum page size of (Integer.MAX_INT) Note: we default the page number to 200 to enable queries without requiring a page specification but enabling detection of large results sets that fall out of the 200 requirement. Max page size should be used with extreme caution as results may exceed your JVM memory footprint. | 200 | PageSpecification +| *processSnapshot* (consumer) | Whether to process snapshots or not | true | boolean +| *sort* (consumer) | Sort allows specification of a set of entity attribute names and their associated directionality and null handling, to be applied upon processing a query specification. The value can be one of: ASC, DESC | | Sort +| *contractStateClass* (consumer) | A contract state (or just state) contains opaque data used by a contract program. It can be thought of as a disk file that the program can use to persist data across transactions. States are immutable: once created they are never updated, instead, any changes must generate a new successor state. States can be updated (consumed) only once: the notary is responsible for ensuring there is no double spending by only signing a transaction if the input state [...] | *exceptionHandler* (consumer) | To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By default the consumer will deal with exceptions, that will be logged at WARN or ERROR level and ignored. | | ExceptionHandler | *exchangePattern* (consumer) | Sets the exchange pattern when the consumer creates an exchange. The value can be one of: InOnly, InOut, InOptionalOut | | ExchangePattern +| *flowLogicArguments* (consumer) | Start the given flow with the given arguments, returning an Observable with a single observation of the result of running the flow. The flowLogicClass must be annotated with net.corda.core.flows.StartableByRPC. | | Object[] +| *flowLogicClass* (consumer) | Start the given flow with the given arguments, returning an Observable with a single observation of the result of running the flow. The flowLogicClass must be annotated with net.corda.core.flows.StartableByRPC. | | Class +| *queryCriteria* (consumer) | QueryCriteria assumes underlying schema tables are correctly indexed for performance. | | QueryCriteria | *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 use | | String | *basicPropertyBinding* (advanced) | Whether the endpoint should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities | false | boolean @@ -112,17 +120,17 @@ You can append query options to the URI in the following format, Subscribe for new vault state changes: [source,java] ---------------------------------------------------------------------------------------------- +---- from("corda://localhost:10006?username=user1&password=test&operation=VAULT_TRACK&contractStateClass=#contractStateClass") .to("jms:queue:vault"); ---------------------------------------------------------------------------------------------- +---- Read the node information: [source,java] --------------------------------------------------------- +---- from("direct:start") .to("corda://localhost:10006?username=user1&password=test&operation=NODE_INFO"); --------------------------------------------------------- +---- include::camel-spring-boot::page$corda-starter.adoc[] diff --git a/components/camel-corda/src/main/java/org/apache/camel/component/corda/CordaConfiguration.java b/components/camel-corda/src/main/java/org/apache/camel/component/corda/CordaConfiguration.java index bbb2926..75bb703 100644 --- a/components/camel-corda/src/main/java/org/apache/camel/component/corda/CordaConfiguration.java +++ b/components/camel-corda/src/main/java/org/apache/camel/component/corda/CordaConfiguration.java @@ -36,29 +36,50 @@ public class CordaConfiguration implements Cloneable { private transient String host; private transient int port; - @UriPath @Metadata(required = true) + @UriPath @Metadata(required = true, description = "The url for the corda node") private String node; - @UriParam(label = "producer") + @UriParam(label = "producer", description = "Operation to use") private String operation; - @UriParam(label = "security", secret = true) + @UriParam(label = "security", secret = true, description = "Username for login") private String username; - @UriParam(label = "security", secret = true) + @UriParam(label = "security", secret = true, description = "Password for login") private String password; - @Metadata(label = "consumer", defaultValue = "true") + @UriParam(label = "consumer", defaultValue = "true", description = "Whether to process snapshots or not") private boolean processSnapshot = true; - private Class<FlowLogic<?>> flowLociClass; - private Object [] arguments; + @UriParam(label = "consumer,advanced", + description = "Start the given flow with the given arguments, returning an Observable with a single observation of the" + + " result of running the flow. The flowLogicClass must be annotated with net.corda.core.flows.StartableByRPC.") + private Class<FlowLogic<?>> flowLogicClass; + @UriParam(label = "consumer,advanced", + description = "Start the given flow with the given arguments, returning an Observable with a single observation of the" + + " result of running the flow. The flowLogicClass must be annotated with net.corda.core.flows.StartableByRPC.") + private Object[] flowLogicArguments; + @UriParam(label = "consumer,advanced", + description = "A contract state (or just state) contains opaque data used by a contract program. It can be thought of as a disk" + + " file that the program can use to persist data across transactions. States are immutable: once created they are never" + + " updated, instead, any changes must generate a new successor state. States can be updated (consumed) only once: the" + + " notary is responsible for ensuring there is no \"double spending\" by only signing a transaction if the input states are all free.") private Class<ContractState> contractStateClass; + @UriParam(label = "consumer,advanced", description = "QueryCriteria assumes underlying schema tables are correctly indexed for performance.") private QueryCriteria queryCriteria; + @UriParam(label = "consumer", defaultValue = "200", + description = "PageSpecification allows specification of a page number (starting from 1) and page size" + + " (defaulting to 200 with a maximum page size of (Integer.MAX_INT)" + + " Note: we default the page number to 200 to enable queries without requiring a page specification" + + " but enabling detection of large results sets that fall out of the 200 requirement." + + " Max page size should be used with extreme caution as results may exceed your JVM memory footprint.") private PageSpecification pageSpecification; + @UriParam(label = "consumer", enums = "ASC,DESC", + description = "Sort allows specification of a set of entity attribute names and their associated directionality" + + " and null handling, to be applied upon processing a query specification.") private Sort sort; public void configure() { try { URI nodeURI = new URI(node); - setHost(nodeURI.getHost()); - setPort(nodeURI.getPort()); + this.host = nodeURI.getHost(); + this.port = nodeURI.getPort(); if (nodeURI.getUserInfo() != null) { String[] creds = nodeURI.getUserInfo().split(":"); @@ -74,13 +95,20 @@ public class CordaConfiguration implements Cloneable { } } + public String retrieveHost() { + return host; + } + + public int retrievePort() { + return port; + } + + + public String getNode() { return node; } - /** - * The url for the corda node - */ public void setNode(String node) { this.node = node; } @@ -89,9 +117,6 @@ public class CordaConfiguration implements Cloneable { return operation; } - /** - * Operation to use - */ public void setOperation(String operation) { this.operation = operation; } @@ -100,9 +125,6 @@ public class CordaConfiguration implements Cloneable { return username; } - /** - * Username for login - */ public void setUsername(String username) { this.username = username; } @@ -111,54 +133,32 @@ public class CordaConfiguration implements Cloneable { return password; } - /** - * Password for login - */ public void setPassword(String password) { this.password = password; } - public String getHost() { - return host; - } - - public void setHost(String host) { - this.host = host; - } - - public int getPort() { - return port; - } - - public void setPort(int port) { - this.port = port; - } - public boolean isProcessSnapshot() { return processSnapshot; } - /** - * Whether to process snapshots or not - */ public void setProcessSnapshot(boolean processSnapshot) { this.processSnapshot = processSnapshot; } - public Class<FlowLogic<?>> getFlowLociClass() { - return flowLociClass; + public Class<FlowLogic<?>> getFlowLogicClass() { + return flowLogicClass; } - public void setFlowLociClass(Class<FlowLogic<?>> flowLociClass) { - this.flowLociClass = flowLociClass; + public void setFlowLogicClass(Class<FlowLogic<?>> flowLogicClass) { + this.flowLogicClass = flowLogicClass; } - public Object[] getArguments() { - return arguments; + public Object[] getFlowLogicArguments() { + return flowLogicArguments; } - public void setArguments(Object[] arguments) { - this.arguments = arguments; + public void setFlowLogicArguments(Object[] flowLogicArguments) { + this.flowLogicArguments = flowLogicArguments; } public Class<ContractState> getContractStateClass() { diff --git a/components/camel-corda/src/main/java/org/apache/camel/component/corda/CordaConsumer.java b/components/camel-corda/src/main/java/org/apache/camel/component/corda/CordaConsumer.java index dfb05bf..2043905 100644 --- a/components/camel-corda/src/main/java/org/apache/camel/component/corda/CordaConsumer.java +++ b/components/camel-corda/src/main/java/org/apache/camel/component/corda/CordaConsumer.java @@ -78,7 +78,7 @@ public class CordaConsumer extends DefaultConsumer { PageSpecification pageSpec = configuration.getPageSpecification(); Sort sorting = configuration.getSort(); - DataFeed<Vault.Page<ContractState>, Vault.Update<ContractState>> pageUpdateDataFeed = null; + DataFeed<Vault.Page<ContractState>, Vault.Update<ContractState>> pageUpdateDataFeed; switch (configuration.getOperation()) { case VAULT_TRACK: @@ -174,7 +174,7 @@ public class CordaConsumer extends DefaultConsumer { case START_TRACKED_FLOW_DYNAMIC: LOG.debug("subscribing for operation: " + START_TRACKED_FLOW_DYNAMIC); - FlowProgressHandle<Object> objectFlowProgressHandle = cordaRPCOps.startTrackedFlowDynamic(configuration.getFlowLociClass(), configuration.getArguments()); + FlowProgressHandle<Object> objectFlowProgressHandle = cordaRPCOps.startTrackedFlowDynamic(configuration.getFlowLogicClass(), configuration.getFlowLogicArguments()); Object result = objectFlowProgressHandle.getReturnValue().get(); Observable<String> progress = objectFlowProgressHandle.getProgress(); processSnapshot(exchange, result); diff --git a/components/camel-corda/src/main/java/org/apache/camel/component/corda/CordaEndpoint.java b/components/camel-corda/src/main/java/org/apache/camel/component/corda/CordaEndpoint.java index a4bc810..a8d5976 100644 --- a/components/camel-corda/src/main/java/org/apache/camel/component/corda/CordaEndpoint.java +++ b/components/camel-corda/src/main/java/org/apache/camel/component/corda/CordaEndpoint.java @@ -16,9 +16,6 @@ */ package org.apache.camel.component.corda; -import java.net.URI; -import java.net.URISyntaxException; - import net.corda.client.rpc.CordaRPCClient; import net.corda.client.rpc.CordaRPCConnection; import net.corda.core.messaging.CordaRPCOps; @@ -26,10 +23,8 @@ import net.corda.core.utilities.NetworkHostAndPort; 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.spi.UriParam; -import org.apache.camel.spi.UriPath; import org.apache.camel.support.DefaultEndpoint; /** @@ -71,7 +66,7 @@ public class CordaEndpoint extends DefaultEndpoint { @Override protected void doStart() throws Exception { - NetworkHostAndPort rpcAddress = new NetworkHostAndPort(configuration.getHost(), configuration.getPort()); + NetworkHostAndPort rpcAddress = new NetworkHostAndPort(configuration.retrieveHost(), configuration.retrievePort()); CordaRPCClient rpcClient = new CordaRPCClient(rpcAddress); rpcConnection = rpcClient.start(this.configuration.getUsername(), this.configuration.getPassword()); proxy = rpcConnection.getProxy();