You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Adam Ostrožlík (Jira)" <ji...@apache.org> on 2020/10/03 08:02:00 UTC

[jira] [Comment Edited] (CAMEL-15622) endpoint-dsl - Bean name evaluated as string in sql component

    [ https://issues.apache.org/jira/browse/CAMEL-15622?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17206631#comment-17206631 ] 

Adam Ostrožlík edited comment on CAMEL-15622 at 10/3/20, 8:01 AM:
------------------------------------------------------------------

What about resolving this issue in lower level in 
{code:java}
org.apache.camel.support.DefaultComponent#resolveAndRemoveReferenceParameter(java.util.Map<java.lang.String,java.lang.Object>, java.lang.String, java.lang.Class<T>)
{code}
There are parameter and also type specified (in this case "dataSource" and DataSource.class). The algorithm would just get the parameter and If types match, it would simply return the value from parameters without any transformation. 

Maybe something like this?
{code:java}
public < T extends Object > T resolveAndRemoveReferenceParameter(Map < String, Object > parameters, String key, Class < T > type) {
    if (parameters.containsKey(key) && type.isAssignableFrom(parameters.get(key).getClass()) {
        return type.cast(parameters.get(key));
    }
    return resolveAndRemoveReferenceParameter(parameters, key, type, null);
}{code}


was (Author: drezir):
What about resolving this issue in lower level in 
{code:java}
org.apache.camel.support.DefaultComponent#resolveAndRemoveReferenceParameter(java.util.Map<java.lang.String,java.lang.Object>, java.lang.String, java.lang.Class<T>)
{code}
There are parameter and also type specified (in this case "dataSource" and DataSource.class). The algorithm would just get the parameter and If types match, it would simply return the value from parameters without any transformation. 

Maybe something like this?
{code:java}
public < T extends Object > T resolveAndRemoveReferenceParameter(Map < String, Object > parameters, String key, Class < T > type) {
    if (parameters.containsKey(key) && parameters.get(key).getClass().isAssignableFrom(type)) {
        return type.cast(parameters.get(key));
    }
    return resolveAndRemoveReferenceParameter(parameters, key, type, null);
}{code}

> endpoint-dsl - Bean name evaluated as string in sql component
> -------------------------------------------------------------
>
>                 Key: CAMEL-15622
>                 URL: https://issues.apache.org/jira/browse/CAMEL-15622
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-sql
>    Affects Versions: 3.5.0
>            Reporter: Adam Ostrožlík
>            Priority: Major
>
> Hi,
> I have this stack:
>  * camel spring boot starter
>  * camel-sql component
>  * camel endpoint DSL
> I have this code:
> {code:java}
> .to(sql("classpath:sql/zentiva.sql").dataSource("zentivaDataSource"))
> {code}
> If I use instance of DataSource object and set it in .datasource(dataSourceBean()) there is actually a problem that camel is looking in springbootcamelcontext for the name of the result of *dataSourceBean.toString()* which might be like HikariDataSource (null). Lookup for wrong bean name happens in
> {code:java}
> org.apache.camel.support.CamelContextHelper#mandatoryLookupAndConvert
> {code}
> Route with bean instance is not working properly. As a workaround, we have to use name of the bean.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)