Results 1 to 2 of 2

Thread: Auto-wire a set of beans?

  1. #1

    Default Auto-wire a set of beans?

    Folks;

    not sure how newbie'ish or stupid this question seems, I haven't so far found a straightforward way of doing what I want so I'm back here. Basically, my structure is like this:

    * I do have a given interface, say "IProviderStrategy", which is implemented a couple of times in my application. There is a client class keeping a "Set<IProviderStrategy> strategies", picking the "right" implementation and using it in a given situation.
    * So far, I have a "setStrategies(Set<IProviderStrategy> ...)" setter in the client class, have all the various implementations of IProviderStrategy configured in my applicationContext and wired to the client class via setter injection and value-ref elements.

    As I'd like to get rid of most of the XML configuration cluttering my setup, I'd like to use component-scan to find most of the IProviderStrategy implementations and then, in "some way", tell the application context to put all these implementations together in a Set and @Autowire this into the client class.

    So to ask: Is this possible? Can something like this be done without too much ado, or is this beyond what one would like to do? Is there, as an alternative, a more "Spring" way to do what I want to do?

    TIA, any input greatly appreciated!
    K.

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,695

    Default

    Please read the reference guide as this is explained in the reference guide. Section 4.9.2 explains this exact use case. Also use the search as this question has been answered numerous times before.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Posting Permissions

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