Skip to content

Update relevant auto-configurations to ConditionalOnSingleCandidate #2784

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
snicoll opened this issue Apr 7, 2015 · 4 comments
Closed

Update relevant auto-configurations to ConditionalOnSingleCandidate #2784

snicoll opened this issue Apr 7, 2015 · 4 comments
Assignees
Labels
type: enhancement A general enhancement
Milestone

Comments

@snicoll
Copy link
Member

snicoll commented Apr 7, 2015

Now that we have a special support for "single candidate" in #1702 we should review our auto-config infrastructure and update conditions accordingly. Anything that configures some sort of template is directly targeted at this.

@snicoll snicoll added the type: enhancement A general enhancement label Apr 7, 2015
@snicoll snicoll added this to the 1.3.0 milestone Apr 7, 2015
@snicoll snicoll self-assigned this May 18, 2015
@snicoll
Copy link
Member Author

snicoll commented Jul 17, 2015

It's a bit more complicated than I thought since we need to isolate such code in separate @Configuration and order them in such a way that the bean it's checking is already created. The Rabbit/JMS configuration is significantly harder to write unless we move the template config to a separate auto-configuration. Thoughts?

@philwebb philwebb modified the milestones: 1.3.0.M3, 1.3.0.RC1 Aug 5, 2015
@snicoll snicoll removed this from the 1.3.0.M5 milestone Aug 26, 2015
@snicoll snicoll added the status: declined A suggestion or change that we don't feel we should currently apply label Aug 26, 2015
@snicoll snicoll closed this as completed Aug 26, 2015
@snicoll snicoll reopened this Dec 9, 2015
@snicoll snicoll added team-meeting and removed status: declined A suggestion or change that we don't feel we should currently apply labels Dec 9, 2015
@snicoll
Copy link
Member Author

snicoll commented Dec 9, 2015

We really should find a way to make this work. This would allow boot to back off when several instance of a given type is defined rather than blowing up like it does currently. #4678 is another occurrence of this problem.

@philwebb
Copy link
Member

philwebb commented Jan 7, 2016

Let's talk to @jhoeller about this to see if we can extend the core container support. What we want is a way to plugin strategies to use when multiple candidates are found. Something like

@Bean
@ConflictResolver(MyResolver.class)
public MyBean(MyDep dep) {
}

// ...

public class MyResolver implements ExtendedAutowireCandidateResolver {

    Dunno resolve(List<SomeContext> candidates) {
       /// ...
    }

}

i.e. Similar to the @Condition annotation, the @ConflictResolver creates a resolver instance and is provided with information (including class meta-data). In Boot we would mark auto-configured beans that we create so that we know that is the one to inject.

@snicoll
Copy link
Member Author

snicoll commented Jan 20, 2016

I have been discussing this with @jhoeller today and he gave me a few advices to tune the way the configuration can be architectured. This is WIP but the current tests pass for JMS and AMQP using @ConditionalOnSingleCandidate, see snicoll@dd281b0

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants