If you use an annotation-based configuration, and you specify a list of objects with the same interface as the dependency for any class, then spring will automatically scroll the wire automatically. Example:
interface StageInterface { //... } class StageImpl1 implements StageInterface { //... } class StageImpl2 implements StageInterface { //... } @Component class StageContainer { private final List<StageInterface> stages; @Autowired public StageContainer(List<StageInterface> stages) { this.stages = stages; } public List<StageInterface> getStages() { return stages; } }
This is spring version 3+.
I believe the same is possible with xml customization. In your case, it will probably be the same class (StageClass), but with different configuration options.
source share