Make it possible to detect the difference between 0 instance candidates or >1 instance candidates from Instantiator.
See original GitHub issueWhen Instantiator
is used in Spring or CDI with an abstract target type, then an instance will be returned if there’s exactly one available bean type that implements that type. This is used in Collaboration Engine to allow the application developer to publish custom configuration for Collaboration Engine as a bean, without including any code in Collaboration Engine that would directly depend on Spring or CDI.
Since the configuration type itself is abstract, Instantiator.getOrCreate
will fail if no bean is available (or if not using a DI container) or if there are multiple candidate beans. We would like to see the difference between those two cases: no bean probably means that the developer isn’t even trying to define configuration as a bean and should thus not be reported as a problem whereas the presence of multiple candidate beans is most likely a mistake in the application and it would be very useful if Collaboration Engine could let the developer know which beans are causing the conflict.
I can see two different ways of implementing this:
getOrCreate
could be enhanced to use a custom exception type that explicitly gives information to this kind of information- Introduce a new method in
Instantiator
that is designed specifically for this purpose. The method could return a collection of candidates where each candidate would have some kind of identifier (String and/or Class) as well as a callback to actually create a specific instance.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6 (6 by maintainers)
Closing as a duplicate of #9756 as we’re not going to likely do much specifically for instantiators anymore just for Flow 2.x and this is not a blocker but an improvement for collaboration engine.
This tickets targets all the Vaadin versions that we want Collaboration Engine to support, i.e. the latest Vaadin 14 and the latest non-LTS release train.