[JBoss-user] [Management, JMX/JBoss] - note on instrumenting a NotificationBroadcaster as an XMBean

2004-04-21 Thread brettcalvin
Just thought I'd share something I'd discovered:

If you have a class that implements the NotificationBroadcaster interface (sends JMX 
notifications) and you instrument it as a ModelMBean using the XMBean approach (by 
providing an XML description of the MBean interface), you must have a public method 
sendNotification(Notification notification) in your class for it to work.

I had a standard MBean that is a NotificationBroadcaster and I converted it to be a 
ModelMBean to take advantage of the persistence mechanism, but then it stopped 
working.  The reason is that my class was no longer the MBean, but was wrapped by the 
XMBean class.  In order for the XMBean to recognize that it needs to forward your 
class all the NotificationBroacaster stuff, it needs to see via reflection that your 
class has that sendNotification method.

From the ModelMBeanInvoker.java class in the v3.2.3 source:

  |   /*
  |   If the managed resource is a NotificationBroadcaster and does have a public 
method
  |   sendNotification on it, set our notifier to it. The sendNotification call
  |   will be invoked through reflection on the resource.
  |   This is currently the only way an xmbean can send notifications.
  |   */
In case someone else comes across the same and is searching for the solution...

Regards,

Brett

View the original post : 
http://www.jboss.org/index.html?module=bbop=viewtopicp=3831841#3831841

Reply to the post : 
http://www.jboss.org/index.html?module=bbop=postingmode=replyp=3831841


---
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470alloc_id=3638op=click
___
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user


[JBoss-user] [Management, JMX/JBoss] - ModelMBeanInfo.getMBeanDescriptor().getFieldValue(

2004-03-29 Thread brettcalvin
Greetings -

I am writing my own persistence manager for my model mbeans.  Obviously, you need some 
sort of unique name to associate with each set of attributes for each MBean.  My 
intent was to use the MBean name, since it is there and already unique.  So, in my 
PersistenceManager.load(ModelMBeanInvoker, MBeanInfo) method, I need a way to get at 
the MBean name.

Based on the sun docs, it looked like the way to get it was from 
ModelMBeanInfo.getMBeanDescriptor().getFieldValue(name)

However, in my method, when I make the calls:

ModelMBeanInfo modelMBeanInfo = (ModelMBeanInfo)mbeanInfo;
  | Descriptor modelMBeanDescriptor = modelMBeanInfo.getMBeanDescriptor();
  | String mbeanName = 
(String)modelMBeanDescriptor.getFieldValue(ModelMBeanConstants.NAME);

mbeanName is set to my model mbean's class name.

Looking through the code (v3.2.3), I see in XMBeanMetaData.java in the build() method, 
line 194 is:

descr.setField(name, mmbClassName);

which leads me to believe it is intentional, and not something I am doing wrong in my 
configuration.

Is this name field supposed to yield the class name?  Am I looking for the ModelMBean 
name in the wrong spot?  Is there an alternate way of obtaining the ModelMBean name (I 
believe the ModelMBean itself is not yet registered, so calls to the MBeanServer to 
find out about it won't work yet.)

For now, I am setting the persistName to the mbean name in the configuration of the 
persistence descriptor, and then pull it from there in the persistence manager, so I 
can accomplish this without having the actual mbean name.  It is one more thing to 
configure for each model mbean, but no biggy; mostly, I am curious.

Thanks much,

Brett

View the original post : 
http://www.jboss.org/index.html?module=bbop=viewtopicp=3827997#3827997

Reply to the post : 
http://www.jboss.org/index.html?module=bbop=postingmode=replyp=3827997


---
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470alloc_id=3638op=click
___
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user