Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between MBean and MXBean

Tags:

java

jmx

mbeans

I have the following questions regarding MBean and MXBean:

  1. What is the difference between MBean and MXBean?
  2. What are the use cases for MBean and MXBean?
like image 756
Denim Datta Avatar asked Apr 29 '13 09:04

Denim Datta


People also ask

What is the difference between bean and beans in XML file?

There is no semantic difference, they mean exactly the same thing. It's just a difference in how their XML namespaces are declared.

What is the difference between @bean and @autowired?

@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).

What is @bean annotation in Spring boot?

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.

What is the difference between declaring a bean with @bean and with @component?

@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.


1 Answers

MXBeans are just a special kind of MBeans. 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

like image 57
Heiko Rupp Avatar answered Oct 14 '22 01:10

Heiko Rupp