snicoll commented on a change in pull request #3: Polish the code as spring's
best practice
URL: https://github.com/apache/rocketmq-spring/pull/3#discussion_r241682654
##########
File path:
rocketmq-spring-boot/src/main/java/org/apache/rocketmq/spring/config/ListenerContainerConfiguration.java
##########
@@ -42,6 +42,7 @@
import java.util.concurrent.atomic.AtomicLong;
+@Configuration
Review comment:
It's not optional. Adding `@Configuration` flags this class as a
configuration class. `@Import` is generic, you could `@Import` a regular class
and it will be exposed as a bean.
Adding `@Configuration` is important as the `ApplicationContext` handles
classes with the `@Configuration` stereotype differently than regular classes.
The most typical example is proxying mode where you pass references around
using method invocation, e.g.
```
@Configuration
public Class MyConfig {
@Bean
public MyBean first() { ... }
public AnotherBean second() {
return new AnotherBean(first());
}
}
```
If you remove `@Configuration` the internal `first()` call in `AnotherBean`
is not going to return the same bean instance as the bean exposed by the
`@Bean` method.
Removing `@Configuration` turns your class in lite mode (which I'd like to
get rid of at some point to be honest).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services