Skip to content

Commit

Permalink
CAMEL-16732: camel-sql - DataSource should be autowired
Browse files Browse the repository at this point in the history
  • Loading branch information
davsclaus committed Jun 18, 2021
1 parent ba1bfcc commit 8d4714d
Show file tree
Hide file tree
Showing 17 changed files with 107 additions and 97 deletions.
Expand Up @@ -69,7 +69,7 @@ The ElSQL component supports 7 options, which are listed below.
|===
| Name | Description | Default | Type
| *databaseVendor* (common) | To use a vendor specific com.opengamma.elsql.ElSqlConfig. There are 7 enums and the value can be one of: Default, Postgres, HSql, MySql, Oracle, SqlServer2008, Veritca | | ElSqlDatabaseVendor
| *dataSource* (common) | Sets the DataSource to use to communicate with the database. | | DataSource
| *dataSource* (common) | *Autowired* Sets the DataSource to use to communicate with the database. | | DataSource
| *resourceUri* (common) | The resource file which contains the elsql SQL statements to use. You can specify multiple resources separated by comma. The resources are loaded on the classpath by default, you can prefix with file: to load from file system. Notice you can set this option on the component and then you do not have to configure this on the endpoint. | | String
| *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
| *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 starting the producer may take a little time and prolong the total processing time of the processing. | false | boolean
Expand Down Expand Up @@ -106,7 +106,7 @@ with the following path and query parameters:
| Name | Description | Default | Type
| *allowNamedParameters* (common) | Whether to allow using named parameters in the queries. | true | boolean
| *databaseVendor* (common) | To use a vendor specific com.opengamma.elsql.ElSqlConfig. There are 7 enums and the value can be one of: Default, Postgres, HSql, MySql, Oracle, SqlServer2008, Veritca | | ElSqlDatabaseVendor
| *dataSource* (common) | Sets the DataSource to use to communicate with the database at endpoint level. | | DataSource
| *dataSource* (common) | *Autowired* Sets the DataSource to use to communicate with the database at endpoint level. | | DataSource
| *outputClass* (common) | Specify the full package and class name to use as conversion when outputType=SelectOne. | | String
| *outputHeader* (common) | Store the query result in a header instead of the message body. By default, outputHeader == null and the query result is stored in the message body, any existing content in the message body is discarded. If outputHeader is set, the value is used as the name of the header to store the query result and the original message body is preserved. | | String
| *outputType* (common) | Make the output of consumer or producer to SelectList as List of Map, or SelectOne as single Java object in the following way: a) If the query has only single column, then that JDBC Column object is returned. (such as SELECT COUNT( ) FROM PROJECT will return a Long object. b) If the query has more than one column, then it will return a Map of that result. c) If the outputClass is set, then it will convert the query result into an Java bean object by calling all the setters that match the column names. It will assume your class has a default constructor to create instance with. d) If the query resulted in more than one rows, it throws an non-unique result exception. StreamList streams the result of the query using an Iterator. This can be used with the Splitter EIP in streaming mode to process the ResultSet in streaming fashion. There are 3 enums and the value can be one of: SelectOne, SelectList, StreamList | SelectList | SqlOutputType
Expand Down
Expand Up @@ -124,7 +124,7 @@ The SQL component supports 5 options, which are listed below.
[width="100%",cols="2,5,^1,2",options="header"]
|===
| Name | Description | Default | Type
| *dataSource* (common) | Sets the DataSource to use to communicate with the database. | | DataSource
| *dataSource* (common) | *Autowired* Sets the DataSource to use to communicate with the database. | | DataSource
| *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
| *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 starting the producer may take a little time and prolong the total processing time of the processing. | false | boolean
| *autowiredEnabled* (advanced) | 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 then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc. | true | boolean
Expand Down Expand Up @@ -161,7 +161,7 @@ with the following path and query parameters:
|===
| Name | Description | Default | Type
| *allowNamedParameters* (common) | Whether to allow using named parameters in the queries. | true | boolean
| *dataSource* (common) | Sets the DataSource to use to communicate with the database at endpoint level. | | DataSource
| *dataSource* (common) | *Autowired* Sets the DataSource to use to communicate with the database at endpoint level. | | DataSource
| *outputClass* (common) | Specify the full package and class name to use as conversion when outputType=SelectOne. | | String
| *outputHeader* (common) | Store the query result in a header instead of the message body. By default, outputHeader == null and the query result is stored in the message body, any existing content in the message body is discarded. If outputHeader is set, the value is used as the name of the header to store the query result and the original message body is preserved. | | String
| *outputType* (common) | Make the output of consumer or producer to SelectList as List of Map, or SelectOne as single Java object in the following way: a) If the query has only single column, then that JDBC Column object is returned. (such as SELECT COUNT( ) FROM PROJECT will return a Long object. b) If the query has more than one column, then it will return a Map of that result. c) If the outputClass is set, then it will convert the query result into an Java bean object by calling all the setters that match the column names. It will assume your class has a default constructor to create instance with. d) If the query resulted in more than one rows, it throws an non-unique result exception. StreamList streams the result of the query using an Iterator. This can be used with the Splitter EIP in streaming mode to process the ResultSet in streaming fashion. There are 3 enums and the value can be one of: SelectOne, SelectList, StreamList | SelectList | SqlOutputType
Expand Down
Expand Up @@ -39,6 +39,11 @@ public boolean configure(CamelContext camelContext, Object obj, String name, Obj
}
}

@Override
public String[] getAutowiredNames() {
return new String[]{"dataSource"};
}

@Override
public Class<?> getOptionType(String name, boolean ignoreCase) {
switch (ignoreCase ? name.toLowerCase() : name) {
Expand Down
Expand Up @@ -111,6 +111,11 @@ public boolean configure(CamelContext camelContext, Object obj, String name, Obj
}
}

@Override
public String[] getAutowiredNames() {
return new String[]{"dataSource"};
}

@Override
public Class<?> getOptionType(String name, boolean ignoreCase) {
switch (ignoreCase ? name.toLowerCase() : name) {
Expand Down
Expand Up @@ -23,7 +23,7 @@
},
"componentProperties": {
"databaseVendor": { "kind": "property", "displayName": "Database Vendor", "group": "common", "label": "", "required": false, "type": "object", "javaType": "org.apache.camel.component.elsql.ElSqlDatabaseVendor", "enum": [ "Default", "Postgres", "HSql", "MySql", "Oracle", "SqlServer2008", "Veritca" ], "deprecated": false, "autowired": false, "secret": false, "description": "To use a vendor specific com.opengamma.elsql.ElSqlConfig" },
"dataSource": { "kind": "property", "displayName": "Data Source", "group": "common", "label": "", "required": false, "type": "object", "javaType": "javax.sql.DataSource", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the DataSource to use to communicate with the database." },
"dataSource": { "kind": "property", "displayName": "Data Source", "group": "common", "label": "", "required": false, "type": "object", "javaType": "javax.sql.DataSource", "deprecated": false, "autowired": true, "secret": false, "description": "Sets the DataSource to use to communicate with the database." },
"resourceUri": { "kind": "property", "displayName": "Resource Uri", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The resource file which contains the elsql SQL statements to use. You can specify multiple resources separated by comma. The resources are loaded on the classpath by default, you can prefix with file: to load from file system. Notice you can set this option on the component and then you do not have to configure this on the endpoint." },
"bridgeErrorHandler": { "kind": "property", "displayName": "Bridge Error Handler", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": 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 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." },
"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 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 starting the producer may take a little time and prolong the total processing time of the processing." },
Expand All @@ -35,7 +35,7 @@
"resourceUri": { "kind": "path", "displayName": "Resource Uri", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The resource file which contains the elsql SQL statements to use. You can specify multiple resources separated by comma. The resources are loaded on the classpath by default, you can prefix with file: to load from file system. Notice you can set this option on the component and then you do not have to configure this on the endpoint." },
"allowNamedParameters": { "kind": "parameter", "displayName": "Allow Named Parameters", "group": "common", "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." },
"databaseVendor": { "kind": "parameter", "displayName": "Database Vendor", "group": "common", "label": "", "required": false, "type": "object", "javaType": "org.apache.camel.component.elsql.ElSqlDatabaseVendor", "enum": [ "Default", "Postgres", "HSql", "MySql", "Oracle", "SqlServer2008", "Veritca" ], "deprecated": false, "autowired": false, "secret": false, "description": "To use a vendor specific com.opengamma.elsql.ElSqlConfig" },
"dataSource": { "kind": "parameter", "displayName": "Data Source", "group": "common", "label": "", "required": false, "type": "object", "javaType": "javax.sql.DataSource", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the DataSource to use to communicate with the database at endpoint level." },
"dataSource": { "kind": "parameter", "displayName": "Data Source", "group": "common", "label": "", "required": false, "type": "object", "javaType": "javax.sql.DataSource", "deprecated": false, "deprecationNote": "", "autowired": true, "secret": false, "description": "Sets the DataSource to use to communicate with the database at endpoint level." },
"outputClass": { "kind": "parameter", "displayName": "Output Class", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Specify the full package and class name to use as conversion when outputType=SelectOne." },
"outputHeader": { "kind": "parameter", "displayName": "Output Header", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Store the query result in a header instead of the message body. By default, outputHeader == null and the query result is stored in the message body, any existing content in the message body is discarded. If outputHeader is set, the value is used as the name of the header to store the query result and the original message body is preserved." },
"outputType": { "kind": "parameter", "displayName": "Output Type", "group": "common", "label": "", "required": false, "type": "object", "javaType": "org.apache.camel.component.sql.SqlOutputType", "enum": [ "SelectOne", "SelectList", "StreamList" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "SelectList", "description": "Make the output of consumer or producer to SelectList as List of Map, or SelectOne as single Java object in the following way: a) If the query has only single column, then that JDBC Column object is returned. (such as SELECT COUNT( ) FROM PROJECT will return a Long object. b) If the query has more than one column, then it will return a Map of that result. c) If the outputClass is set, then it will convert the query result into an Java bean object by calling all the setters that match the column names. It will assume your class has a default constructor to create instance with. d) If the query resulted in more than one rows, it throws an non-unique result exception. StreamList streams the result of the query using an Iterator. This can be used with the Splitter EIP in streaming mode to process the ResultSet in streaming fashion." },
Expand Down

0 comments on commit 8d4714d

Please sign in to comment.