[jboss-cvs] JBossAS SVN: r70191 - in trunk: testsuite/src/main/org/jboss/test/profileservice/test and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Feb 27 14:02:46 EST 2008
Author: scott.stark at jboss.org
Date: 2008-02-27 14:02:46 -0500 (Wed, 27 Feb 2008)
New Revision: 70191
Modified:
trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java
trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java
Log:
JBAS-5247, JBAS-5248 fix null DefaultDS stat values and multiple ManagedComponents
Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java 2008-02-27 18:44:04 UTC (rev 70190)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java 2008-02-27 19:02:46 UTC (rev 70191)
@@ -62,6 +62,8 @@
import org.jboss.managed.api.annotation.ManagementObject;
import org.jboss.managed.api.annotation.ManagementObjectID;
import org.jboss.managed.api.annotation.ManagementObjectRef;
+import org.jboss.managed.api.annotation.ManagementProperty;
+import org.jboss.managed.api.annotation.ViewUse;
import org.jboss.managed.plugins.ManagedComponentImpl;
import org.jboss.managed.plugins.ManagedObjectImpl;
import org.jboss.managed.plugins.factory.AbstractManagedObjectFactory;
@@ -134,7 +136,7 @@
private Map<String, ManagedObject> runtimeMOs = new HashMap<String, ManagedObject>();
/** runtimeMOs that have not been merged */
private Set<String> unmergedRuntimeMOs = new HashSet<String>();
- /** The dispatcher */
+ /** The dispatcher handles ManagedOperation dispatches */
private RuntimeComponentDispatcher dispatcher;
public ManagementViewImpl()
@@ -275,6 +277,7 @@
{
// This should only matter for ManagedObjects that have a ManagementObjectID
log.debug("Duplicate mo for key: "+key+", prevMO: "+prevMO);
+ return;
}
// Check for unresolved refs
checkForReferences(key, mo);
@@ -926,7 +929,36 @@
if (runtimeProps != null && runtimeProps.size() > 0)
{
+ // Get the runtime MO component name
+ Object componentName = runtimeMO.getComponentName();
log.debug("Properties before:"+props);
+ // We need to pull the runtime values for stats
+ for(ManagedProperty prop : runtimeProps.values())
+ {
+ Map<String, Annotation> pannotations = prop.getAnnotations();
+ if(pannotations != null)
+ {
+ ManagementProperty mpa = (ManagementProperty) pannotations.get(ManagementProperty.class.getName());
+ ViewUse[] uses = mpa.use();
+ for(ViewUse use : uses)
+ {
+ if(use == ViewUse.STATISTIC)
+ {
+ String propName = prop.getMappedName();
+ try
+ {
+ MetaValue propValue = dispatcher.get(componentName, propName);
+ if(propValue != null)
+ prop.setValue(propValue);
+ }
+ catch(Throwable t)
+ {
+ log.debug("Failed to get stat value, "+componentName+":"+propName);
+ }
+ }
+ }
+ }
+ }
props.putAll(runtimeProps);
log.debug("Properties after:"+props);
}
@@ -951,7 +983,8 @@
* @param mo the managed object
* @param ops the managed operations
* @return set of wrapped managed operations
- * @throws Exception for any errot
+ * @throws Exception for any error
+ * @see #
*/
protected Set<ManagedOperation> createOperationProxies(ManagedObject mo, Set<ManagedOperation> ops)
throws Exception
@@ -970,6 +1003,7 @@
Class[] ifaces = {ManagedOperation.class};
for (ManagedOperation op : ops)
{
+ // This is just a unique name registered with the dispatcher and remoting layers
String dispatchName = "ProfileService.ManagedOperation@"+System.identityHashCode(op);
Dispatcher.singleton.registerTarget(dispatchName, new ManagedOperationDelegate(op, mo));
ManagedOperation opProxy = (ManagedOperation) Remoting.createRemoteProxy(dispatchName,
Modified: trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java 2008-02-27 18:44:04 UTC (rev 70190)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java 2008-02-27 19:02:46 UTC (rev 70191)
@@ -361,7 +361,30 @@
Map<String,ManagedProperty> props = dsInfo.getProperties();
validatePropertyMetaValues(props);
}
+
/**
+ * Validate that there is only 1 DefaultDS ManagedComponent
+ * @throws Exception
+ */
+ public void testDefaultDSComponentCount()
+ throws Exception
+ {
+ ManagementView mgtView = getManagementView();
+ ComponentType type = new ComponentType("DataSource", "LocalTx");
+ Set<ManagedComponent> comps = mgtView.getComponentsForType(type);
+ int count = 0;
+ for (ManagedComponent comp : comps)
+ {
+ String cname = comp.getName();
+ if( cname.endsWith("DefaultDS") )
+ {
+ count ++;
+ }
+ }
+ assertEquals("There is 1 DefaultDS ManagedComponent", 1, 1);
+ }
+
+ /**
* Validate that all ManagedPropertys are values are of type MetaValue
* @throws Exception
*/
@@ -375,6 +398,11 @@
validatePropertyMetaValues(props);
}
+ /**
+ * Validate the DefaultDS stats that are non-null
+ *
+ * @throws Exception
+ */
public void testDefaultDSStats()
throws Exception
{
@@ -394,7 +422,7 @@
{
if(use == ViewUse.STATISTIC)
{
- log.info("STATISTIC: "+prop);
+ log.info("STATISTIC: "+prop+", value: "+prop.getValue());
stats.add(prop);
}
}
More information about the jboss-cvs-commits
mailing list