[jboss-dev-forums] [Design of Management Features on JBoss] - Re: How to Expose MBean Invocation Stats into admin-console?
ALRubinger
do-not-reply at jboss.com
Sat May 30 15:57:24 EDT 2009
OK, so I've confirmed name collisions w/ the ManagedObject.getName. If not specified via @ManagedObject.name, the default behaviour is:
name = managementObject.name();
| if (name.length() == 0 || name.equals(ManagementConstants.GENERATED))
| name = classInfo.getName();
...from AbstractManagedObjectFactory.buildManagedObject. If I apply the following patch, I get what I'm expecting:
Index: deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/helpers/DefaultManagedObjectCreator.java
| ===================================================================
| --- deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/helpers/DefaultManagedObjectCreator.java (revision 89514)
| +++ deployers-spi/src/main/java/org/jboss/deployers/spi/deployer/helpers/DefaultManagedObjectCreator.java (working copy)
| @@ -21,6 +21,7 @@
| */
| package org.jboss.deployers.spi.deployer.helpers;
|
| +import java.util.Collection;
| import java.util.Map;
| import java.util.Set;
|
| @@ -29,6 +30,7 @@
| import org.jboss.deployers.structure.spi.DeploymentUnit;
| import org.jboss.managed.api.ManagedObject;
| import org.jboss.managed.api.factory.ManagedObjectFactory;
| +import org.jboss.managed.plugins.ManagedObjectImpl;
| import org.jboss.managed.plugins.factory.ManagedObjectFactoryBuilder;
| import org.jboss.metadata.spi.MetaData;
|
| @@ -73,14 +75,20 @@
| if(factory == null )
| factory = ManagedObjectFactoryBuilder.create();
|
| - for(String name : attachments)
| + final Map<String,Object> duAttachments = unit.getAttachments();
| + final Collection<String> attachmentNames = duAttachments.keySet();
| + for(final String attachmentName:attachmentNames)
| {
| - Object instance = unit.getAttachment(name);
| + Object instance = unit.getAttachment(attachmentName);
| if (instance != null)
| {
| - ManagedObject mo = factory.initManagedObject(instance, null, metaData, name, null);
| - if (mo != null)
| + ManagedObject mo = factory.initManagedObject(instance, null, metaData, attachmentName, null);
| + factory.initManagedObject(instance, metaData);
| + if (mo != null){
| + ManagedObjectImpl impl = (ManagedObjectImpl) mo;
| + impl.setName(unit.getName() + "-" + attachmentName);
| managedObjects.put(mo.getName(), mo);
| + }
| }
| }
| }
Revealing, for instance:
ManagedDeployment: vfsfile:/home/alrubinger/business/jboss/wc/jbossas/branches/Branch_5_x/build/output/jboss-5.2.0.Beta/server/default/deploy/profileservice-secured.jar/
| +++ ManagedComponent(name=vfsfile:/home/alrubinger/business/jboss/wc/jbossas/branches/Branch_5_x/build/output/jboss-5.2.0.Beta/server/default/deploy/profileservice-secured.jar/-jboss.j2ee:service=EJB3,name=SecureDeploymentManager-metrics-invocation, type=(ComponentType{type=MCBean, subtype=*}), compName=jboss.j2ee:service=EJB3,name=SecureDeploymentManager-metrics-invocation, attachment: org.jboss.ejb3.metrics.deployer.ManagedInvocationStatisticsWrapper
| ++++++ properties: [stats]
| +++ ManagedComponent(name=vfsfile:/home/alrubinger/business/jboss/wc/jbossas/branches/Branch_5_x/build/output/jboss-5.2.0.Beta/server/default/deploy/profileservice-secured.jar/-jboss.j2ee:service=EJB3,name=SecureManagementView-metrics-instance, type=(ComponentType{type=MCBean, subtype=*}), compName=jboss.j2ee:service=EJB3,name=SecureManagementView-metrics-instance, attachment: org.jboss.ejb3.metrics.deployer.BasicStatelessSessionInstanceMetrics
| ++++++ properties: [removeCount, currentSize, maxSize, createCount, availableCount]
| +++ ManagedComponent(name=vfsfile:/home/alrubinger/business/jboss/wc/jbossas/branches/Branch_5_x/build/output/jboss-5.2.0.Beta/server/default/deploy/profileservice-secured.jar/-jboss.j2ee:service=EJB3,name=SecureDeploymentManager-metrics-instance, type=(ComponentType{type=MCBean, subtype=*}), compName=jboss.j2ee:service=EJB3,name=SecureDeploymentManager-metrics-instance, attachment: org.jboss.ejb3.metrics.deployer.BasicStatelessSessionInstanceMetrics
| ++++++ properties: [removeCount, currentSize, maxSize, createCount, availableCount]
| +++ ManagedComponent(name=vfsfile:/home/alrubinger/business/jboss/wc/jbossas/branches/Branch_5_x/build/output/jboss-5.2.0.Beta/server/default/deploy/profileservice-secured.jar/-jboss.j2ee:service=EJB3,name=SecureProfileService-metrics-instance, type=(ComponentType{type=MCBean, subtype=*}), compName=jboss.j2ee:service=EJB3,name=SecureProfileService-metrics-instance, attachment: org.jboss.ejb3.metrics.deployer.BasicStatelessSessionInstanceMetrics
| ++++++ properties: [removeCount, currentSize, maxSize, createCount, availableCount]
| +++ ManagedComponent(name=vfsfile:/home/alrubinger/business/jboss/wc/jbossas/branches/Branch_5_x/build/output/jboss-5.2.0.Beta/server/default/deploy/profileservice-secured.jar/-jboss.j2ee:service=EJB3,name=SecureProfileService-metrics-invocation, type=(ComponentType{type=MCBean, subtype=*}), compName=jboss.j2ee:service=EJB3,name=SecureProfileService-metrics-invocation, attachment: org.jboss.ejb3.metrics.deployer.ManagedInvocationStatisticsWrapper
| ++++++ properties: [stats]
| +++ ManagedComponent(name=vfsfile:/home/alrubinger/business/jboss/wc/jbossas/branches/Branch_5_x/build/output/jboss-5.2.0.Beta/server/default/deploy/profileservice-secured.jar/-jboss.j2ee:service=EJB3,name=SecureManagementView-metrics-invocation, type=(ComponentType{type=MCBean, subtype=*}), compName=jboss.j2ee:service=EJB3,name=SecureManagementView-metrics-invocation, attachment: org.jboss.ejb3.metrics.deployer.ManagedInvocationStatisticsWrapper
| ++++++ properties: [stats]
BTW my deployer is:
http://anonsvn.jboss.org/repos/jbossas/projects/ejb3/trunk/metrics-deployer/src/main/java/org/jboss/ejb3/metrics/deployer/Ejb3MetricsDeployer.java
Can we change the jboss-deployers behaviour to set the @ManagedObject.name, if not specified, to du.getName + attachmentName?
S,
ALR
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4234288#4234288
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4234288
More information about the jboss-dev-forums
mailing list