You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Marco Bungart (Jira)" <ji...@apache.org> on 2023/04/02 15:44:00 UTC
[jira] [Updated] (CAMEL-19234) 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 ]
Marco Bungart updated CAMEL-19234:
----------------------------------
Description:
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}
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>")}} 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 yielded no result.
FTR: [relevant zulip chat|https://camel.zulipchat.com/#narrow/stream/257302-camel-quarkus/topic/Resolution.20of.20.40Identifier.20dependency]
was:
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:
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);
}
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>")}} 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 yielded no result.
FTR: [relevant zulip chat|https://camel.zulipchat.com/#narrow/stream/257302-camel-quarkus/topic/Resolution.20of.20.40Identifier.20dependency]
> 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: Bug
> Components: camel-core
> Affects Versions: 3.0.0-M3
> Reporter: Marco Bungart
> 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}
> 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>")}} 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 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)