camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Łukasz Dywicki <>
Subject [DISCUSS] Refactoring of Registry/Injector interface
Date Tue, 20 Nov 2012 17:16:38 GMT
Dear all,
During my work on camel-cdi component and cdi itself I realized that beans don't have to be
named. They have qualifiers, which are more generic approach. To put some name on bean user
must use @Named qualifier.

This model doesn't fit very well to current camel registry SPI. For example if component developer
is interested in returning all instances of given type he must name them. Next thing is Injector
stuff, which allows usage of type to create instance. It's overlaps in some places same logic
as most popular integration we have (Spring) uses ApplicationContext in both.
I know that logically Registry and Injector are different ideas, however in 99.9% people use
same Registry and Injector provider. Why we support that then?

The proposal I bring here is following:
interface Registry {
    // named lookups
    lookupByName(String name) : Object
    lookupByNameAndType(String name, Class<T> type) : T

    // typed lookups
    lookupByType(Class<T> type) : T
    lookupByType(Class<T> type, boolean createIfNotFound) : T

    // find calls
    findByTypeWithName(Class<T> type) : Map<String, T>
    findByType(Class<T> type) : Set<T>

I reviewed usage of current lookupByType which returns map and in most places key from returned
map is not used at all.
Łukasz Dywicki
Twitter: ldywicki
Code-House -
View raw message