[jboss-cvs] JBossAS SVN: r89854 - in branches/JBPAPP_5_0: profileservice/src/resources and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Jun 4 19:19:05 EDT 2009


Author: jason.greene at jboss.com
Date: 2009-06-04 19:19:05 -0400 (Thu, 04 Jun 2009)
New Revision: 89854

Modified:
   branches/JBPAPP_5_0/profileservice/src/main/org/jboss/profileservice/management/ProxyDeploymentInfo.java
   branches/JBPAPP_5_0/profileservice/src/main/org/jboss/profileservice/management/ProxyManagedDeploymentFactory.java
   branches/JBPAPP_5_0/profileservice/src/resources/profileservice-jboss-beans.xml
   branches/JBPAPP_5_0/server/src/main/org/jboss/ejb/ContainerMBean.java
   branches/JBPAPP_5_0/server/src/main/org/jboss/ejb/EntityContainer.java
   branches/JBPAPP_5_0/server/src/main/org/jboss/ejb/MessageDrivenContainer.java
   branches/JBPAPP_5_0/server/src/main/org/jboss/ejb/StatefulSessionContainer.java
   branches/JBPAPP_5_0/server/src/main/org/jboss/ejb/StatelessSessionContainer.java
   branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/profileservice/test/JMXMappingUnitTestCase.java
Log:
Expose bean type in Container MBeans
Add support for filtering MBeans by property key
Add support for MBean attribute driven component types
Map EJBs to the propper component types using this mechanism



Modified: branches/JBPAPP_5_0/profileservice/src/main/org/jboss/profileservice/management/ProxyDeploymentInfo.java
===================================================================
--- branches/JBPAPP_5_0/profileservice/src/main/org/jboss/profileservice/management/ProxyDeploymentInfo.java	2009-06-04 22:57:06 UTC (rev 89853)
+++ branches/JBPAPP_5_0/profileservice/src/main/org/jboss/profileservice/management/ProxyDeploymentInfo.java	2009-06-04 23:19:05 UTC (rev 89854)
@@ -21,7 +21,9 @@
  */
 package org.jboss.profileservice.management;
 
+import java.util.Collections;
 import java.util.Map;
+import java.util.Set;
 
 import javax.management.ObjectName;
 
@@ -31,7 +33,7 @@
 /**
  * Encapsulation of a collection of mbeans that should be exposed as a
  * ManagedDeployment with ManagedComponents.
- * 
+ *
  * @author Scott.Stark at jboss.org
  * @version $Revision$
  */
@@ -48,6 +50,12 @@
    /** A map of attribute name to ComponentType:ComponentSubType for child components of the root component */
    private Map<String, String> componentInfo;
 
+   /** An attribute of the mdb used to build the subtype */
+   private String subtypeAttribute;
+
+   /** Excluded ObjectName keys */
+   private Set<String> excludedKeys = Collections.emptySet();
+
    public String getCompType()
    {
       return compType;
@@ -64,6 +72,26 @@
    {
       this.compSubtype = compSubtype;
    }
+
+   public String getSubtypeAttribute()
+   {
+      return this.subtypeAttribute;
+   }
+
+   public void setSubtypeAttribute(String subtypeAttribute)
+   {
+      this.subtypeAttribute = subtypeAttribute;
+   }
+
+   public Set<String> getExcludedKeys()
+   {
+      return this.excludedKeys;
+   }
+
+   public void setExcludedKeys(Set<String> excludedKeys)
+   {
+      this.excludedKeys = excludedKeys;
+   }
    public ComponentType getType()
    {
       return new ComponentType(compType, compSubtype);
@@ -76,7 +104,7 @@
    {
       this.pattern = pattern;
    }
-   
+
    public MBeanDeploymentNameBuilder getNameBuilder()
    {
       return nameBuilder;

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-04 22:57:06 UTC (rev 89853)
+++ branches/JBPAPP_5_0/profileservice/src/main/org/jboss/profileservice/management/ProxyManagedDeploymentFactory.java	2009-06-04 23:19:05 UTC (rev 89854)
@@ -22,12 +22,17 @@
 package org.jboss.profileservice.management;
 
 import java.util.Collection;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
 
+import javax.management.AttributeNotFoundException;
+import javax.management.InstanceNotFoundException;
+import javax.management.MBeanException;
 import javax.management.MBeanServer;
 import javax.management.ObjectName;
+import javax.management.ReflectionException;
 
 import org.jboss.profileservice.spi.ManagedMBeanDeploymentFactory;
 
@@ -91,6 +96,8 @@
       this.propertyMetaMappings = propertyMappings;
    }
 
+
+
    public Collection<MBeanDeployment> getDeployments(MBeanServer mbeanServer)
    {
       Map<String, MBeanDeployment> tmp = new HashMap<String, MBeanDeployment>();
@@ -104,6 +111,9 @@
       {
          for(ObjectName name : names)
          {
+            if (hasExcludedNameKey(info, name))
+               continue;
+
             String dname = info.getNameBuilder().getName(name, mbeanServer);
             MBeanDeployment deployment = tmp.get(dname);
             if(deployment == null)
@@ -112,7 +122,24 @@
                tmp.put(dname, deployment);
             }
             String compType = info.getCompType();
-            String compSubtype = info.getCompSubtype();
+            String compSubtype = null;
+
+            if (info.getSubtypeAttribute() != null)
+            {
+               try
+               {
+                  compSubtype = (String) mbeanServer.getAttribute(name, info.getSubtypeAttribute());
+               }
+               catch (Exception e)
+               {
+                  // EAT
+               }
+            }
+
+            if (compSubtype == null)
+               compSubtype = info.getCompSubtype();
+
+
             MBeanComponent rootComp = new MBeanComponent(name, compType, compSubtype);
             deployment.addComponent(rootComp);
             Map<String, String> componentInfo = info.getComponentInfo();
@@ -132,7 +159,7 @@
                   }
                   catch(Exception e)
                   {
-                     e.printStackTrace();
+                     // EAT
                   }
                }
             }
@@ -142,6 +169,17 @@
       return tmp.values();
    }
 
+   private boolean hasExcludedNameKey(ProxyDeploymentInfo info, ObjectName name)
+   {
+      Set<String> excludedKeys = info.getExcludedKeys();
+      for (Object key : name.getKeyPropertyList().keySet())
+      {
+         if (excludedKeys.contains(key))
+            return true;
+      }
+
+      return false;
+   }
    /**
     * Generate MBeanComponents for each name given by the attribute value. This
     * processes the attribute value as an array or collection of strings or

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-04 22:57:06 UTC (rev 89853)
+++ branches/JBPAPP_5_0/profileservice/src/resources/profileservice-jboss-beans.xml	2009-06-04 23:19:05 UTC (rev 89854)
@@ -322,9 +322,15 @@
             <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="compType">EJB</property>
+                    <property name="compSubtype">Unknown</property>
+                    <property name="subtypeAttribute">BeanTypeName</property>
                     <property name="pattern">jboss.j2ee:service=EJB,*</property>
+                    <property name="excludedKeys">
+                       <set elementClass="java.lang.String">
+                           <value>plugin</value>
+                       </set>
+                    </property>
                     <property name="nameBuilder">
                         <inject bean="JNDINameKeyMBeanDeploymentNameBuilder"/>
                     </property>

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-04 22:57:06 UTC (rev 89853)
+++ branches/JBPAPP_5_0/server/src/main/org/jboss/ejb/ContainerMBean.java	2009-06-04 23:19:05 UTC (rev 89854)
@@ -39,6 +39,13 @@
    */
   String getDeploymentName();
 
+  /**
+   * Gets the type of bean (Session, Entity, etc)
+   *
+   * @return type of bean
+   */
+  String getBeanTypeName();
+
    /**
     * Gets the number of create invocations that have been made
     */

Modified: branches/JBPAPP_5_0/server/src/main/org/jboss/ejb/EntityContainer.java
===================================================================
--- branches/JBPAPP_5_0/server/src/main/org/jboss/ejb/EntityContainer.java	2009-06-04 22:57:06 UTC (rev 89853)
+++ branches/JBPAPP_5_0/server/src/main/org/jboss/ejb/EntityContainer.java	2009-06-04 23:19:05 UTC (rev 89854)
@@ -115,7 +115,7 @@
     * manage this instance.
     */
    protected static GlobalTxEntityMap globalTxEntityMap = new GlobalTxEntityMap();
-   
+
    public static GlobalTxEntityMap getGlobalTxEntityMap()
    {
       return globalTxEntityMap;
@@ -349,7 +349,7 @@
             EJBProxyFactory ci = (EJBProxyFactory)proxyFactories.get(invokerBinding);
             ci.start();
          }
-         
+
          // Start instance cache
          instanceCache.start();
 
@@ -500,7 +500,7 @@
       if (method != null && method.getName().equals("remove"))
       {
          // Map to EJBHome.remove(Object) to EJBObject.remove()
-         InvocationType type = mi.getType(); 
+         InvocationType type = mi.getType();
          if (type == InvocationType.HOME)
             mi.setType(InvocationType.REMOTE);
          else if (type == InvocationType.LOCALHOME)
@@ -548,7 +548,7 @@
       EntityEnterpriseContext ctx = (EntityEnterpriseContext)mi.getEnterpriseContext();
       getPersistenceManager().removeEntity(ctx);
 
-      final Object pk = ctx.getId(); 
+      final Object pk = ctx.getId();
       AccessController.doPrivileged(new PrivilegedAction<Object>()
       {
          public Object run()
@@ -557,7 +557,7 @@
             return null;
          }
       });
-      
+
       // We signify "removed" with a null id
       // There is no need to synchronize on the context since all the threads reaching here have
       // gone through the InstanceInterceptor so the instance is locked and we only have one thread
@@ -880,6 +880,11 @@
    {
    }
 
+   public String getBeanTypeName()
+   {
+      return "Entity";
+   }
+
    // Private -------------------------------------------------------
 
    private void setupHomeMappingImpl(Method[] m,

Modified: branches/JBPAPP_5_0/server/src/main/org/jboss/ejb/MessageDrivenContainer.java
===================================================================
--- branches/JBPAPP_5_0/server/src/main/org/jboss/ejb/MessageDrivenContainer.java	2009-06-04 22:57:06 UTC (rev 89853)
+++ branches/JBPAPP_5_0/server/src/main/org/jboss/ejb/MessageDrivenContainer.java	2009-06-04 23:19:05 UTC (rev 89854)
@@ -95,6 +95,11 @@
       return instancePool;
    }
 
+   public String getBeanTypeName()
+   {
+      return "MDB";
+   }
+
    public void addInterceptor(Interceptor in)
    {
       if (interceptor == null)
@@ -276,9 +281,9 @@
             EJBProxyFactory ci = (EJBProxyFactory) proxyFactories.get(invokerBinding);
             ci.start();
          }
-         
+
          // Restore persisted ejb timers
-         restoreTimers();         
+         restoreTimers();
       }
       finally
       {

Modified: branches/JBPAPP_5_0/server/src/main/org/jboss/ejb/StatefulSessionContainer.java
===================================================================
--- branches/JBPAPP_5_0/server/src/main/org/jboss/ejb/StatefulSessionContainer.java	2009-06-04 22:57:06 UTC (rev 89853)
+++ branches/JBPAPP_5_0/server/src/main/org/jboss/ejb/StatefulSessionContainer.java	2009-06-04 23:19:05 UTC (rev 89854)
@@ -411,6 +411,11 @@
       throw new Error("Not Yet Implemented");
    }
 
+   public String getBeanTypeName()
+   {
+      return "StatefulSession";
+   }
+
    // Private -------------------------------------------------------
 
    protected void setupHomeMapping() throws Exception

Modified: branches/JBPAPP_5_0/server/src/main/org/jboss/ejb/StatelessSessionContainer.java
===================================================================
--- branches/JBPAPP_5_0/server/src/main/org/jboss/ejb/StatelessSessionContainer.java	2009-06-04 22:57:06 UTC (rev 89853)
+++ branches/JBPAPP_5_0/server/src/main/org/jboss/ejb/StatelessSessionContainer.java	2009-06-04 23:19:05 UTC (rev 89854)
@@ -115,6 +115,11 @@
       throw new UnreachableStatementException();
    }
 
+   public String getBeanTypeName()
+   {
+      return "StatelessSession";
+   }
+
    // Protected  ----------------------------------------------------
 
    protected void setupHomeMapping()

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-04 22:57:06 UTC (rev 89853)
+++ branches/JBPAPP_5_0/testsuite/src/main/org/jboss/test/profileservice/test/JMXMappingUnitTestCase.java	2009-06-04 23:19:05 UTC (rev 89854)
@@ -75,7 +75,7 @@
 
       ManagementView mgtView = getManagementView();
       mgtView.load();
-      Set<ManagedComponent> comps = mgtView.getComponentsForType(new ComponentType("MBean", "EJB"));
+      Set<ManagedComponent> comps = mgtView.getComponentsForType(new ComponentType("EJB", "StatefulSession"));
       for (ManagedComponent comp : comps)
       {
          System.out.println(comp.getName());
@@ -87,8 +87,11 @@
             CompositeValue methodStatsMap = (CompositeValue)((CompositeValue) value).get("methodStats");
             CompositeValue methodStats = (CompositeValue)methodStatsMap.get("count");
             assertEquals(2L, ((SimpleValue)methodStats.get("count")).getValue());
+            return;
          }
       }
+
+      fail("Could not find EJB!");
    }
 
    public void testWebApplicationManager()




More information about the jboss-cvs-commits mailing list