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 b0bbaab1512628a7f143ffac0cc4a6b891ce575c Author: Nicolas Filotto <[email protected]> AuthorDate: Wed Mar 30 11:25:43 2022 +0200 CAMEL-17792: Add doc about the message headers of camel-jdbc --- .../org/apache/camel/component/jdbc/jdbc.json | 10 ++++++++ .../camel-jdbc/src/main/docs/jdbc-component.adoc | 27 +++------------------- .../apache/camel/component/jdbc/JdbcConstants.java | 26 ++++++++++++++++++--- .../apache/camel/component/jdbc/JdbcEndpoint.java | 2 +- 4 files changed, 37 insertions(+), 28 deletions(-) diff --git a/components/camel-jdbc/src/generated/resources/org/apache/camel/component/jdbc/jdbc.json b/components/camel-jdbc/src/generated/resources/org/apache/camel/component/jdbc/jdbc.json index 827fb2e..3a65cc1 100644 --- a/components/camel-jdbc/src/generated/resources/org/apache/camel/component/jdbc/jdbc.json +++ b/components/camel-jdbc/src/generated/resources/org/apache/camel/component/jdbc/jdbc.json @@ -27,6 +27,16 @@ "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 [...] "connectionStrategy": { "kind": "property", "displayName": "Connection Strategy", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.component.jdbc.ConnectionStrategy", "deprecated": false, "autowired": false, "secret": false, "description": "To use a custom strategy for working with connections. Do not use a custom strategy when using the spring-jdbc component because a special Spring ConnectionStrategy is used by default to [...] }, + "headers": { + "CamelJdbcUpdateCount": { "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "int", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "If the query is an `UPDATE`, query the update count is returned in this\nOUT header." }, + "CamelJdbcRowCount": { "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "int", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "If the query is a `SELECT`, query the row count is returned in this OUT\nheader." }, + "CamelJdbcColumnNames": { "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "Set<String>", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The column names from the ResultSet as a `java.util.Set`\ntype." }, + "CamelJdbcParameters": { "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "Map", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "A `java.util.Map` which has the headers to be used if\n`useHeadersAsParameters` has been enabled." }, + "CamelRetrieveGeneratedKeys": { "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "Boolean", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": "false", "description": "Set its value to true to retrieve generated keys" }, + "CamelGeneratedColumns": { "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "String[] or int[]", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Set it to specify the expected generated columns" }, + "CamelGeneratedKeysRowCount": { "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "int", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The number of rows in the header that contains generated\nkeys." }, + "CamelGeneratedKeysRows": { "kind": "header", "displayName": "", "group": "producer", "label": "producer", "required": false, "javaType": "List<Map<String, Object>>", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Rows that contains the generated keys." } + }, "properties": { "dataSourceName": { "kind": "path", "displayName": "Data Source Name", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Name of DataSource to lookup in the Registry. If the name is dataSource or default, then Camel will attempt to lookup a default DataSource from the registry, meaning if there is a only one instance of DataSource found, [...] "allowNamedParameters": { "kind": "parameter", "displayName": "Allow Named Parameters", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "description": "Whether to allow using named parameters in the queries." }, diff --git a/components/camel-jdbc/src/main/docs/jdbc-component.adoc b/components/camel-jdbc/src/main/docs/jdbc-component.adoc index a96bef6..9253412 100644 --- a/components/camel-jdbc/src/main/docs/jdbc-component.adoc +++ b/components/camel-jdbc/src/main/docs/jdbc-component.adoc @@ -58,6 +58,9 @@ include::partial$component-endpoint-options.adoc[] // endpoint options: END +// component headers: START +include::partial$component-endpoint-headers.adoc[] +// component headers: END == Result @@ -70,30 +73,6 @@ the result. *Note:* This component fetches `ResultSetMetaData` to be able to return the column name as the key in the `Map`. -=== Message Headers - -[width="100%",cols="10%,90%",options="header",] -|=== -|Header |Description - -|`CamelJdbcRowCount` |If the query is a `SELECT`, query the row count is returned in this OUT -header. - -|`CamelJdbcUpdateCount` |If the query is an `UPDATE`, query the update count is returned in this -OUT header. - -|`CamelGeneratedKeysRows` |Rows that contains the generated keys. - -|`CamelGeneratedKeysRowCount` |The number of rows in the header that contains generated -keys. - -|`CamelJdbcColumnNames` |The column names from the ResultSet as a `java.util.Set` -type. - -|`CamelJdbcParameters` |A `java.util.Map` which has the headers to be used if -`useHeadersAsParameters` has been enabled. -|=== - == Generated keys If you insert data using SQL INSERT, then the RDBMS may support auto diff --git a/components/camel-jdbc/src/main/java/org/apache/camel/component/jdbc/JdbcConstants.java b/components/camel-jdbc/src/main/java/org/apache/camel/component/jdbc/JdbcConstants.java index ef8b723..3dcd18c 100644 --- a/components/camel-jdbc/src/main/java/org/apache/camel/component/jdbc/JdbcConstants.java +++ b/components/camel-jdbc/src/main/java/org/apache/camel/component/jdbc/JdbcConstants.java @@ -16,22 +16,35 @@ */ package org.apache.camel.component.jdbc; +import org.apache.camel.spi.Metadata; + /** * JDBC Constants */ public final class JdbcConstants { + @Metadata(label = "producer", description = "If the query is an `UPDATE`, query the update count is returned in this\n" + + "OUT header.", + javaType = "int") public static final String JDBC_UPDATE_COUNT = "CamelJdbcUpdateCount"; - + @Metadata(label = "producer", description = "If the query is a `SELECT`, query the row count is returned in this OUT\n" + + "header.", + javaType = "int") public static final String JDBC_ROW_COUNT = "CamelJdbcRowCount"; - + @Metadata(label = "producer", description = "The column names from the ResultSet as a `java.util.Set`\n" + + "type.", + javaType = "Set<String>") public static final String JDBC_COLUMN_NAMES = "CamelJdbcColumnNames"; - + @Metadata(label = "producer", description = "A `java.util.Map` which has the headers to be used if\n" + + "`useHeadersAsParameters` has been enabled.", + javaType = "Map") public static final String JDBC_PARAMETERS = "CamelJdbcParameters"; /** * Boolean input header. Set its value to true to retrieve generated keys, default is false */ + @Metadata(label = "producer", description = "Set its value to true to retrieve generated keys", javaType = "Boolean", + defaultValue = "false") public static final String JDBC_RETRIEVE_GENERATED_KEYS = "CamelRetrieveGeneratedKeys"; /** @@ -44,16 +57,23 @@ public final class JdbcConstants { * href="http://docs.oracle.com/javase/6/docs/api/java/sql/Statement.html#execute(java.lang.String, java.lang.String[])"> * java.sql.Statement.execute(java.lang.String, java.lang.String[])</a> */ + @Metadata(label = "producer", description = "Set it to specify the expected generated columns", + javaType = "String[] or int[]") public static final String JDBC_GENERATED_COLUMNS = "CamelGeneratedColumns"; /** * int output header giving the number of rows of generated keys */ + @Metadata(label = "producer", description = "The number of rows in the header that contains generated\n" + + "keys.", + javaType = "int") public static final String JDBC_GENERATED_KEYS_ROW_COUNT = "CamelGeneratedKeysRowCount"; /** * <tt>List<Map<String, Object>></tt> output header containing the generated keys retrieved */ + @Metadata(label = "producer", description = "Rows that contains the generated keys.", + javaType = "List<Map<String, Object>>") public static final String JDBC_GENERATED_KEYS_DATA = "CamelGeneratedKeysRows"; private JdbcConstants() { diff --git a/components/camel-jdbc/src/main/java/org/apache/camel/component/jdbc/JdbcEndpoint.java b/components/camel-jdbc/src/main/java/org/apache/camel/component/jdbc/JdbcEndpoint.java index cee84ef..34fbad3 100644 --- a/components/camel-jdbc/src/main/java/org/apache/camel/component/jdbc/JdbcEndpoint.java +++ b/components/camel-jdbc/src/main/java/org/apache/camel/component/jdbc/JdbcEndpoint.java @@ -35,7 +35,7 @@ import org.apache.camel.support.DefaultEndpoint; * Access databases through SQL and JDBC. */ @UriEndpoint(firstVersion = "1.2.0", scheme = "jdbc", title = "JDBC", syntax = "jdbc:dataSourceName", producerOnly = true, - category = { Category.DATABASE, Category.SQL }) + category = { Category.DATABASE, Category.SQL }, headersClass = JdbcConstants.class) public class JdbcEndpoint extends DefaultEndpoint { private DataSource dataSource;
