You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Claus Ibsen (Jira)" <ji...@apache.org> on 2023/04/04 16:35:00 UTC

[jira] [Assigned] (CAMEL-19234) camel-core - When looking up a mandatory bean, look it up through its type first

     [ https://issues.apache.org/jira/browse/CAMEL-19234?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claus Ibsen reassigned CAMEL-19234:
-----------------------------------

    Assignee: Claus Ibsen

> camel-core - When looking up a mandatory bean, look it up through its type first
> --------------------------------------------------------------------------------
>
>                 Key: CAMEL-19234
>                 URL: https://issues.apache.org/jira/browse/CAMEL-19234
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-core
>    Affects Versions: 3.0.0-M3
>            Reporter: Marco Bungart
>            Assignee: Claus Ibsen
>            Priority: Minor
>
> Currently, when we look up a mandatory bean which type we know, we perform the lookup with the bean's name and convert it to the requested type:
> {code:java|title=CamelContextHelper.java}
> ...
> public static <T> T mandatoryLookupAndConvert(CamelContext context, String name, Class<T> beanType) {
>     Object value = lookup(context, name);
>     if (value == null){
>         throw new NoSuchBeanException(name, beanType.getName());
>     }
>     return convertTo(context, beanType, value);
> }
> ...
> {code}
> Source: [https://github.com/apache/camel/blob/main/core/camel-support/src/main/java/org/apache/camel/support/CamelContextHelper.java#L245]
> This leads to problem with the current implementation of [https://github.com/apache/camel-quarkus/issues/4725], where we introduced automatic registration of beans annotated with {{@Identifier}} . When several beans with the same {{@Identifier("<name>")}} but different types are present. We think we can prevent this problem when we modify above method to do a {{lookup(...)}} with the type information, and only do the {{lookup(...)}} without type information if the {{{}lookup(...){}}}with type information yielded no result.
> FTR: [relevant zulip chat|https://camel.zulipchat.com/#narrow/stream/257302-camel-quarkus/topic/Resolution.20of.20.40Identifier.20dependency]



--
This message was sent by Atlassian Jira
(v8.20.10#820010)