1 Reply Latest reply on Mar 30, 2004 1:21 PM by Scott Stark


    brettcalvin Newbie

      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,