Results 1 to 3 of 3

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

  1. #1
    Join Date
    May 2007
    Location
    Berlin
    Posts
    44

    Default @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
    software engineering blog: http://www.aldana-online.de

  2. #2
    Join Date
    Mar 2010
    Location
    New York / Bombay
    Posts
    33

    Default

    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.

  3. #3
    Join Date
    Nov 2012
    Posts
    1

    Default

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •