I have the following questions regarding MBean and MXBean:
There is no semantic difference, they mean exactly the same thing. It's just a difference in how their XML namespaces are declared.
@Bean is just for the metadata definition to create the bean(equivalent to tag). @Autowired is to inject the dependancy into a bean(equivalent to ref XML tag/attribute).
Spring @Bean Annotation is applied on a method to specify that it returns a bean to be managed by Spring context. Spring Bean annotation is usually declared in Configuration classes methods. In this case, bean methods may reference other @Bean methods in the same class by calling them directly.
@Component is a class-level annotation, but @Bean is at the method level, so @Component is only an option when a class's source code is editable. @Bean can always be used, but it's more verbose. @Component is compatible with Spring's auto-detection, but @Bean requires manual class instantiation.
MXBean
s are just a special kind of MBean
s. The main difference is that MXBean
restrict the data types, so that they are "more compatible" with potential clients.
As example: a MBean
can expose attributes of a data type Foo
. Now the client also needs to have this type Foo
to make sense of the attribute.
The MXBean
tries to restrict the data types to those "already available" - java.lang.*
etc.
See this tutorial
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With