Skip to content

Autowiring should support ordered collection driven by Order annotation or Ordered interface [SPR-5574] #10245

Closed
@spring-projects-issues

Description

@spring-projects-issues

Roman Pichlík opened SPR-5574 and commented

Let suppose that there are beans of a given type T and these beans are marked by interface Ordered or annotation Order. It does make really sense to preserve their order according to Ordered/Order marker if they are collected. See following code for illustration.

@Component
@Order(value=1)
public class BusinessServiceA implements BusinessService{}

@Component
@Order(value=2)
public class BusinessServiceB implements BusinessService{}

@Component
public class ServiceRegistry {
@Autowired
public List<BusinessService> services;
}

assertThat(services.get(0).getClass(), is(BusinessServiceA.class));
assertThat(services.get(1).getClass(), is(BusinessServiceB.class));


Issue Links:

Referenced from: commits 4a9af23

15 votes, 15 watchers

Metadata

Metadata

Assignees

Labels

has: votes-jiraIssues migrated from JIRA with more than 10 votes at the time of importin: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions