[jboss-dev-forums] [Design of Management Features on JBoss] - Re: How to Expose MBean Invocation Stats into admin-console?
scott.stark@jboss.org
do-not-reply at jboss.com
Sun May 31 10:00:37 EDT 2009
"ALRubinger" wrote : OK, so I've confirmed name collisions w/ the ManagedObject.getName.
|
| ...
|
| Can we change the jboss-deployers behaviour to set the @ManagedObject.name, if not specified, to du.getName + attachmentName?
|
I think the unconditional override of the MO name is too much. Note that the component names are unique as they correspond to the runtime bean names. We can look to default the MO name to the component name if there is no name given on the ManagementObject in the AbstractManagedObjectFactory. The logic would need to be something like this patch:
| Index: /Users/svn/JBossAS/projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/factory/AbstractManagedObjectFactory.java
| ===================================================================
| --- /Users/svn/JBossAS/projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/factory/AbstractManagedObjectFactory.java (revision 89190)
| +++ /Users/svn/JBossAS/projects/jboss-man/branches/Branch_2_1/managed/src/main/java/org/jboss/managed/plugins/factory/AbstractManagedObjectFactory.java (working copy)
| @@ -420,6 +420,14 @@
| MutableManagedObject mmo = (MutableManagedObject) result;
| ManagedObjectPopulator<Object> populator = getPopulator(moClass);
| populator.populateManagedObject(mmo, instance, metaData);
| + // Set a default MO.name to the MO.componentName
| + Boolean hasDefaultName = (Boolean) mmo.getTransientAttachment("ManagedObject.hasDefaultName");
| + Object compName = mmo.getComponentName();
| + if(hasDefaultName && compName != null)
| + {
| + String moName = compName.toString();
| + mmo.setName(moName);
| + }
| }
|
| return result;
| @@ -518,6 +526,7 @@
|
| // Process the ManagementObject fields
| boolean isRuntime = managementObject.isRuntime();
| + boolean hasDefaultName = true;
| String name = classInfo.getName();
| String nameType = null;
| String attachmentName = classInfo.getName();
| @@ -528,8 +537,12 @@
| if (managementObject != null)
| {
| name = managementObject.name();
| + hasDefaultName = false;
| if (name.length() == 0 || name.equals(ManagementConstants.GENERATED))
| + {
| name = classInfo.getName();
| + hasDefaultName = true;
| + }
| nameType = managementObject.type();
| if (nameType.length() == 0)
| nameType = null;
| @@ -862,7 +875,7 @@
| ManagedObjectImpl result = new ManagedObjectImpl(name, properties);
| result.setAnnotations(moAnnotations);
| // Set the component name to name if this is a runtime MO with a name specified
| - if (isRuntime && name.equals(classInfo.getName()) == false)
| + if (isRuntime && hasDefaultName == false)
| result.setComponentName(name);
| if (nameType != null)
| result.setNameType(nameType);
| @@ -873,6 +886,8 @@
| for (ManagedProperty property : properties)
| property.setManagedObject(result);
| result.setTransientAttachment(BeanInfo.class.getName(), beanInfo);
| + // Propagate whether the name is defaulted
| + result.setTransientAttachment("ManagedObject.hasDefaultName", hasDefaultName);
| return result;
| }
|
I just uploaded a jboss-managed and related 2.1.1 snapshot to https://snapshots.jboss.org/maven2/org/jboss/man/jboss-man/2.1.1-SNAPSHOT/ with this change, so can you try that out?
Also, instead of casting to a MangedObjectImpl, use the MutableManagedObject interface when you need to change ManagedObject settings.
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4234323#4234323
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4234323
More information about the jboss-dev-forums
mailing list