-
Sep 27th, 2012, 04:13 AM
#1
Annotation for injecting array
How do I inject an array via annotations while keeping control over the order? In xml I listed the beans that I wanted in the order that I wanted.
Following this thread on stackoverflow, I've found the following so far:
* using the @Autowired annotation: injects all implementations of the interface;
* using the @Autowired + @Qualifier annotation: injects all implementation of the interface with the same qualifier;
* using the @Resource annotation: spring throws an IllegalStateException.
None give me control over the order. Does the @javax.inject.Inject annotation allow for ordering?
thanks,
Lino
-
Sep 27th, 2012, 02:25 PM
#2
If you are able to determine the order, you probably know what beans are to be injected. You can create a bean of type list in a xml where you enumerate all beans you need (reference the beans by name).
Another option is to write a comparator and use it in the setter method right after the list is injected.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules