Announcement Announcement Module
Collapse
No announcement yet.
@Autowired for lists (what is the order of list) Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • @Autowired for lists (what is the order of list)

    Hi,

    I like the @Autowired approach for list items

    Code:
    @Component
    class Foo{
     
     @Autowired List<MyObject> items;
    
    }
    
    @Component
    class A implements MyObject{}
    
    @Component 
    class B MyObject{}
    I wonder what's the order of the injected items? Does it relate to the order of .jar loadings (i.e. classpath order)? Or maybe the order of the context definition loading resolves to the final order?

    Looking at http://jira.springframework.org/browse/SPR-5574 an expliticly user-defined order is not supported.

    thanks

  • #2
    https://jira.springsource.org/browse/SPR-6253 also seems to support a new feature for user defined ordering.

    I too am curious to know what will decide order in the current situation.

    Comment


    • #3
      You can implement the Ordered interface to re order the List. see an example here http://rdafbn.blogspot.ie/2012/11/ch...ng-spring.html

      Comment

      Working...
      X