You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by nf...@apache.org on 2022/03/29 16:59:49 UTC

[camel] 06/12: CAMEL-17792: Add doc about the message headers of camel-iec60870

This is an automated email from the ASF dual-hosted git repository.

nfilotto pushed a commit to branch CAMEL-17792/doc-message-headers
in repository https://gitbox.apache.org/repos/asf/camel.git

commit db74ce33eb994581543d5bc3ac0150825c517d41
Author: Nicolas Filotto <nf...@talend.com>
AuthorDate: Tue Mar 29 15:27:45 2022 +0200

    CAMEL-17792: Add doc about the message headers of camel-iec60870
---
 .../component/iec60870/client/iec60870-client.json |  6 +++++
 .../component/iec60870/server/iec60870-server.json |  8 +++++++
 .../src/main/docs/iec60870-client-component.adoc   |  3 +++
 .../src/main/docs/iec60870-server-component.adoc   |  4 +++-
 .../apache/camel/component/iec60870/Constants.java | 27 ++++++++++++++++++++++
 .../component/iec60870/client/ClientEndpoint.java  |  6 +++--
 .../component/iec60870/server/ServerConsumer.java  | 13 ++++++-----
 .../component/iec60870/server/ServerEndpoint.java  |  6 +++--
 8 files changed, 62 insertions(+), 11 deletions(-)

diff --git a/components/camel-iec60870/src/generated/resources/org/apache/camel/component/iec60870/client/iec60870-client.json b/components/camel-iec60870/src/generated/resources/org/apache/camel/component/iec60870/client/iec60870-client.json
index 07768f0..a4732ba 100644
--- a/components/camel-iec60870/src/generated/resources/org/apache/camel/component/iec60870/client/iec60870-client.json
+++ b/components/camel-iec60870/src/generated/resources/org/apache/camel/component/iec60870/client/iec60870-client.json
@@ -27,6 +27,12 @@
     "lazyStartProducer": { "kind": "property", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": 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 star [...]
     "autowiredEnabled": { "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which t [...]
   },
+  "headers": {
+    "CamelIec60870Value": { "kind": "header", "displayName": "", "group": "consumer", "label": "consumer", "required": false, "javaType": "Object", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The value" },
+    "CamelIec60870Timestamp": { "kind": "header", "displayName": "", "group": "consumer", "label": "consumer", "required": false, "javaType": "long", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The timestamp of the value" },
+    "CamelIec60870Quality": { "kind": "header", "displayName": "", "group": "consumer", "label": "consumer", "required": false, "javaType": "org.eclipse.neoscada.protocol.iec60870.asdu.types.QualityInformation", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The quality information of the value" },
+    "CamelIec60870Overflow": { "kind": "header", "displayName": "", "group": "consumer", "label": "consumer", "required": false, "javaType": "boolean", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Is overflow" }
+  },
   "properties": {
     "uriPath": { "kind": "path", "displayName": "Uri Path", "group": "common", "label": "", "required": true, "type": "object", "javaType": "org.apache.camel.component.iec60870.ObjectAddress", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The object information address" },
     "dataModuleOptions": { "kind": "parameter", "displayName": "Data Module Options", "group": "common", "label": "", "required": false, "type": "object", "javaType": "org.eclipse.neoscada.protocol.iec60870.client.data.DataModuleOptions", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.iec60870.client.ClientOptions", "configurationField": "connectionOptions", "description": "Data module options" },
diff --git a/components/camel-iec60870/src/generated/resources/org/apache/camel/component/iec60870/server/iec60870-server.json b/components/camel-iec60870/src/generated/resources/org/apache/camel/component/iec60870/server/iec60870-server.json
index a35ebbb..5f2726c 100644
--- a/components/camel-iec60870/src/generated/resources/org/apache/camel/component/iec60870/server/iec60870-server.json
+++ b/components/camel-iec60870/src/generated/resources/org/apache/camel/component/iec60870/server/iec60870-server.json
@@ -27,6 +27,14 @@
     "lazyStartProducer": { "kind": "property", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": 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 star [...]
     "autowiredEnabled": { "kind": "property", "displayName": "Autowired Enabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which t [...]
   },
+  "headers": {
+    "address": { "kind": "header", "displayName": "", "group": "consumer", "label": "consumer", "required": false, "javaType": "org.apache.camel.component.iec60870.ObjectAddress", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The address as ObjectAddress" },
+    "value": { "kind": "header", "displayName": "", "group": "consumer", "label": "consumer", "required": false, "javaType": "Object", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The value" },
+    "informationObjectAddress": { "kind": "header", "displayName": "", "group": "consumer", "label": "consumer", "required": false, "javaType": "org.eclipse.neoscada.protocol.iec60870.asdu.types.InformationObjectAddress", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The address as InformationObjectAddress" },
+    "asduHeader": { "kind": "header", "displayName": "", "group": "consumer", "label": "consumer", "required": false, "javaType": "org.eclipse.neoscada.protocol.iec60870.asdu.ASDUHeader", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The ASDU header" },
+    "type": { "kind": "header", "displayName": "", "group": "consumer", "label": "consumer", "required": false, "javaType": "byte", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The type" },
+    "execute": { "kind": "header", "displayName": "", "group": "consumer", "label": "consumer", "required": false, "javaType": "boolean", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Is execute" }
+  },
   "properties": {
     "uriPath": { "kind": "path", "displayName": "Uri Path", "group": "common", "label": "", "required": true, "type": "object", "javaType": "org.apache.camel.component.iec60870.ObjectAddress", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The object information address" },
     "dataModuleOptions": { "kind": "parameter", "displayName": "Data Module Options", "group": "common", "label": "", "required": false, "type": "object", "javaType": "org.eclipse.neoscada.protocol.iec60870.client.data.DataModuleOptions", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.iec60870.client.ClientOptions", "configurationField": "connectionOptions", "description": "Data module options" },
diff --git a/components/camel-iec60870/src/main/docs/iec60870-client-component.adoc b/components/camel-iec60870/src/main/docs/iec60870-client-component.adoc
index 118c018..863ff89 100644
--- a/components/camel-iec60870/src/main/docs/iec60870-client-component.adoc
+++ b/components/camel-iec60870/src/main/docs/iec60870-client-component.adoc
@@ -71,5 +71,8 @@ include::partial$component-endpoint-options.adoc[]
 
 // endpoint options: END
 
+// component headers: START
+include::partial$component-endpoint-headers.adoc[]
+// component headers: END
 
 include::spring-boot:partial$starter.adoc[]
diff --git a/components/camel-iec60870/src/main/docs/iec60870-server-component.adoc b/components/camel-iec60870/src/main/docs/iec60870-server-component.adoc
index 8de026c..cb95ee5 100644
--- a/components/camel-iec60870/src/main/docs/iec60870-server-component.adoc
+++ b/components/camel-iec60870/src/main/docs/iec60870-server-component.adoc
@@ -55,6 +55,8 @@ include::partial$component-endpoint-options.adoc[]
 
 // endpoint options: END
 
-
+// component headers: START
+include::partial$component-endpoint-headers.adoc[]
+// component headers: END
 
 include::spring-boot:partial$starter.adoc[]
diff --git a/components/camel-iec60870/src/main/java/org/apache/camel/component/iec60870/Constants.java b/components/camel-iec60870/src/main/java/org/apache/camel/component/iec60870/Constants.java
index 65d2b31..63ce3fa 100644
--- a/components/camel-iec60870/src/main/java/org/apache/camel/component/iec60870/Constants.java
+++ b/components/camel-iec60870/src/main/java/org/apache/camel/component/iec60870/Constants.java
@@ -16,15 +16,42 @@
  */
 package org.apache.camel.component.iec60870;
 
+import org.apache.camel.spi.Metadata;
+
 public interface Constants {
+
+    String SCHEME_SERVER = "iec60870-server";
+    String SCHEME_CLIENT = "iec60870-client";
+
     String PARAM_DATA_MODULE_OPTIONS = "dataModuleOptions";
 
     String PARAM_PROTOCOL_OPTIONS = "protocolOptions";
 
     String PARAM_CONNECTION_OPTIONS = "connectionOptions";
 
+    @Metadata(label = "consumer", description = "The value", javaType = "Object", applicableFor = SCHEME_CLIENT)
     String IEC60870_VALUE = "CamelIec60870Value";
+    @Metadata(label = "consumer", description = "The timestamp of the value", javaType = "long", applicableFor = SCHEME_CLIENT)
     String IEC60870_TIMESTAMP = "CamelIec60870Timestamp";
+    @Metadata(label = "consumer", description = "The quality information of the value",
+              javaType = "org.eclipse.neoscada.protocol.iec60870.asdu.types.QualityInformation", applicableFor = SCHEME_CLIENT)
     String IEC60870_QUALITY = "CamelIec60870Quality";
+    @Metadata(label = "consumer", description = "Is overflow", javaType = "boolean", applicableFor = SCHEME_CLIENT)
     String IEC60870_OVERFLOW = "CamelIec60870Overflow";
+    @Metadata(label = "consumer", description = "The address as ObjectAddress",
+              javaType = "org.apache.camel.component.iec60870.ObjectAddress", applicableFor = SCHEME_SERVER)
+    String ADDRESS = "address";
+    @Metadata(label = "consumer", description = "The value", javaType = "Object", applicableFor = SCHEME_SERVER)
+    String VALUE = "value";
+    @Metadata(label = "consumer", description = "The address as InformationObjectAddress",
+              javaType = "org.eclipse.neoscada.protocol.iec60870.asdu.types.InformationObjectAddress",
+              applicableFor = SCHEME_SERVER)
+    String INFORMATION_OBJECT_ADDRESS = "informationObjectAddress";
+    @Metadata(label = "consumer", description = "The ASDU header",
+              javaType = "org.eclipse.neoscada.protocol.iec60870.asdu.ASDUHeader", applicableFor = SCHEME_SERVER)
+    String ASDU_HEADER = "asduHeader";
+    @Metadata(label = "consumer", description = "The type", javaType = "byte", applicableFor = SCHEME_SERVER)
+    String TYPE = "type";
+    @Metadata(label = "consumer", description = "Is execute", javaType = "boolean", applicableFor = SCHEME_SERVER)
+    String EXECUTE = "execute";
 }
diff --git a/components/camel-iec60870/src/main/java/org/apache/camel/component/iec60870/client/ClientEndpoint.java b/components/camel-iec60870/src/main/java/org/apache/camel/component/iec60870/client/ClientEndpoint.java
index c5f23d3..d4092a4 100644
--- a/components/camel-iec60870/src/main/java/org/apache/camel/component/iec60870/client/ClientEndpoint.java
+++ b/components/camel-iec60870/src/main/java/org/apache/camel/component/iec60870/client/ClientEndpoint.java
@@ -21,17 +21,19 @@ import org.apache.camel.Consumer;
 import org.apache.camel.Processor;
 import org.apache.camel.Producer;
 import org.apache.camel.component.iec60870.AbstractIecEndpoint;
+import org.apache.camel.component.iec60870.Constants;
 import org.apache.camel.component.iec60870.ObjectAddress;
 import org.apache.camel.spi.UriEndpoint;
 import org.apache.camel.support.DefaultComponent;
 
 import static java.util.Objects.requireNonNull;
+import static org.apache.camel.component.iec60870.Constants.SCHEME_CLIENT;
 
 /**
  * IEC 60870 supervisory control and data acquisition (SCADA) client using NeoSCADA implementation.
  */
-@UriEndpoint(firstVersion = "2.20.0", scheme = "iec60870-client", syntax = "iec60870-client:uriPath",
-             title = "IEC 60870 Client", category = { Category.IOT })
+@UriEndpoint(firstVersion = "2.20.0", scheme = SCHEME_CLIENT, syntax = "iec60870-client:uriPath",
+             title = "IEC 60870 Client", category = { Category.IOT }, headersClass = Constants.class)
 public class ClientEndpoint extends AbstractIecEndpoint<ClientConnectionMultiplexor> {
 
     public ClientEndpoint(final String uri, final DefaultComponent component, final ClientConnectionMultiplexor connection,
diff --git a/components/camel-iec60870/src/main/java/org/apache/camel/component/iec60870/server/ServerConsumer.java b/components/camel-iec60870/src/main/java/org/apache/camel/component/iec60870/server/ServerConsumer.java
index 2444361..78cbf28 100644
--- a/components/camel-iec60870/src/main/java/org/apache/camel/component/iec60870/server/ServerConsumer.java
+++ b/components/camel-iec60870/src/main/java/org/apache/camel/component/iec60870/server/ServerConsumer.java
@@ -22,6 +22,7 @@ import java.util.concurrent.CompletionStage;
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 import org.apache.camel.Processor;
+import org.apache.camel.component.iec60870.Constants;
 import org.apache.camel.component.iec60870.ObjectAddress;
 import org.apache.camel.support.DefaultConsumer;
 import org.apache.camel.support.DefaultMessage;
@@ -98,12 +99,12 @@ public class ServerConsumer extends DefaultConsumer {
 
         message.setBody(request);
 
-        message.setHeader("address", ObjectAddress.valueOf(request.getHeader().getAsduAddress(), request.getAddress()));
-        message.setHeader("value", request.getValue());
-        message.setHeader("informationObjectAddress", request.getAddress());
-        message.setHeader("asduHeader", request.getHeader());
-        message.setHeader("type", request.getType());
-        message.setHeader("execute", request.isExecute());
+        message.setHeader(Constants.ADDRESS, ObjectAddress.valueOf(request.getHeader().getAsduAddress(), request.getAddress()));
+        message.setHeader(Constants.VALUE, request.getValue());
+        message.setHeader(Constants.INFORMATION_OBJECT_ADDRESS, request.getAddress());
+        message.setHeader(Constants.ASDU_HEADER, request.getHeader());
+        message.setHeader(Constants.TYPE, request.getType());
+        message.setHeader(Constants.EXECUTE, request.isExecute());
 
         return message;
     }
diff --git a/components/camel-iec60870/src/main/java/org/apache/camel/component/iec60870/server/ServerEndpoint.java b/components/camel-iec60870/src/main/java/org/apache/camel/component/iec60870/server/ServerEndpoint.java
index 063ca8f..f453c87 100644
--- a/components/camel-iec60870/src/main/java/org/apache/camel/component/iec60870/server/ServerEndpoint.java
+++ b/components/camel-iec60870/src/main/java/org/apache/camel/component/iec60870/server/ServerEndpoint.java
@@ -21,18 +21,20 @@ import org.apache.camel.Consumer;
 import org.apache.camel.Processor;
 import org.apache.camel.Producer;
 import org.apache.camel.component.iec60870.AbstractIecEndpoint;
+import org.apache.camel.component.iec60870.Constants;
 import org.apache.camel.component.iec60870.ObjectAddress;
 import org.apache.camel.spi.UriEndpoint;
 import org.apache.camel.spi.UriParam;
 import org.apache.camel.support.DefaultComponent;
 
 import static java.util.Objects.requireNonNull;
+import static org.apache.camel.component.iec60870.Constants.SCHEME_SERVER;
 
 /**
  * IEC 60870 supervisory control and data acquisition (SCADA) server using NeoSCADA implementation.
  */
-@UriEndpoint(firstVersion = "2.20.0", scheme = "iec60870-server", syntax = "iec60870-server:uriPath",
-             title = "IEC 60870 Server", category = { Category.IOT })
+@UriEndpoint(firstVersion = "2.20.0", scheme = SCHEME_SERVER, syntax = "iec60870-server:uriPath",
+             title = "IEC 60870 Server", category = { Category.IOT }, headersClass = Constants.class)
 public class ServerEndpoint extends AbstractIecEndpoint<ServerConnectionMultiplexor> {
 
     /**