Luca Burgazzoli created CAMEL-13948:
---------------------------------------

             Summary: Uupredictable registry lookup
                 Key: CAMEL-13948
                 URL: https://issues.apache.org/jira/browse/CAMEL-13948
             Project: Camel
          Issue Type: Improvement
          Components: camel-core
            Reporter: Luca Burgazzoli
             Fix For: 3.0.0, 3.0.0.RC2


The camel registry support binding multiple classes to the same entry via the 
bind method:

    void bind(String id, Class<?> type, Object bean)

The underlying implementation is roughly:

    void bind(String id, Class<?> type, Object bean) {
        computeIfAbsent(id, k -> new LinkedHashMap<>()).put(type, bean);
    }
 
So assuming I have a class MyLogComponent which extends LogComponent and I do 
the following binding:

    Component a = new LogComponent()
    Component b = new MyLogComponent()

    registry.bind("log", LogComponent.class, a )
    registry.bind("log", MyLogComponent.class, b)

then lookupByNameAndType may return different values depending on the type used 
for looking up the beans:

    registry.lookupByNameAndType("log", LogComponent.class)  ==> a
    registry.lookupByNameAndType("log", MyLogComponent.class)   ==> b
    registry.lookupByNameAndType("log", DefaultComponent.class)  ==> a or b 
(depends on the order)






--
This message was sent by Atlassian Jira
(v8.3.2#803003)

Reply via email to