[jboss-cvs] JBossAS SVN: r65779 - in trunk/ejb3/src: test/org/jboss/ejb3/test/mdb/unit and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Oct 2 19:45:47 EDT 2007


Author: bdecoste
Date: 2007-10-02 19:45:47 -0400 (Tue, 02 Oct 2007)
New Revision: 65779

Added:
   trunk/ejb3/src/main/org/jboss/ejb3/mdb/MessagingDelegateWrapperMBean.java
   trunk/ejb3/src/test/org/jboss/ejb3/test/mdb/unit/MetricsUnitTestCase.java
Modified:
   trunk/ejb3/src/main/org/jboss/ejb3/mdb/MDB.java
   trunk/ejb3/src/main/org/jboss/ejb3/mdb/MessagingContainer.java
   trunk/ejb3/src/main/org/jboss/ejb3/mdb/MessagingDelegateWrapper.java
Log:
[EJBTHREE-1033] added Messaging metrics

Modified: trunk/ejb3/src/main/org/jboss/ejb3/mdb/MDB.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/mdb/MDB.java	2007-10-02 22:28:23 UTC (rev 65778)
+++ trunk/ejb3/src/main/org/jboss/ejb3/mdb/MDB.java	2007-10-02 23:45:47 UTC (rev 65779)
@@ -28,6 +28,7 @@
 import org.jboss.ejb3.Ejb3Deployment;
 import org.jboss.ejb3.ProxyFactoryHelper;
 import org.jboss.ejb3.interceptor.InterceptorInfoRepository;
+import org.jboss.ejb3.stateful.StatefulDelegateWrapper;
 
 import javax.ejb.ActivationConfigProperty;
 import javax.ejb.MessageDriven;
@@ -48,14 +49,15 @@
  */
 public class MDB extends MessagingContainer 
 {
-   protected Class messagingType = null;
    /**
     * Default destination type. Used when no message-driven-destination is given
     * in ejb-jar, and a lookup of destinationJNDI from jboss.xml is not
     * successfull. Default value: javax.jms.Topic.
     */
    protected final static String DEFAULT_DESTINATION_TYPE = "javax.jms.Topic";
-
+   
+   protected Class messagingType = null;
+   
    public MDB(String ejbName, AspectManager manager, ClassLoader cl, String beanClassName, Hashtable ctxProperties,
               InterceptorInfoRepository interceptorRepository, Ejb3Deployment deployment)
    {

Modified: trunk/ejb3/src/main/org/jboss/ejb3/mdb/MessagingContainer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/mdb/MessagingContainer.java	2007-10-02 22:28:23 UTC (rev 65778)
+++ trunk/ejb3/src/main/org/jboss/ejb3/mdb/MessagingContainer.java	2007-10-02 23:45:47 UTC (rev 65779)
@@ -648,4 +648,32 @@
    {
       return false;
    }
+   
+   public int getMinPoolSize()
+   {
+      return 1;
+   }
+   
+   public int getMaxPoolSize()
+   {
+      return pool.getMaxSize();
+   }
+   
+   public int getMaxMessages()
+   {
+      String maxMessages = activationSpec.get("maxMessages");
+      if (maxMessages != null) 
+         return Integer.parseInt(maxMessages);
+      else
+         return 1;
+   }
+   
+   public int getKeepAliveMillis()
+   {
+      String keepAlive = activationSpec.get("keepAlive");
+      if (keepAlive != null) 
+         return Integer.parseInt(keepAlive);
+      else
+         return 60000;
+   }
 }
\ No newline at end of file

Modified: trunk/ejb3/src/main/org/jboss/ejb3/mdb/MessagingDelegateWrapper.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/mdb/MessagingDelegateWrapper.java	2007-10-02 22:28:23 UTC (rev 65778)
+++ trunk/ejb3/src/main/org/jboss/ejb3/mdb/MessagingDelegateWrapper.java	2007-10-02 23:45:47 UTC (rev 65779)
@@ -30,6 +30,7 @@
  * @version $Revision: $
  */
 public class MessagingDelegateWrapper extends ContainerDelegateWrapper<MessagingContainer>
+   implements MessagingDelegateWrapperMBean
 {
    protected MessagingDelegateWrapper(MessagingContainer delegate)
    {
@@ -38,21 +39,21 @@
 
    public int getMinPoolSize()
    {
-      return -1;
+      return ((MessagingContainer)delegate).getMinPoolSize();
    }
-
+   
    public int getMaxPoolSize()
    {
-      return -1;
+      return ((MessagingContainer)delegate).getMaxPoolSize();
    }
-
+   
    public int getMaxMessages()
    {
-      return -1;
+      return ((MessagingContainer)delegate).getMaxMessages();
    }
-
+   
    public int getKeepAliveMillis()
    {
-      return -1;
+      return ((MessagingContainer)delegate).getKeepAliveMillis();
    }
 }

Added: trunk/ejb3/src/main/org/jboss/ejb3/mdb/MessagingDelegateWrapperMBean.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/mdb/MessagingDelegateWrapperMBean.java	                        (rev 0)
+++ trunk/ejb3/src/main/org/jboss/ejb3/mdb/MessagingDelegateWrapperMBean.java	2007-10-02 23:45:47 UTC (rev 65779)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.ejb3.mdb;
+
+import org.jboss.ejb3.ContainerDelegateWrapperMBean;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public interface MessagingDelegateWrapperMBean extends ContainerDelegateWrapperMBean
+{
+	int getMinPoolSize();
+	
+	int getMaxPoolSize();
+	
+	int getMaxMessages();
+   
+   int getKeepAliveMillis();
+}

Added: trunk/ejb3/src/test/org/jboss/ejb3/test/mdb/unit/MetricsUnitTestCase.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/mdb/unit/MetricsUnitTestCase.java	                        (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/mdb/unit/MetricsUnitTestCase.java	2007-10-02 23:45:47 UTC (rev 65779)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.ejb3.test.mdb.unit;
+
+import javax.management.MBeanServerConnection;
+
+import org.jboss.logging.Logger;
+import org.jboss.test.JBossTestCase;
+import junit.framework.Test;
+
+import javax.management.ObjectName;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public class MetricsUnitTestCase
+extends JBossTestCase
+{
+   private static final Logger log = Logger.getLogger(MetricsUnitTestCase.class);
+
+
+   public MetricsUnitTestCase(String name)
+   {
+      super(name);
+   }
+   
+   public void testJmxMetrics() throws Exception
+   {
+	   MBeanServerConnection server = getServer();
+      
+      int size = 0;
+	      
+      ObjectName testerName = new ObjectName("jboss.j2ee:jar=mdb-test.jar,name=QueueTestMDB,service=EJB3");
+      
+      size = (Integer)server.getAttribute(testerName, "MinPoolSize");
+      assertEquals(1, size);
+      
+      size = (Integer)server.getAttribute(testerName, "MaxPoolSize");
+      assertEquals(1, size);
+      
+      size = (Integer)server.getAttribute(testerName, "MaxMessages");
+      assertEquals(1, size);
+      
+      size = (Integer)server.getAttribute(testerName, "KeepAliveMillis");
+      assertEquals(60000, size);
+      
+      testerName = new ObjectName("jboss.j2ee:jar=mdb-test.jar,name=TransactionQueueTestMDB,service=EJB3");
+      
+      size = (Integer)server.getAttribute(testerName, "MaxPoolSize");
+      assertEquals(1, size);
+      
+      testerName = new ObjectName("jboss.j2ee:jar=mdb-test.jar,name=DefaultedQueueTestMDB,service=EJB3");
+      
+      size = (Integer)server.getAttribute(testerName, "MaxPoolSize");
+      assertEquals(15, size);
+   }
+
+   public static Test suite() throws Exception
+   {
+      return getDeploySetup(MetricsUnitTestCase.class, "mdbtest-service.xml, mdb-test.jar");
+   }
+
+}




More information about the jboss-cvs-commits mailing list