[jboss-cvs] JBossAS SVN: r84458 - in trunk: profileservice/src/main/org/jboss/profileservice/management and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Feb 19 09:21:46 EST 2009


Author: emuckenhuber
Date: 2009-02-19 09:21:46 -0500 (Thu, 19 Feb 2009)
New Revision: 84458

Modified:
   trunk/component-matrix/pom.xml
   trunk/profileservice/src/main/org/jboss/profileservice/management/KernelBusRuntimeComponentDispatcher.java
   trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java
   trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java
Log:
[JBAS-5523] merge changes from 5_x branch to trunk

Modified: trunk/component-matrix/pom.xml
===================================================================
--- trunk/component-matrix/pom.xml	2009-02-19 13:30:27 UTC (rev 84457)
+++ trunk/component-matrix/pom.xml	2009-02-19 14:21:46 UTC (rev 84458)
@@ -61,7 +61,7 @@
     <version.org.jboss.reflect>2.0.2.GA</version.org.jboss.reflect>
     <version.org.jboss.vfs>2.2.0-SNAPSHOT</version.org.jboss.vfs>
     <version.org.jboss.mdr>2.0.1.GA</version.org.jboss.mdr>
-    <version.org.jboss.man>2.0.0.GA</version.org.jboss.man>
+    <version.org.jboss.man>2.1.0.CR1</version.org.jboss.man>
     <version.org.jboss.microcontainer>2.2.0-SNAPSHOT</version.org.jboss.microcontainer>
     <version.org.jboss.cl>2.0.3-SNAPSHOT</version.org.jboss.cl>
     <version.org.jboss.deployers>2.2.0-SNAPSHOT</version.org.jboss.deployers>

Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/KernelBusRuntimeComponentDispatcher.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/KernelBusRuntimeComponentDispatcher.java	2009-02-19 13:30:27 UTC (rev 84457)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/KernelBusRuntimeComponentDispatcher.java	2009-02-19 14:21:46 UTC (rev 84458)
@@ -44,7 +44,6 @@
 {
    private KernelBus bus;
    private Kernel kernel;
-   private String statePropertyName = "state";
 
    @Deprecated
    public KernelBusRuntimeComponentDispatcher(KernelBus bus)
@@ -89,23 +88,10 @@
          throw new IllegalArgumentException("Null kernel bus");
    }
 
-   /**
-    * Set the state property name.
-    *
-    * @param statePropertyName the state property name
-    */
-   public void setStatePropertyName(String statePropertyName)
-   {
-      this.statePropertyName = statePropertyName;
-   }
-
    public MetaValue get(Object componentName, String propertyName)
    {
       try
       {
-         if(propertyName.equals(statePropertyName))
-            return getState(componentName);
-
          return create(bus.get(componentName, propertyName));
       }
       catch (Throwable t)
@@ -144,7 +130,7 @@
     * @param name the bean name
     * @return state enum value
     */
-   protected EnumValue getState(Object name)
+   public String getState(Object name)
    {
       KernelController controller = kernel.getController();
       ControllerContext context = controller.getContext(name, null);
@@ -152,6 +138,6 @@
          throw new IllegalStateException("Context not installed: " + name);
 
       ControllerState state = context.getState();
-      return new EnumValueSupport(ControllerStateMetaType.TYPE, state.getStateString());
+      return state.getStateString();
    }
 }

Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java	2009-02-19 13:30:27 UTC (rev 84457)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java	2009-02-19 14:21:46 UTC (rev 84458)
@@ -60,7 +60,9 @@
 import org.jboss.managed.api.ManagedOperation;
 import org.jboss.managed.api.ManagedParameter;
 import org.jboss.managed.api.ManagedProperty;
+import org.jboss.managed.api.MutableManagedComponent;
 import org.jboss.managed.api.MutableManagedObject;
+import org.jboss.managed.api.RunState;
 import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
 import org.jboss.managed.api.annotation.ManagementComponent;
 import org.jboss.managed.api.annotation.ManagementObject;
@@ -144,6 +146,7 @@
     * matching ManagedObject.
     */
    private Map<String, ManagedObject> runtimeMOs = new HashMap<String, ManagedObject>();
+   private Map<String, String> stateMappings = new HashMap<String, String>();
    /** The dispatcher handles ManagedOperation dispatches */
    private RuntimeComponentDispatcher dispatcher;
    private MetaValueFactory metaValueFactory = MetaValueFactory.getInstance();
@@ -160,6 +163,16 @@
       currentLocale = Locale.getDefault();
       formatter.setLocale(currentLocale);
       i18n = ResourceBundle.getBundle(BUNDLE_NAME, currentLocale);
+      // Set default run state mappings for mc beans/mbeans
+      stateMappings.put("**ERROR**", RunState.FAILED.name());
+      stateMappings.put("Not Installed", RunState.STOPPED.name());
+      stateMappings.put("PreInstall", RunState.STARTING.name());
+      stateMappings.put("Described", RunState.STARTING.name());
+      stateMappings.put("Instantiated", RunState.STARTING.name());
+      stateMappings.put("Configured", RunState.STARTING.name());
+      stateMappings.put("Create", RunState.STARTING.name());
+      stateMappings.put("Start", RunState.STARTING.name());
+      stateMappings.put("Installed", RunState.RUNNING.name());
    }
 
    /**
@@ -360,7 +373,14 @@
             mergeRuntimeMO(parentMO, mo);
             runtimeMOs.remove(key);
          }
-         // There is no further processing of runtime ManagedObjects
+         // Update the runtime state of any ManagedComponent associated with this runtime mo
+         ManagedComponent comp = md.getComponent(mo.getName());
+         if (comp != null)
+         {
+            RunState state = updateRunState(mo, comp);
+            log.debug("Updated component: "+comp+" run state to: "+state);
+         }
+        // There is no further processing of runtime ManagedObjects
          return;
       }
       else
@@ -371,6 +391,13 @@
          {
             mergeRuntimeMO(mo, runtimeMO);
             runtimeMOs.remove(key);
+            // Update the runtime state of any ManagedComponent associated with this runtime mo
+            ManagedComponent comp = md.getComponent(mo.getName());
+            if (comp != null)
+            {
+               RunState state = updateRunState(runtimeMO, comp);
+               log.debug("Updated component: "+comp+" run state to: "+state);
+            }
          }
       }
 
@@ -402,7 +429,7 @@
 
       // Create ManagedComponents for ManagedObjects annotated with ManagementComponent
       ManagementComponent mc = (ManagementComponent) moAnns.get(ManagementComponent.class.getName());
-      if (mc != null)
+      if (mc != null && md.getComponent(mo.getName()) == null)
       {
          ComponentType type = new ComponentType(mc.type(), mc.subtype());
          ManagedComponentImpl comp = new ManagedComponentImpl(type, md, mo);
@@ -415,6 +442,7 @@
             compByCompType.put(type, typeComps);
          }
          typeComps.add(comp);
+         RunState state = updateRunState(null, comp);
       }
 
       // Scan for @ManagementObjectRef
@@ -524,6 +552,31 @@
       return value;
    }
 
+   protected RunState updateRunState(ManagedObject runtimeMO, ManagedComponent comp)
+   {
+      RunState state = comp.getRunState();
+      if (state == RunState.UNKNOWN)
+      {
+         //TODO, update RuntimeComponentDispatcher
+         KernelBusRuntimeComponentDispatcher xdispatcher = (KernelBusRuntimeComponentDispatcher) dispatcher;
+         Object name = comp.getComponentName();
+         if (name == null && runtimeMO != null)
+            name = runtimeMO.getComponentName();
+         if (name != null)
+         {
+            String stateString = xdispatcher.getState(name);
+            String runStateString = stateMappings.get(stateString);
+            state = RunState.valueOf(runStateString);
+            if (comp instanceof MutableManagedComponent)
+            {
+               MutableManagedComponent mcomp = MutableManagedComponent.class.cast(comp);
+               mcomp.setRunState(state);
+            }
+         }
+      }
+      return state;
+   }
+
    /**
     * Process generic value.
     *
@@ -1164,7 +1217,6 @@
 
    /**
     * Merge the runtime props and ops
-    * TODO: need a plugin to access the ManagedObject impl, JBMAN-23
     * @param mo
     * @param runtimeMO
     */
@@ -1173,7 +1225,9 @@
    {
       Map<String, ManagedProperty> runtimeProps = runtimeMO.getProperties();
       Set<ManagedOperation> runtimeOps = runtimeMO.getOperations();
-      log.debug("Merging runtime: "+runtimeMO.getName());
+      // Get the runtime MO component name
+      Object componentName = runtimeMO.getComponentName();
+      log.debug("Merging runtime: "+runtimeMO.getName()+", compnent name: "+componentName);
       Map<String, ManagedProperty> moProps = mo.getProperties();
       Set<ManagedOperation> moOps = mo.getOperations();
       HashMap<String, ManagedProperty> props = new HashMap<String, ManagedProperty>(moProps);
@@ -1181,8 +1235,6 @@
 
       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())
@@ -1209,6 +1261,9 @@
                      }
                   }
                }
+               // Keep the property associated with the runtime MO for invocations/upddates
+               if (prop.getTargetManagedObject() == null)
+                  prop.setTargetManagedObject(runtimeMO);
             }
          }
          props.putAll(runtimeProps);

Modified: trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java	2009-02-19 13:30:27 UTC (rev 84457)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java	2009-02-19 14:21:46 UTC (rev 84458)
@@ -47,6 +47,7 @@
 import org.jboss.managed.api.ManagedObject;
 import org.jboss.managed.api.ManagedOperation;
 import org.jboss.managed.api.ManagedProperty;
+import org.jboss.managed.api.RunState;
 import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
 import org.jboss.managed.api.annotation.ManagementProperty;
 import org.jboss.managed.api.annotation.ViewUse;
@@ -567,6 +568,7 @@
       throws Exception
    {
       ManagementView mgtView = getManagementView();
+      mgtView.reloadProfile();
       ComponentType type = new ComponentType("DataSource", "LocalTx");
       ManagedComponent hsqldb = mgtView.getComponent("DefaultDS", type);
       Map<String,ManagedProperty> props = hsqldb.getProperties();
@@ -597,6 +599,10 @@
             nullStats.add(stat.getName());
       }
       assertTrue("There are no null stats: "+nullStats, nullStats.size() == 0);
+      
+      // Validate the component run state
+      RunState state = hsqldb.getRunState();
+      assertEquals("DefaultDS is running", RunState.RUNNING, state);
    }
 
    /**
@@ -648,6 +654,7 @@
    {
       String jndiName = "TestLocalTxDs";
       Map<String, MetaValue> propValues = new HashMap<String, MetaValue>();
+      propValues.put("track-connection-by-tx", SimpleValueSupport.wrap(Boolean.FALSE));
       addNonXaDsProperties(propValues, jndiName, "jboss-local-jdbc.rar", "javax.sql.DataSource");
       createComponentTest("LocalTxDataSourceTemplate", propValues, "testLocalTxDs",
          KnownComponentTypes.DataSourceTypes.LocalTx.getType(), jndiName);
@@ -888,7 +895,7 @@
       propValues.put("no-tx-separate-pools", SimpleValueSupport.wrap(Boolean.TRUE));
       propValues.put("statistics-formatter", SimpleValueSupport.wrap("org.jboss.resource.statistic.pool.JBossDefaultSubPoolStatisticFormatter"));
       propValues.put("isSameRM-override-value", SimpleValueSupport.wrap(Boolean.FALSE));
-      propValues.put("track-connection-by-tx", SimpleValueSupport.wrap(Boolean.TRUE));
+      propValues.put("track-connection-by-tx", SimpleValueSupport.wrap(Boolean.FALSE));
       propValues.put("type-mapping", SimpleValueSupport.wrap("Hypersonic SQL"));
       // todo: config-property
       // todo: security-domain




More information about the jboss-cvs-commits mailing list