Artem Bilan 4c33e5eb58 GH-1083: Disallow reuse bean name for bindings
Resolves spring-cloud/spring-cloud-stream#1083

By default Spring Framework allows beans overriding via the same name.
The binding target definitions (`@Input` and `@Output`) populate beans as well
and when we use the same name for target we end up with unexpected behavior
but without errors.
Since it isn't so obvious via Spring Framework bean definition DSLs
(XML or Java & Annotations) how to override beans with the same name,
that is absolutely easy to use the same value for `@Input` and `@Output`
definitions even in different binding interfaces.
That's hard to analyze fro the target application since mostly
`@Input` and `@Output` produce `MessageChannel` beans.

* Fail fast with the `BeanDefinitionStoreException` when we meet existing
bean definition for the same name
* Add JavaDocs to the `@Input` and `@Output` to explain that their `value`
is a bean name, as well as destination by default

Since `@EnableBinding` is `@Inherited`, the inheritor picks up it from the
super class during configuration class parsing.
The parsing process logic is such that after the root class we go to parse its
super classes, and therefore come back to the `@EnableBinding` again.
In this case we process all the `@Import`s one more time and collect them to
the root `configurationClass`.
Essentially we get a duplication for the `ImportBeanDefinitionRegistrar`s
such as `BindingBeansRegistrar`.
The last one parsed `@EnableBinding` and registers appropriate beans for the
`@Input` and `@Output`, as well as for the binding interface - `BindableProxyFactory`.
But since we have it twice in the `configurationClass` we end up with
`BeanDefinitionStoreException` mentioned before.
That's how Spring Framework works with inheritance for configuration classes
and that's may be why it allows to override beans by default

* Skip parsing `@EnableBinding` one more time if the bean definition for
binding interface is already present in the `registry`
* Fix `AggregateWithMainTest` do not process `@ComponentScan` what causes
picking up the configuration classes for children contexts in the aggregation
* Fix `testBindableProxyFactoryCaching()` do not register `Source` and `Processor`
in the same application context because both of them cause registration for the
`Source.OUTPUT` bean
2017-09-28 13:41:18 -04:00
2016-06-04 09:14:54 +01:00
2017-05-15 13:03:45 -04:00
2017-03-08 12:45:19 -05:00
2017-09-05 13:38:47 -04:00
2016-02-22 16:30:36 -05:00
2015-05-28 11:20:23 -04:00
2016-09-20 13:48:13 +01:00
2015-08-14 10:08:25 +01:00
2017-09-13 11:04:00 -04:00
2017-06-15 14:15:02 -04:00

== Spring Cloud Stream image:https://badge.waffle.io/spring-cloud/spring-cloud-stream.svg?label=ready&title=Ready[Stories Ready, link=http://waffle.io/spring-cloud/spring-cloud-stream] image:https://badge.waffle.io/spring-cloud/spring-cloud-stream.svg?label=In%20Progress&title=In%20Progress[Stores In Progress, link=http://waffle.io/spring-cloud/spring-cloud-stream] image:https://badges.gitter.im/spring-cloud/spring-cloud-stream.svg[link="https://gitter.im/spring-cloud/spring-cloud-stream?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge"]

This project allows a user to develop and run messaging microservices using Spring Integration and run them locally or in the cloud. Just add `@EnableBinding` and run your app as a Spring Boot app (single application context).

Since version 1.1, Spring Cloud Stream follows a decentralized model where the core components and the binder implementations are developed and released separately.
This repository contains the core components of the project and does not contain any binder implementations.

The repository for the Spring Cloud Stream Release Train is here: https://github.com/spring-cloud/spring-cloud-stream-starters

Information on the Spring Cloud Stream release train can be found here: https://github.com/spring-cloud/spring-cloud-stream-starters/wiki#release-notes.

=== Binder implementations

The following binder implementations are currently available:

* *Kafka*  https://github.com/spring-cloud/spring-cloud-stream-binder-kafka
* *RabbitMQ*  https://github.com/spring-cloud/spring-cloud-stream-binder-rabbit

=== Documentation

The latest documentation for the project can be found http://docs.spring.io/spring-cloud-stream/docs/current-SNAPSHOT/reference/htmlsingle/[here].

=== Samples

For Spring Cloud Stream samples, take a look to the https://github.com/spring-cloud/spring-cloud-stream-samples[samples repository].

=== Question, Bugs and Enhancements

The project team is happy to receive feedback from the community and answer questions.

We use Git Hub issues for tracking bugs and feature requests.
If you would like to report a bug or to suggest a feature, please open a Git Hub issue.

Any question that is not a bug or an issue should be asked on Stack Overflow, using the tag http://stackoverflow.com/questions/tagged/spring-cloud-stream[`spring-cloud-stream`].

=== Contributing

We love contributions.  Follow this https://github.com/spring-cloud/spring-cloud-commons#contributing[link] for more information on how to contribute.

=== Code formatting guidelines

* The directory `eclipse` contains two files that can be used to configure the formatting rules in your IDE: `eclipse-code-formatter.xml` for the majority of the code formatting rules and `eclipse.importorder` to order the import statements.

* In Eclipse you import these files by navigating `Windows -> Preferences` and then the menu items `Preferences > Java > Code Style > Formatter` and `Preferences > Java > Code Style > Organize Imports` respectively.

* In `IntelliJ`, install the plugin `Eclipse Code Formatter`.
You can find it by searching the "Browse Repositories" under the plugin option within `IntelliJ` (Once installed you will need to reboot Intellij for it to take effect).
Then navigate to `Intellij IDEA > Preferences` and select the Eclipse Code Formatter.
Select the `eclipse-code-formatter.xml` file for the field `Eclipse Java Formatter config file` and the file `eclipse.importorder` for the field `Import order`.
Enable the `Eclipse code formatter` by clicking `Use the Eclipse code formatter` then click the *OK* button.
** NOTE: If you configure the `Eclipse Code Formatter` from `File > Other Settings > Default Settings` it will set this policy across all of your Intellij projects.

== Code of Conduct
This project adheres to the Contributor Covenant link:CODE_OF_CONDUCT.adoc[code of conduct]. By participating, you  are expected to uphold this code. Please report unacceptable behavior to spring-code-of-conduct@pivotal.io.
Description
No description provided
Readme Apache-2.0 22 MiB
Languages
Java 96.4%
XSLT 3%
CSS 0.5%