• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

JMX: registerMBean  RSS feed

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm having troubles with JMX. In the code below, you see how I register an MBean.
The problem is, that from everywhere in my application, I call this particular code, and I give as return-value my oltbMBean. I have the feeling, that I'm working with different MBeans, each time I call the code below. The result is, that my values have the initial value...



I suppose you only have to register, a specific MBean, just one time. Is it possible to find the 'registered' MBean?
I know I'm missing something, but I don't know what...


Can anyone help me? It's very urgent...

Thanks in advance,
Ann Carpentier
 
author
Posts: 23832
140
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

The problem is, that from everywhere in my application, I call this particular code, and I give as return-value my oltbMBean. I have the feeling, that I'm working with different MBeans, each time I call the code below. The result is, that my values have the initial value...



Yes, this code will create a new instance and register it with the MBean Server. So, if you call the code again, you will get a new MBean registered.

I suppose you only have to register, a specific MBean, just one time. Is it possible to find the 'registered' MBean?
I know I'm missing something, but I don't know what...



More commonly, the registerMBean() method is not available -- since most of the time, application work through a connector, instead of the MBean server directly. The reason that you can is because you are running in the same JVM as the MBean server. This trick will not work if you are connecting with JNDI via a different JVM.

Anyway, since you are in the same JVM, just register it once, and store the MBean somewhere in a globally accessable reference. The next time you need the MBean, just return the previously instantiated reference.

Henry
 
Ranch Hand
Posts: 290
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can someone tell me what is the Java Managment Extension(JMX)?and wh its use?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!