[jboss-cvs] JBossAS SVN: r63914 - in branches/Branch_4_2/ejb3/src: main/org/jboss/ejb3/mdb and 4 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Jul 9 14:42:47 EDT 2007


Author: bdecoste
Date: 2007-07-09 14:42:46 -0400 (Mon, 09 Jul 2007)
New Revision: 63914

Added:
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/mdb/MismatchedQueueMDB.java
Modified:
   branches/Branch_4_2/ejb3/src/main/org/jboss/annotation/ejb/PoolClass.java
   branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/mdb/MDB.java
   branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/mdb/MessagingContainer.java
   branches/Branch_4_2/ejb3/src/resources/test/mdb/mdbtest-service.xml
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/jca/inflowmdb/JMSMDBBean.java
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/mdb/OverrideTestMDB.java
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/mdb/QueueTestMDB.java
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/mdb/TestStatus.java
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/mdb/TestStatusBean.java
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/mdb/TransactionQueueTestMDB.java
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/mdb/unit/MDBUnitTestCase.java
Log:
[EJBTHREE-1003] @PoolClass for MDBs

Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/annotation/ejb/PoolClass.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/annotation/ejb/PoolClass.java	2007-07-09 18:00:04 UTC (rev 63913)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/annotation/ejb/PoolClass.java	2007-07-09 18:42:46 UTC (rev 63914)
@@ -29,9 +29,7 @@
 import org.jboss.ejb3.Pool;
 
 /**
- * Annotation for specifying the pool class to manage thread pooling for a stateless session
- * bean. To control the pool size of an MDB, use the "minSession" and "maxSession" 
- * ActivationConfigProperty
+ * Annotation for specifying the pool class to manage thread pooling 
  *
  * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
  * @version $Revision$

Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/mdb/MDB.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/mdb/MDB.java	2007-07-09 18:00:04 UTC (rev 63913)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/mdb/MDB.java	2007-07-09 18:42:46 UTC (rev 63914)
@@ -160,20 +160,12 @@
    
    public int getMinPoolSize()
    {
-      String minSession = activationSpec.get("minSession");
-      if (minSession != null) 
-         return Integer.parseInt(minSession);
-      else
-         return 1;
+      return 1;
    }
    
    public int getMaxPoolSize()
    {
-      String maxSession = activationSpec.get("maxSession");
-      if (maxSession != null) 
-         return Integer.parseInt(maxSession);
-      else
-         return 15;
+      return pool.getMaxSize();
    }
    
    public int getMaxMessages()

Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/mdb/MessagingContainer.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/mdb/MessagingContainer.java	2007-07-09 18:00:04 UTC (rev 63913)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/mdb/MessagingContainer.java	2007-07-09 18:42:46 UTC (rev 63914)
@@ -307,12 +307,6 @@
    protected void initializePool() throws Exception
    {
      super.initializePool();
-     
-     String maxSession = getMaxSession();
-     if (maxSession != null)
-     {
-        pool.setMaxSize(Integer.parseInt(maxSession));
-     }
    }
    
    protected String getProviderAdapterJNDI()

Modified: branches/Branch_4_2/ejb3/src/resources/test/mdb/mdbtest-service.xml
===================================================================
--- branches/Branch_4_2/ejb3/src/resources/test/mdb/mdbtest-service.xml	2007-07-09 18:00:04 UTC (rev 63913)
+++ branches/Branch_4_2/ejb3/src/resources/test/mdb/mdbtest-service.xml	2007-07-09 18:42:46 UTC (rev 63914)
@@ -82,5 +82,11 @@
       <attribute name="JNDIName">queue/concurrentmdbtest</attribute>
       <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
    </mbean>
+   
+   <mbean code="org.jboss.mq.server.jmx.Queue"
+      name="jboss.mq.destination:service=Queue,name=mismatchedqueuetest">
+      <attribute name="JNDIName">queue/mismatchedmdbtest</attribute>
+      <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
+   </mbean>
 
 </server>

Modified: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/jca/inflowmdb/JMSMDBBean.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/jca/inflowmdb/JMSMDBBean.java	2007-07-09 18:00:04 UTC (rev 63913)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/jca/inflowmdb/JMSMDBBean.java	2007-07-09 18:42:46 UTC (rev 63914)
@@ -22,6 +22,7 @@
 package org.jboss.ejb3.test.jca.inflowmdb;
 
 import org.jboss.logging.Logger;
+import org.jboss.annotation.ejb.PoolClass;
 import org.jboss.annotation.ejb.ResourceAdapter;
 
 import javax.ejb.MessageDriven;
@@ -41,6 +42,7 @@
 @ActivationConfigProperty(propertyName="maxSession", propertyValue="1")
 })
 @ResourceAdapter("jms-ra.rar")
+ at PoolClass(value=org.jboss.ejb3.StrictMaxPool.class, maxSize=1, timeout=10000)
 public class JMSMDBBean implements MessageListener
 {
    private static final Logger log = Logger.getLogger(JMSMDBBean.class);

Added: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/mdb/MismatchedQueueMDB.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/mdb/MismatchedQueueMDB.java	                        (rev 0)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/mdb/MismatchedQueueMDB.java	2007-07-09 18:42:46 UTC (rev 63914)
@@ -0,0 +1,61 @@
+/*
+ * 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;
+
+import javax.ejb.ActivationConfigProperty;
+import javax.ejb.MessageDriven;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.TextMessage;
+
+import org.jboss.annotation.ejb.PoolClass;
+import org.jboss.logging.Logger;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+ at MessageDriven(activationConfig =
+        {
+        @ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"),
+        @ActivationConfigProperty(propertyName="destination", propertyValue="queue/mismatchedmdbtest"),
+        @ActivationConfigProperty(propertyName="maxSession", propertyValue="100")
+        })
+ at PoolClass(value=org.jboss.ejb3.StrictMaxPool.class, maxSize=1, timeout=10000)
+public class MismatchedQueueMDB
+implements MessageListener
+{
+   private static final Logger log = Logger.getLogger(MismatchedQueueMDB.class);
+   
+   private int count = 0;
+   
+   public void onMessage(Message recvMsg)
+   {
+      ++TestStatusBean.mismatchedQueueRan;
+      ++count;
+      
+      try
+      {
+         System.out.println("+++ MismatchedQueueMDB onMessage " + TestStatusBean.mismatchedQueueRan + " " + count + " " + ((TextMessage)recvMsg).getText());
+      }
+      catch (Exception e){}
+   }
+}

Modified: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/mdb/OverrideTestMDB.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/mdb/OverrideTestMDB.java	2007-07-09 18:00:04 UTC (rev 63913)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/mdb/OverrideTestMDB.java	2007-07-09 18:42:46 UTC (rev 63914)
@@ -28,6 +28,7 @@
 import javax.jms.MessageListener;
 import javax.annotation.Resource;
 
+import org.jboss.annotation.ejb.PoolClass;
 import org.jboss.logging.Logger;
 
 /**
@@ -39,6 +40,7 @@
         @ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Bogus"),
         @ActivationConfigProperty(propertyName="destination", propertyValue="queue/bogus")
         })
+ at PoolClass(value=org.jboss.ejb3.StrictMaxPool.class, maxSize=100, timeout=10000)
 public class OverrideTestMDB implements MessageListener
 {
    private static final Logger log = Logger.getLogger(OverrideTestMDB.class);

Modified: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/mdb/QueueTestMDB.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/mdb/QueueTestMDB.java	2007-07-09 18:00:04 UTC (rev 63913)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/mdb/QueueTestMDB.java	2007-07-09 18:42:46 UTC (rev 63914)
@@ -36,6 +36,7 @@
 
 import javax.annotation.security.RunAs;
 
+import org.jboss.annotation.ejb.PoolClass;
 import org.jboss.annotation.security.SecurityDomain;
 import org.jboss.logging.Logger;
 
@@ -51,6 +52,7 @@
         @ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"),
         @ActivationConfigProperty(propertyName="destination", propertyValue="queue/mdbtest")
         })
+ at PoolClass(value=org.jboss.ejb3.StrictMaxPool.class, maxSize=1, timeout=10000)
 @RunAs("TestRole")
 @SecurityDomain("other")
 public class QueueTestMDB

Modified: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/mdb/TestStatus.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/mdb/TestStatus.java	2007-07-09 18:00:04 UTC (rev 63913)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/mdb/TestStatus.java	2007-07-09 18:42:46 UTC (rev 63914)
@@ -36,6 +36,8 @@
 
    int queueFired();
    
+   int mismatchedQueueFired();
+   
    int concurrentQueueFired();
    
    int overrideQueueFired();

Modified: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/mdb/TestStatusBean.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/mdb/TestStatusBean.java	2007-07-09 18:00:04 UTC (rev 63913)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/mdb/TestStatusBean.java	2007-07-09 18:42:46 UTC (rev 63914)
@@ -40,6 +40,7 @@
    private static final Logger log = Logger.getLogger(TestStatusBean.class);
    
    public static int queueRan = 0;
+   public static int mismatchedQueueRan = 0;
    public static int concurrentQueueRan = 0;
    public static int overrideQueueRan = 0;
    public static int defaultedQueueRan = 0;
@@ -60,6 +61,7 @@
    public void clear()
    {
       queueRan = 0;
+      mismatchedQueueRan = 0;
       concurrentQueueRan = 0;
       topicRan = 0;
       bmtQueueRan = 0;
@@ -82,6 +84,11 @@
       return queueRan;
    }
    
+   public int mismatchedQueueFired()
+   {
+      return mismatchedQueueRan;
+   }
+   
    public int concurrentQueueFired()
    {
       return concurrentQueueRan;

Modified: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/mdb/TransactionQueueTestMDB.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/mdb/TransactionQueueTestMDB.java	2007-07-09 18:00:04 UTC (rev 63913)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/mdb/TransactionQueueTestMDB.java	2007-07-09 18:42:46 UTC (rev 63914)
@@ -34,6 +34,7 @@
 import javax.annotation.security.RunAs;
 import javax.annotation.Resource;
 
+import org.jboss.annotation.ejb.PoolClass;
 import org.jboss.annotation.ejb.TransactionTimeout;
 import org.jboss.annotation.security.SecurityDomain;
 import org.jboss.logging.Logger;
@@ -52,6 +53,7 @@
 // Wolf: this is NOT supported, use the proper activation config property
 //@TransactionTimeout(1)
 @TransactionAttribute(TransactionAttributeType.REQUIRED)
+ at PoolClass(value=org.jboss.ejb3.StrictMaxPool.class, maxSize=1, timeout=10000)
 public class TransactionQueueTestMDB implements MessageListener
 {
    private static final Logger log = Logger.getLogger(TransactionQueueTestMDB.class);

Modified: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/mdb/unit/MDBUnitTestCase.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/mdb/unit/MDBUnitTestCase.java	2007-07-09 18:00:04 UTC (rev 63913)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/mdb/unit/MDBUnitTestCase.java	2007-07-09 18:42:46 UTC (rev 63914)
@@ -243,7 +243,34 @@
       String state = stateless.getState();
       assertEquals("Set", state);
    }
+   
+   public void testMismatchedMDB() throws Exception
+   {
+      TestStatus status = (TestStatus) getInitialContext().lookup(
+            "TestStatusBean/remote");
+      clear(status);
+      QueueConnection cnn = null;
+      QueueSender sender = null;
+      QueueSession session = null;
 
+      Queue queue = (Queue) getInitialContext().lookup("queue/mismatchedmdbtest");
+      QueueConnectionFactory factory = getQueueConnectionFactory();
+      cnn = factory.createQueueConnection();
+      session = cnn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE); 
+
+      sender = session.createSender(queue);
+      for (int i = 0; i < 100 ; ++i)
+      {
+         TextMessage msg = session.createTextMessage("Hello World " + i);
+         sender.send(msg);
+      }
+      session.close();
+      cnn.close();
+
+      Thread.sleep(5000);
+      assertEquals(100, status.mismatchedQueueFired());
+   }
+
    public void testTopic() throws Exception
    {
       TestStatus status = (TestStatus) getInitialContext().lookup(




More information about the jboss-cvs-commits mailing list