2

I am trying to understand why MBeans are such a big deal in Java while I don't recall any other language have such paradigm or pattern.

So why do the MBeans exist, what problem do they try to solve, and how have the other languages solved that problem? (I would prefer comparisons with Python because I understand that the best)

Gabriel
  • 1,078
  • 1
  • 8
  • 15
  • What research have you done? What documentation have you read? Here's a good place to start: http://docs.oracle.com/javase/tutorial/jmx/ – Gray Aug 14 '13 at 20:38
  • MBeans have everything to do with J2EE as a platform, and relatively little to do with Java as a language. An MBean is to JBoss or WebSphere what an SNMP MIB is to Tivoli network manager, or WMI is to a Windows. This link explains further: http://en.wikipedia.org/wiki/Java_Management_Extensions – paulsm4 Aug 14 '13 at 20:41
  • They are certainly not specific to J2EE @paulsm4. – Gray Aug 14 '13 at 20:45
  • Don't quibble. MBeans are ubiquitous in J2EE app servers; they're nowhere near as common in the rest of the Java ecosystem. The point I was trying to make is that MBeans are more a "Java Platform" thing, and less a "Java Language" thing. If the OP is looking for an analog in Python, I would suggest something like [Net-SNMP](https://net-snmp.svn.sourceforge.net/svnroot/net-snmp/trunk/net-snmp/python/README) or a [WMI binding](http://timgolden.me.uk/python/wmi/). IMHO.. – paulsm4 Aug 14 '13 at 20:53
  • 1
    I wrote an [answer](http://stackoverflow.com/a/17364116/2071828) with an example of MBeans not long ago. Hopefully it will be helpful here. – Boris the Spider Aug 14 '13 at 21:31
  • 1
    @Gabriel: take a look at [PyMX](http://code.google.com/p/pymx/), "a Python analog to Java's JMX". – paulsm4 Aug 14 '13 at 22:04

2 Answers2

2

MBeans in java are a way to do management of your application. Say you want to see how long a method takes to execute, or you want to adjust logger settings, or change configuration properties. The MBean via the MBeanServer allow you to provide hooks into your app to do this. You need to create and then wire up your MBeans, and then register them in an MBean server, which the exposes them for management operations (basically read/write data from/to your mbean). JConsole (comes with the jvm) allows you to remotely or locally connect and execute calls on your mbean. There are also a proliferation of tools that use JMX (New Relic, and other management tools probably use it). They are specific to Java, but other languages may have similar counterparts (I don't have much knowledge outside of Java unfortunately).

Alper Akture
  • 2,445
  • 1
  • 30
  • 44
0

MBeans are not a "design pattern". An MBean is an interface standard that is part of JMX. It means nothing outside of JMX. There would be no direct equivalent in other languages unless JMX defined API bindings in other languages, which it doesn't.

The reason they exist is because it was prudent for JMX to define a common interface standard for dealing with these objects.

The problem they intend to solve is to give a consistent standardized interface that JMX can work with.

There may be APIs with bindings in other languages that have similar functionality to JMX, but they would not use MBeans, they would use whatever is defined in those other APIs.

If you are not using JMX then it would make no sense to use an MBean. In fact, if you are not using JMX, you could argue that even if you called something an "MBean", it conceptually would not be one.

Jason C
  • 38,729
  • 14
  • 126
  • 182