I started with a Spring Java configuration that looks like this:
1 2 3 4 5 6 | |
Basically Collection<RelatedService> is telling Spring to look for all beans matching the type of RelatedService and put them in a Collection for me to use in myService().
Then I wanted to make relatedServices an optional dependency. Ideally, I would like to be able to do something like this:
1 2 3 4 5 6 7 | |
However, @Autowired cannot annotate a parameter. This is what I end up doing.
1 2 3 4 5 6 7 8 9 | |
I would prefer to limit the visibility/scope of relatedServices within the method but it does not look possible.