[jboss-cvs] JBossAS SVN: r89743 - in branches/JBPAPP_5_0: profileservice/src/main/org/jboss/profileservice/management/mbean and 6 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Jun 3 11:07:34 EDT 2009
Author: jason.greene at jboss.com
Date: 2009-06-03 11:07:34 -0400 (Wed, 03 Jun 2009)
New Revision: 89743
Added:
branches/JBPAPP_5_0/profileservice/src/main/org/jboss/profileservice/management/mbean/EJBInvocationStatsMapper.java
Modified:
branches/JBPAPP_5_0/profileservice/src/main/org/jboss/profileservice/management/MBeanManagedObjectFactory.java
branches/JBPAPP_5_0/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java
branches/JBPAPP_5_0/profileservice/src/main/org/jboss/profileservice/management/ProxyManagedDeploymentFactory.java
branches/JBPAPP_5_0/profileservice/src/main/org/jboss/profileservice/management/views/MBeanProfileView.java
branches/JBPAPP_5_0/profileservice/src/main/org/jboss/profileservice/spi/ManagedMBeanDeploymentFactory.java
branches/JBPAPP_5_0/profileservice/src/resources/profileservice-jboss-beans.xml
branches/JBPAPP_5_0/server/src/main/org/jboss/ejb/Container.java
branches/JBPAPP_5_0/server/src/main/org/jboss/ejb/ContainerMBean.java
branches/JBPAPP_5_0/server/src/main/org/jboss/invocation/InvocationStatistics.java
branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/profileservice/test/JMXMappingUnitTestCase.java
Log:
Add preliminary support for EJB 1/2 statistics
Add support for custom meta mappers for mbean properties
Add additional stat calls to the Container JMX interface to facilitate detyped use from the PS
Modified: branches/JBPAPP_5_0/profileservice/src/main/org/jboss/profileservice/management/MBeanManagedObjectFactory.java
===================================================================
--- branches/JBPAPP_5_0/profileservice/src/main/org/jboss/profileservice/management/MBeanManagedObjectFactory.java 2009-06-03 15:05:13 UTC (rev 89742)
+++ branches/JBPAPP_5_0/profileservice/src/main/org/jboss/profileservice/management/MBeanManagedObjectFactory.java 2009-06-03 15:07:34 UTC (rev 89743)
@@ -46,8 +46,8 @@
import org.jboss.managed.api.ManagedObject;
import org.jboss.managed.api.ManagedOperation;
import org.jboss.managed.api.ManagedParameter;
+import org.jboss.managed.api.ManagedProperty;
import org.jboss.managed.api.ManagedOperation.Impact;
-import org.jboss.managed.api.ManagedProperty;
import org.jboss.managed.api.annotation.ActivationPolicy;
import org.jboss.managed.api.annotation.DefaultValueBuilderFactory;
import org.jboss.managed.api.annotation.FieldsFactory;
@@ -118,12 +118,12 @@
ClassLoader mbeanLoader, MetaData metaData)
throws Exception
{
- return getManagedObject(mbean, info, mbeanLoader, metaData, null);
+ return getManagedObject(mbean, info, mbeanLoader, metaData, null, null);
}
// FIXME - Hack until metadata mechanism is provided
public ManagedObject getManagedObject(ObjectName mbean, MBeanInfo info,
- ClassLoader mbeanLoader, MetaData metaData, ViewUse[] defaultViewUse)
+ ClassLoader mbeanLoader, MetaData metaData, ViewUse[] defaultViewUse, Map<String, String> propertyMetaMappings)
throws Exception
{
boolean trace = log.isTraceEnabled();
@@ -267,7 +267,7 @@
try
{
type = loadTypeClass(propertyType, mbeanLoader);
- metaType = this.getMetaType(propertyInfo, type, metaData, false, mapperReturn);
+ metaType = this.getMetaType(propertyInfo, type, metaData, false, propertyMetaMappings, mapperReturn);
}
catch(Exception e)
{
@@ -360,13 +360,10 @@
for (MBeanOperationInfo methodInfo : methodInfos)
{
ManagementOperation managementOp = getAnnotation(ManagementOperation.class, methodInfo, metaData);
- if (managementOp == null)
- continue;
-
try
{
- ManagedOperation op = getManagedOperation(methodInfo, managementOp, mbeanLoader, metaData);
- operations.add(op);
+ ManagedOperation op = getManagedOperation(methodInfo, managementOp, mbeanLoader, metaData);
+ operations.add(op);
}
catch(Exception e)
{
@@ -428,7 +425,7 @@
* @return the MetaType for info's type
*/
protected MetaType getMetaType(MBeanFeatureInfo info, Type infoType, MetaData metaData,
- boolean useTypeFactory, MetaMapper[] mapperReturn)
+ boolean useTypeFactory, Map<String, String> propertyMetaMappings, MetaMapper[] mapperReturn)
{
MetaType returnType = null;
// First look for meta mappings
@@ -465,6 +462,24 @@
log.debug("Failed to create MetaMapper: "+metaMapping, e);
}
}
+
+ if (info instanceof MBeanAttributeInfo && propertyMetaMappings != null)
+ {
+ String className = propertyMetaMappings.get(info.getName());
+ if (className != null)
+ {
+ try
+ {
+ // Use the same loader of the profile service
+ metaMapper = (MetaMapper<?>)Class.forName(className).newInstance();
+ }
+ catch (Exception e)
+ {
+ log.debug("Failed to create MetaMapper: " + className + " for property: " + info.getName());
+ }
+ }
+ }
+
if(metaMapper != null)
{
returnType = metaMapper.getMetaType();
@@ -486,7 +501,7 @@
throws Exception
{
String name = methodInfo.getName();
- String description = opAnnotation.description();
+ String description = opAnnotation != null ? opAnnotation.description() : name;
Impact impact = Impact.Unknown;
switch(methodInfo.getImpact())
{
@@ -506,7 +521,7 @@
// The op return type
MetaMapper[] returnTypeMapper = {null};
Class<?> returnTypeClass = loadTypeClass(methodInfo.getReturnType(), mbeanLoader);
- MetaType returnType = getMetaType(methodInfo, returnTypeClass, metaData, true, returnTypeMapper);
+ MetaType returnType = getMetaType(methodInfo, returnTypeClass, metaData, true, null, returnTypeMapper);
// Process the op parameters
ArrayList<ManagedParameter> mparams = new ArrayList<ManagedParameter>();
@@ -527,7 +542,7 @@
fields.setField(Fields.DESCRIPTION, pdescription);
MetaMapper[] paramMapper = {null};
Class<?> paramType = loadTypeClass(pinfo.getType(), mbeanLoader);
- MetaType metaType = getMetaType(pinfo, paramType, metaData, true, paramMapper);
+ MetaType metaType = getMetaType(pinfo, paramType, metaData, true, null, paramMapper);
fields.setField(Fields.META_TYPE, metaType);
Modified: branches/JBPAPP_5_0/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java
===================================================================
--- branches/JBPAPP_5_0/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java 2009-06-03 15:05:13 UTC (rev 89742)
+++ branches/JBPAPP_5_0/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java 2009-06-03 15:07:34 UTC (rev 89743)
@@ -115,8 +115,8 @@
properties = ManagementProperties.EXPLICIT, description = "The ProfileService ManagementView")
public class ManagementViewImpl extends AbstractTemplateCreator implements ManagementView
{
-
+
/** The logger. */
private static Logger log = Logger.getLogger(ManagementViewImpl.class);
private static final String BUNDLE_NAME = "org.jboss.profileservice.management.messages"; //$NON-NLS-1$
@@ -271,11 +271,11 @@
log.debug("Saw MBeanComponent: "+comp);
try
{
- ManagedObject mo = createManagedObject(comp.getName(), mdf.getDefaultViewUse());
-
+ ManagedObject mo = createManagedObject(comp.getName(), mdf.getDefaultViewUse(), mdf.getPropertyMetaMappings());
+
String name = comp.getName().getCanonicalName();
ManagementObject moAnn = createMOAnnotation(name, comp.getType(), comp.getSubtype());
-
+
// Both the ManagementObject and ManagementComponent annotation need to be in the MO annotations
mo.getAnnotations().put(ManagementObject.class.getName(), moAnn);
ManagementComponent mcAnn = moAnn.componentType();
@@ -361,18 +361,18 @@
@SuppressWarnings("all")
private static final class ManagementObjectAnnotationImpl implements ManagementObject, Serializable
- {
+ {
private static final long serialVersionUID=5355799336353299850L;
-
+
private final String name;
private final String type;
private final String subtype;
-
+
@SuppressWarnings("all")
private final class ManagementComponentAnnotationImpl implements ManagementComponent, Serializable
{
private static final long serialVersionUID=5355799336353299850L;
-
+
public String subtype()
{
return subtype;
@@ -451,7 +451,7 @@
return ManagementObject.class;
}
}
-
+
private ManagementObject createMOAnnotation(final String name, final String type, final String subtype)
{
return new ManagementObjectAnnotationImpl(name, type, subtype);
@@ -920,7 +920,7 @@
}
return state;
}
-
+
protected <T extends Enum<?>> T getComponentMappedState(ManagedComponent comp, ManagedObject mo, Object name, ContextStateMapper<T> mapper)
{
T state = mapper.getErrorState();
@@ -935,7 +935,7 @@
{
dispatcher = this.dispatcher;
}
-
+
if (dispatcher != null)
{
state = dispatcher.mapControllerState(name, mapper);
@@ -1717,14 +1717,14 @@
return proxyFactory.createOperationProxies(ops, componentName);
}
- private ManagedObject createManagedObject(ObjectName mbean, String defaultViewUse)
+ private ManagedObject createManagedObject(ObjectName mbean, String defaultViewUse, Map<String, String> propertyMetaMappings)
throws Exception
{
MBeanInfo info = mbeanServer.getMBeanInfo(mbean);
ClassLoader mbeanLoader = mbeanServer.getClassLoaderFor(mbean);
MetaData metaData = null;
ViewUse[] viewUse = defaultViewUse == null ? null : new ViewUse[]{ViewUse.valueOf(defaultViewUse)};
- ManagedObject mo = mbeanMOFactory.getManagedObject(mbean, info, mbeanLoader, metaData, viewUse);
+ ManagedObject mo = mbeanMOFactory.getManagedObject(mbean, info, mbeanLoader, metaData, viewUse, propertyMetaMappings);
return mo;
}
Modified: branches/JBPAPP_5_0/profileservice/src/main/org/jboss/profileservice/management/ProxyManagedDeploymentFactory.java
===================================================================
--- branches/JBPAPP_5_0/profileservice/src/main/org/jboss/profileservice/management/ProxyManagedDeploymentFactory.java 2009-06-03 15:05:13 UTC (rev 89742)
+++ branches/JBPAPP_5_0/profileservice/src/main/org/jboss/profileservice/management/ProxyManagedDeploymentFactory.java 2009-06-03 15:07:34 UTC (rev 89743)
@@ -50,6 +50,9 @@
/** The default view to expose fields as */
private String defaultViewUse;
+ /** The global property to meta-mapper configuration */
+ private Map<String, String> propertyMetaMappings;
+
public String getFactoryName()
{
return factoryName;
@@ -78,7 +81,16 @@
this.defaultViewUse = defaultViewUse;
}
+ public Map<String, String> getPropertyMetaMappings()
+ {
+ return propertyMetaMappings;
+ }
+ public void setPropertyMetaMappings(Map<String, String> propertyMappings)
+ {
+ this.propertyMetaMappings = propertyMappings;
+ }
+
public Collection<MBeanDeployment> getDeployments(MBeanServer mbeanServer)
{
Map<String, MBeanDeployment> tmp = new HashMap<String, MBeanDeployment>();
Added: branches/JBPAPP_5_0/profileservice/src/main/org/jboss/profileservice/management/mbean/EJBInvocationStatsMapper.java
===================================================================
--- branches/JBPAPP_5_0/profileservice/src/main/org/jboss/profileservice/management/mbean/EJBInvocationStatsMapper.java (rev 0)
+++ branches/JBPAPP_5_0/profileservice/src/main/org/jboss/profileservice/management/mbean/EJBInvocationStatsMapper.java 2009-06-03 15:07:34 UTC (rev 89743)
@@ -0,0 +1,145 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.profileservice.management.mbean;
+
+import java.lang.reflect.Type;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.metatype.api.types.CompositeMetaType;
+import org.jboss.metatype.api.types.ImmutableCompositeMetaType;
+import org.jboss.metatype.api.types.MapCompositeMetaType;
+import org.jboss.metatype.api.types.MetaType;
+import org.jboss.metatype.api.types.SimpleMetaType;
+import org.jboss.metatype.api.values.MapCompositeValueSupport;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValueSupport;
+import org.jboss.metatype.spi.values.MetaMapper;
+
+/**
+ * {@link MetaMapper} for detyped EJB invocation statistics.
+ *
+ * @author Jason T. Greene
+ */
+public class EJBInvocationStatsMapper extends MetaMapper<Map<String, Map<String, Long>>>
+{
+ public static final CompositeMetaType TYPE;
+ public static final CompositeMetaType METHOD_STATS_TYPE;
+ private static String[] rootItemNames;
+ private static MapCompositeMetaType METHOD_STATS_MAP_TYPE;
+
+ static
+ {
+ String[] methodItemNames = {
+ "count",
+ "minTime",
+ "maxTime",
+ "totalTime"
+ };
+ String[] methodItemDescriptions = {
+ "the number of invocations",
+ "the minimum invocation time",
+ "the maximum invocation time",
+ "the total invocation time",
+ };
+ MetaType[] methodItemTypes = {
+ SimpleMetaType.LONG,
+ SimpleMetaType.LONG,
+ SimpleMetaType.LONG,
+ SimpleMetaType.LONG,
+ };
+ METHOD_STATS_TYPE = new ImmutableCompositeMetaType("MethodStatistics",
+ "Method invocation statistics",
+ methodItemNames, methodItemDescriptions, methodItemTypes);
+
+ METHOD_STATS_MAP_TYPE = new MapCompositeMetaType(METHOD_STATS_TYPE);
+
+ rootItemNames = new String[] {
+ "concurrentCalls",
+ "maxConcurrentCalls",
+ "lastResetTime",
+ "methodStats"
+ };
+
+ String[] rootItemDescriptions = {
+ "the number of concurrent invocations",
+ "the maximum number of concurrent invocations",
+ "last time statistics were reset",
+ "method statistics",
+ };
+ MetaType[] rootItemTypes = {
+ SimpleMetaType.LONG,
+ SimpleMetaType.LONG,
+ SimpleMetaType.LONG,
+ METHOD_STATS_MAP_TYPE
+ };
+
+ TYPE = new ImmutableCompositeMetaType("InvocationStatistics",
+ "EJB invocation statistics",
+ rootItemNames, rootItemDescriptions, rootItemTypes);
+ }
+
+ @Override
+ public MetaType getMetaType()
+ {
+ return TYPE;
+ }
+
+ @Override
+ public Type mapToType()
+ {
+ return Map.class;
+ }
+
+ @Override
+ public MetaValue createMetaValue(MetaType metaType, Map<String, Map<String, Long>> object)
+ {
+ Map<String, MetaValue> methodMap = new HashMap<String, MetaValue>();
+ for (Map.Entry<String, Map<String, Long>> entry: object.entrySet())
+ {
+ if (entry.getKey().charAt(0) == '#')
+ continue;
+
+ MapCompositeValueSupport cvs = new MapCompositeValueSupport(METHOD_STATS_TYPE);
+ for (String name : METHOD_STATS_TYPE.itemSet())
+ cvs.put(name, SimpleValueSupport.wrap(entry.getValue().get(name)));
+
+ methodMap.put(entry.getKey(), cvs);
+ }
+
+ MapCompositeValueSupport root = new MapCompositeValueSupport(TYPE);
+ for (int i = 0; i < 3; i++)
+ root.put(rootItemNames[i], SimpleValueSupport.wrap(object.get("#Global").get(rootItemNames[i])));
+
+ root.put(rootItemNames[3], new MapCompositeValueSupport(methodMap, METHOD_STATS_MAP_TYPE));
+
+ return root;
+ }
+
+ @Override
+ public Map<String, Map<String, Long>> unwrapMetaValue(MetaValue metaValue)
+ {
+ // This is read-only, so not needed
+ return null;
+ }
+}
Property changes on: branches/JBPAPP_5_0/profileservice/src/main/org/jboss/profileservice/management/mbean/EJBInvocationStatsMapper.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: branches/JBPAPP_5_0/profileservice/src/main/org/jboss/profileservice/management/views/MBeanProfileView.java
===================================================================
--- branches/JBPAPP_5_0/profileservice/src/main/org/jboss/profileservice/management/views/MBeanProfileView.java 2009-06-03 15:05:13 UTC (rev 89742)
+++ branches/JBPAPP_5_0/profileservice/src/main/org/jboss/profileservice/management/views/MBeanProfileView.java 2009-06-03 15:07:34 UTC (rev 89743)
@@ -23,6 +23,7 @@
import java.util.Collection;
import java.util.HashMap;
+import java.util.Map;
import javax.management.MBeanInfo;
import javax.management.MBeanServer;
@@ -119,7 +120,7 @@
log.debug("Saw MBeanComponent: "+comp);
try
{
- ManagedObject mo = createManagedObject(comp.getName(), mdf.getDefaultViewUse());
+ ManagedObject mo = createManagedObject(comp.getName(), mdf.getDefaultViewUse(), mdf.getPropertyMetaMappings());
// Add a ManagementComponent annotation
String annotationExpr = "@org.jboss.managed.api.annotation.ManagementObject("
+ "name=\""+comp.getName()+"\","
@@ -154,13 +155,13 @@
}
}
- private ManagedObject createManagedObject(ObjectName mbean, String defaultViewUse) throws Exception
+ private ManagedObject createManagedObject(ObjectName mbean, String defaultViewUse, Map<String, String> propertyMetaMappings) throws Exception
{
MBeanInfo info = mbeanServer.getMBeanInfo(mbean);
ClassLoader mbeanLoader = mbeanServer.getClassLoaderFor(mbean);
MetaData metaData = null;
ViewUse[] viewUse = defaultViewUse == null ? null : new ViewUse[] { ViewUse.valueOf(defaultViewUse) };
- ManagedObject mo = mbeanMOFactory.getManagedObject(mbean, info, mbeanLoader, metaData, viewUse);
+ ManagedObject mo = mbeanMOFactory.getManagedObject(mbean, info, mbeanLoader, metaData, viewUse, propertyMetaMappings);
return mo;
}
Modified: branches/JBPAPP_5_0/profileservice/src/main/org/jboss/profileservice/spi/ManagedMBeanDeploymentFactory.java
===================================================================
--- branches/JBPAPP_5_0/profileservice/src/main/org/jboss/profileservice/spi/ManagedMBeanDeploymentFactory.java 2009-06-03 15:05:13 UTC (rev 89742)
+++ branches/JBPAPP_5_0/profileservice/src/main/org/jboss/profileservice/spi/ManagedMBeanDeploymentFactory.java 2009-06-03 15:07:34 UTC (rev 89743)
@@ -23,6 +23,7 @@
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Map;
import javax.management.MBeanServer;
import javax.management.ObjectName;
@@ -104,4 +105,5 @@
public String getFactoryName();
public Collection<MBeanDeployment> getDeployments(MBeanServer mbeanServer);
public String getDefaultViewUse();
+ public Map<String, String> getPropertyMetaMappings();
}
Modified: branches/JBPAPP_5_0/profileservice/src/resources/profileservice-jboss-beans.xml
===================================================================
--- branches/JBPAPP_5_0/profileservice/src/resources/profileservice-jboss-beans.xml 2009-06-03 15:05:13 UTC (rev 89742)
+++ branches/JBPAPP_5_0/profileservice/src/resources/profileservice-jboss-beans.xml 2009-06-03 15:07:34 UTC (rev 89743)
@@ -197,6 +197,10 @@
class="org.jboss.profileservice.management.mbean.SimpleMBeanDeploymentNameBuilder">
<property name="keyName">name</property>
</bean>
+ <bean name="JNDINameKeyMBeanDeploymentNameBuilder"
+ class="org.jboss.profileservice.management.mbean.SimpleMBeanDeploymentNameBuilder">
+ <property name="keyName">jndiName</property>
+ </bean>
<bean name="HostMBeanDeploymentNameBuilder"
class="org.jboss.profileservice.management.mbean.SimpleMBeanDeploymentNameBuilder">
<property name="keyName">host</property>
@@ -302,4 +306,30 @@
</set>
</property>
</bean>
+ <bean name="EJBMetricsManagedDeploymentFactory"
+ class="org.jboss.profileservice.management.ProxyManagedDeploymentFactory">
+ <property name="factoryName">EJBMetrics</property>
+ <property name="defaultViewUse">STATISTIC</property>
+ <property name="propertyMetaMappings">
+ <map keyClass="java.lang.String" valueClass="java.lang.String">
+ <entry>
+ <key>DetypedInvocationStatistics</key>
+ <value>org.jboss.profileservice.management.mbean.EJBInvocationStatsMapper</value>
+ </entry>
+ </map>
+ </property>
+ <property name="rootMOPatterns">
+ <set elementClass="org.jboss.profileservice.management.ProxyDeploymentInfo">
+ <!-- Manager -->
+ <bean class="org.jboss.profileservice.management.ProxyDeploymentInfo">
+ <property name="compType">MBean</property>
+ <property name="compSubtype">EJB</property>
+ <property name="pattern">jboss.j2ee:service=EJB,*</property>
+ <property name="nameBuilder">
+ <inject bean="JNDINameKeyMBeanDeploymentNameBuilder"/>
+ </property>
+ </bean>
+ </set>
+ </property>
+ </bean>
</deployment>
Modified: branches/JBPAPP_5_0/server/src/main/org/jboss/ejb/Container.java
===================================================================
--- branches/JBPAPP_5_0/server/src/main/org/jboss/ejb/Container.java 2009-06-03 15:05:13 UTC (rev 89742)
+++ branches/JBPAPP_5_0/server/src/main/org/jboss/ejb/Container.java 2009-06-03 15:07:34 UTC (rev 89743)
@@ -190,7 +190,7 @@
/** SecurityManagement Instance - holder of all security managers */
protected ISecurityManagement securityManagement;
-
+
/** PolicyRegistration - Holds Authorization Policies */
protected PolicyRegistration policyRegistration;
@@ -242,8 +242,8 @@
/** The JACC context id for the container */
protected String jaccContextID;
- /**
- * Flag to denote whether a JACC configuration has been fitted for authorization
+ /**
+ * Flag to denote whether a JACC configuration has been fitted for authorization
*/
protected boolean isJaccEnabled = false;
@@ -290,7 +290,7 @@
/**
* Whether the bean is call by value
- *
+ *
* @return true for call by value
*/
public boolean isCallByValue()
@@ -340,7 +340,7 @@
public void setSecurityManagement(ISecurityManagement securityManagement)
{
this.securityManagement = securityManagement;
- }
+ }
public PolicyRegistration getPolicyRegistration()
{
@@ -414,7 +414,7 @@
// There's no factory thread local which means this is probably
// a local invocation. Just use the first (usually only)
// proxy factory.
- // TODO: define a default factory in the meta data or
+ // TODO: define a default factory in the meta data or
// even better, let the return over the original transport
// plugin the transport layer for the generated proxy
if (factory == null && remoteInterface != null)
@@ -496,9 +496,9 @@
this.timerService = timerService;
}
- /**
- * Get the flag whether JACC is enabled
- * @return
+ /**
+ * Get the flag whether JACC is enabled
+ * @return
*/
public boolean isJaccEnabled()
{
@@ -506,9 +506,9 @@
}
/**
- * Set the flag that JACC is enabled
- *
- * @param isJaccEnabled
+ * Set the flag that JACC is enabled
+ *
+ * @param isJaccEnabled
*/
public void setJaccEnabled(boolean isJaccEnabled)
{
@@ -526,6 +526,14 @@
}
/**
+ * Gets the deployment unit name that contains this container.
+ */
+ public String getDeploymentName()
+ {
+ return ejbModule.name;
+ }
+
+ /**
* Gets the number of create invocations that have been made
* @jmx.managed-attribute
*/
@@ -551,7 +559,29 @@
return invokeStats;
}
+
/**
+ * Converts the method invocation stats into a detyped nested map structure.
+ * The format is:
+ *
+ * {methodName => {statisticTypeName => longValue}}
+ *
+ * @return A map indexed by method name with map values indexed by statistic type
+ */
+ public Map<String, Map<String, Long>> getDetypedInvocationStatistics()
+ {
+ return invokeStats.toDetypedMap();
+ }
+
+ /**
+ * Resets the current invocation stats
+ */
+ public void resetInvocationStats()
+ {
+ invokeStats.resetStats();
+ }
+
+ /**
* Sets the class loader for this container. All the classes and resources
* used by the bean in this container will use this classloader.
*
@@ -663,7 +693,7 @@
}
else if (m.equals(EJB_TIMEOUT))
{
- // No role is required to access the ejbTimeout as this is
+ // No role is required to access the ejbTimeout as this is
permissions = new HashSet<Principal>();
permissions.add(AnybodyPrincipal.ANYBODY_PRINCIPAL);
methodPermissionsCache.put(m, permissions);
@@ -678,7 +708,7 @@
{
for (String role : roles)
permissions.add(new SimplePrincipal(role));
- }
+ }
methodPermissionsCache.put(m, permissions);
}
@@ -965,7 +995,7 @@
public abstract void addInterceptor(Interceptor in);
/** The detached invoker operation.
- *
+ *
* @jmx.managed-operation
*
* @param mi - the method invocation context
@@ -1451,11 +1481,11 @@
if (securityDomain == null)
securityDomain = metaData.getApplicationMetaData().getSecurityDomain();
if (securityDomain != null)
- {
+ {
//JBAS-6060: Tolerate a Security Domain configuration without the java:/jaas prefix
if(securityDomain.startsWith(SecurityConstants.JAAS_CONTEXT_ROOT) == false)
securityDomain = SecurityConstants.JAAS_CONTEXT_ROOT + "/" + securityDomain;
-
+
log.debug("Binding securityDomain: " + securityDomain + " to JDNI ENC as: security/security-domain");
Util.bind(envCtx, "security/security-domain", new LinkRef(securityDomain));
Modified: branches/JBPAPP_5_0/server/src/main/org/jboss/ejb/ContainerMBean.java
===================================================================
--- branches/JBPAPP_5_0/server/src/main/org/jboss/ejb/ContainerMBean.java 2009-06-03 15:05:13 UTC (rev 89742)
+++ branches/JBPAPP_5_0/server/src/main/org/jboss/ejb/ContainerMBean.java 2009-06-03 15:07:34 UTC (rev 89743)
@@ -21,6 +21,8 @@
*/
package org.jboss.ejb;
+import java.util.Map;
+
/**
* MBean interface.
* @see EJBDeployer
@@ -32,6 +34,11 @@
*/
org.jboss.ejb.EjbModule getEjbModule() ;
+ /**
+ * Gets the deployment name of the deployment unit that contains this container.
+ */
+ String getDeploymentName();
+
/**
* Gets the number of create invocations that have been made
*/
@@ -47,6 +54,21 @@
*/
org.jboss.invocation.InvocationStatistics getInvokeStats() ;
+ /**
+ * Converts the method invocation stats into a detyped nested map structure.
+ * The format is:
+ *
+ * {methodName => {statisticTypeName => longValue}}
+ *
+ * @return A map indexed by method name with map values indexed by statistic type
+ */
+ Map<String, Map<String, Long>> getDetypedInvocationStatistics();
+
+ /**
+ * Resets the current invocation stats
+ */
+ void resetInvocationStats();
+
/**
* Get the components environment context
* @return Environment Context */
Modified: branches/JBPAPP_5_0/server/src/main/org/jboss/invocation/InvocationStatistics.java
===================================================================
--- branches/JBPAPP_5_0/server/src/main/org/jboss/invocation/InvocationStatistics.java 2009-06-03 15:05:13 UTC (rev 89742)
+++ branches/JBPAPP_5_0/server/src/main/org/jboss/invocation/InvocationStatistics.java 2009-06-03 15:07:34 UTC (rev 89743)
@@ -41,7 +41,7 @@
private static final long serialVersionUID = -8031193044335393420L;
/** A HashMap<Method, TimeStatistic> of the method invocations */
- private Map methodStats;
+ private Map<Method, TimeStatistic> methodStats;
public long concurrentCalls = 0;
public long maxConcurrentCalls = 0;
@@ -52,7 +52,7 @@
{
/** @since 4.2.0 */
private static final long serialVersionUID = -8689933338506854386L;
-
+
public volatile long count;
public volatile long minTime = Long.MAX_VALUE;
public volatile long maxTime;
@@ -80,7 +80,7 @@
*/
public void updateStats(Method m, long elapsed)
{
- TimeStatistic stat = (TimeStatistic) methodStats.get(m);
+ TimeStatistic stat = methodStats.get(m);
if (stat == null)
{
stat = new TimeStatistic();
@@ -147,11 +147,10 @@
tmp.append(concurrentCalls);
tmp.append("' >\n");
- HashMap copy = new HashMap(methodStats);
- Iterator iter = copy.entrySet().iterator();
+ Iterator<Map.Entry<Method, TimeStatistic>> iter = methodStats.entrySet().iterator();
while (iter.hasNext())
{
- Map.Entry entry = (Map.Entry) iter.next();
+ Map.Entry<Method, TimeStatistic> entry = iter.next();
TimeStatistic stat = (TimeStatistic) entry.getValue();
if (stat != null)
{
@@ -171,4 +170,39 @@
tmp.append("</InvocationStatistics>");
return tmp.toString();
}
+
+ /**
+ * Converts the method invocation stats into a detyped nested map structure.
+ * The format is:
+ *
+ * {methodName => {statisticTypeName => longValue}}
+ *
+ * In addition some other global statistics are added under the fake
+ * method name #Global
+ *
+ * @return A map indexed by method name with map values indexed by statistic type
+ */
+ public Map<String, Map<String, Long>> toDetypedMap()
+ {
+
+ Map<String, Map<String, Long>> detyped = new HashMap<String, Map<String, Long>>();
+ for (Map.Entry<Method, TimeStatistic> entry : methodStats.entrySet())
+ {
+ TimeStatistic stats = entry.getValue();
+ Map<String, Long> detypedStats = new HashMap<String, Long>(methodStats.size());
+ detypedStats.put("count", stats.count);
+ detypedStats.put("minTime", stats.minTime);
+ detypedStats.put("maxTime", stats.maxTime);
+ detypedStats.put("totalTime", stats.totalTime);
+ detyped.put(entry.getKey().getName(), detypedStats);
+ }
+
+ Map<String, Long> global = new HashMap<String, Long>();
+ global.put("concurrentCalls", concurrentCalls);
+ global.put("maxConcurrentCalls", maxConcurrentCalls);
+ global.put("lastResetTime", lastResetTime);
+ detyped.put("#Global", global);
+
+ return detyped;
+ }
}
Modified: branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/profileservice/test/JMXMappingUnitTestCase.java
===================================================================
--- branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/profileservice/test/JMXMappingUnitTestCase.java 2009-06-03 15:05:13 UTC (rev 89742)
+++ branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/profileservice/test/JMXMappingUnitTestCase.java 2009-06-03 15:07:34 UTC (rev 89743)
@@ -22,13 +22,28 @@
package org.jboss.test.profileservice.test;
import java.net.URL;
+import java.util.Collection;
+import java.util.List;
import java.util.Set;
+import javax.rmi.PortableRemoteObject;
+
+import junit.framework.Test;
+
import org.jboss.deployers.spi.management.ManagementView;
import org.jboss.managed.api.ComponentType;
import org.jboss.managed.api.ManagedComponent;
+import org.jboss.managed.api.ManagedOperation;
+import org.jboss.managed.api.ManagedProperty;
import org.jboss.managed.api.RunState;
+import org.jboss.metatype.api.values.CompositeValue;
+import org.jboss.metatype.api.values.MetaValue;
import org.jboss.metatype.api.values.SimpleValue;
+import org.jboss.metatype.api.values.TableValue;
+import org.jboss.test.ejb.proxy.beans.StatefulCounter;
+import org.jboss.test.ejb.proxy.beans.StatefulCounterHome;
+import org.jboss.test.ejb.proxy.beans.HandleRetrievalStatefulSessionInterceptor.RetrievalMethodHandle;
+import org.jboss.test.ejb.proxy.test.ProxyLogicTestCase;
/**
* Tests JMX components exposed outside the MC
@@ -42,6 +57,40 @@
super(name);
}
+ public static Test suite() throws Exception
+ {
+ return getDeploySetup(JMXMappingUnitTestCase.class, "ejbproxy-test.jar");
+ }
+
+ public void testEjbMetrics() throws Exception
+ {
+ getLog().debug(getName());
+
+ Object ref = getInitialContext().lookup("ejb/StatefulCounterEjb");
+ StatefulCounterHome home = (StatefulCounterHome) PortableRemoteObject.narrow(ref, StatefulCounterHome.class);
+ StatefulCounter counter = home.create();
+
+ assertEquals(1, counter.count());
+ assertEquals(2, counter.count());
+
+ ManagementView mgtView = getManagementView();
+ mgtView.load();
+ Set<ManagedComponent> comps = mgtView.getComponentsForType(new ComponentType("MBean", "EJB"));
+ for (ManagedComponent comp : comps)
+ {
+ System.out.println(comp.getName());
+ ManagedProperty property = comp.getProperty("DetypedInvocationStatistics");
+ if ("jboss.j2ee:jndiName=ejb/StatefulCounterEjb,service=EJB".equals(comp.getName()))
+ {
+ MetaValue value = property.getValue();
+ System.out.println("Value = " + value);
+ CompositeValue methodStatsMap = (CompositeValue)((CompositeValue) value).get("methodStats");
+ CompositeValue methodStats = (CompositeValue)methodStatsMap.get("count");
+ assertEquals(2L, ((SimpleValue)methodStats.get("count")).getValue());
+ }
+ }
+ }
+
public void testWebApplicationManager()
throws Exception
{
@@ -118,7 +167,7 @@
fail("Could not find localhost Host");
}
-
+
public void testConnector() throws Exception
{
ManagementView mgtView = getManagementView();
@@ -138,7 +187,7 @@
fail("Could not find connector!");
}
-
+
public void testContextMO() throws Exception
{
ManagementView mgtView = getManagementView();
@@ -155,7 +204,7 @@
fail("Could not find deployment context root!");
}
-
+
public void testRunState() throws Exception
{
ManagementView mgtView = getManagementView();
@@ -171,5 +220,5 @@
fail("Could not find localhost Host");
}
-
+
}
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list