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

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Mar 15 14:54:36 EDT 2007


Author: bdecoste
Date: 2007-03-15 14:54:36 -0400 (Thu, 15 Mar 2007)
New Revision: 61346

Added:
   branches/Branch_4_2/ejb3/src/resources/test/invalidtxmdb/
   branches/Branch_4_2/ejb3/src/resources/test/invalidtxmdb/mdbtest-service.xml
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/invalidtxmdb/
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/invalidtxmdb/QueueTestMDB.java
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/invalidtxmdb/TestStatus.java
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/invalidtxmdb/TestStatusBean.java
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/invalidtxmdb/unit/
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/invalidtxmdb/unit/MDBUnitTestCase.java
Modified:
   branches/Branch_4_2/ejb3/build-test.xml
   branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/Ejb3AnnotationHandler.java
Log:
[EJBTHREE-831] MDBs only support REQUIRED and NOT_SUPPORTED

Modified: branches/Branch_4_2/ejb3/build-test.xml
===================================================================
--- branches/Branch_4_2/ejb3/build-test.xml	2007-03-15 18:46:12 UTC (rev 61345)
+++ branches/Branch_4_2/ejb3/build-test.xml	2007-03-15 18:54:36 UTC (rev 61346)
@@ -2275,7 +2275,23 @@
          </fileset>
       </jar>
    </target>
+   
+   <target name="invalidtxmdb"
+      description="Builds all jar files."
+      depends="compile-classes">
 
+      <mkdir dir="${build.lib}"/>
+
+      <jar jarfile="${build.lib}/invalidtxmdb-test.jar">
+         <fileset dir="${build.classes}">
+            <include name="org/jboss/ejb3/test/invalidtxmdb/*.class"/>
+         </fileset>
+         <fileset dir="${resources}/test/invalidtxmdb">
+            <include name="*.xml"/>
+         </fileset>
+      </jar>
+   </target>
+
    <target name="mdb"
       description="Builds all jar files."
       depends="compile-classes">
@@ -2301,7 +2317,6 @@
             <include name="*.xml"/>
          </fileset>
       </copy>
-      
    </target>
 
    <target name="mdbtopic"
@@ -3028,7 +3043,7 @@
       </jar>
    </target>
    
-   <target name="jars" depends="descriptortypo, libdeployment, homeinterface, timestampentity, servicexmbean, arjuna, mdbtransactions, unauthenticatedprincipal, clusteredservice, invoker, classloader, 
+   <target name="jars" depends="invalidtxmdb, descriptortypo, libdeployment, homeinterface, timestampentity, servicexmbean, arjuna, mdbtransactions, unauthenticatedprincipal, clusteredservice, invoker, classloader, 
       circulardependency, jsp, timerdependency, servicedependency, servlet, stateless14, webservices, ear, ejbthree440, 
       ejbthree454, ejbthree653, ejbthree670, ejbthree712, ejbthree751, ejbthree832,
       aspectdomain, ejbcontext, schema, mail, scopedclassloader, dependency, jaxws,
@@ -3432,6 +3447,9 @@
          <param name="test" value="mdb"/>
       </antcall>
       <antcall target="test" inheritRefs="true">
+         <param name="test" value="invalidtxmdb"/>
+      </antcall>
+      <antcall target="test" inheritRefs="true">
          <param name="test" value="mdbtransactions"/>
       </antcall>
       <antcall target="test" inheritRefs="true">

Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/Ejb3AnnotationHandler.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/Ejb3AnnotationHandler.java	2007-03-15 18:46:12 UTC (rev 61345)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/Ejb3AnnotationHandler.java	2007-03-15 18:54:36 UTC (rev 61346)
@@ -38,6 +38,9 @@
 import org.jboss.ejb3.stateless.StatelessContainer;
 import org.jboss.logging.Logger;
 
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+
 import java.util.ArrayList;
 import java.util.Hashtable;
 import java.util.List;
@@ -152,6 +155,7 @@
          else if (ejbType == EJB_TYPE.MESSAGE_DRIVEN)
          {
             MDB container = getMDB(ejbIndex);
+            validateMDBTransactionAttribute(container);
             container.setJaccContextId(getJaccContextId());
             containers.add(container);
          }
@@ -173,6 +177,18 @@
       return containers;
    }
    
+   protected void validateMDBTransactionAttribute(MDB mdb)
+   {
+      TransactionAttribute tx = (TransactionAttribute)mdb.resolveAnnotation(TransactionAttribute.class); 
+      if (tx != null)
+      {
+         TransactionAttributeType type = tx.value();
+         if (type != TransactionAttributeType.REQUIRED && type != TransactionAttributeType.NOT_SUPPORTED)
+            throw new RuntimeException("MDB " + mdb.getEjbName() + " has an invalid TransactionAttribute: " + type + 
+                  ". Only REQUIRED and NOT_SUPPORTED are valid");
+      }
+   }
+   
    protected String getAspectDomain(int ejbIndex, String defaultDomain)
    {
       return EJB3Util.getAspectDomain(visible, defaultDomain);

Added: branches/Branch_4_2/ejb3/src/resources/test/invalidtxmdb/mdbtest-service.xml
===================================================================
--- branches/Branch_4_2/ejb3/src/resources/test/invalidtxmdb/mdbtest-service.xml	                        (rev 0)
+++ branches/Branch_4_2/ejb3/src/resources/test/invalidtxmdb/mdbtest-service.xml	2007-03-15 18:54:36 UTC (rev 61346)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<server>
+   <mbean code="org.jboss.mq.server.jmx.Queue"
+      name="jboss.mq.destination:service=Queue,name=queuetest">
+      <attribute name="JNDIName">queue/mdbtest</attribute>
+      <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
+   </mbean>
+</server>

Added: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/invalidtxmdb/QueueTestMDB.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/invalidtxmdb/QueueTestMDB.java	                        (rev 0)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/invalidtxmdb/QueueTestMDB.java	2007-03-15 18:54:36 UTC (rev 61346)
@@ -0,0 +1,51 @@
+/*
+ * 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.invalidtxmdb;
+
+import javax.ejb.ActivationConfigProperty;
+import javax.ejb.MessageDriven;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+
+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/mdbtest")
+        })
+ at TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
+public class QueueTestMDB implements MessageListener
+{
+   private static final Logger log = Logger.getLogger(QueueTestMDB.class);
+   
+   public void onMessage(Message recvMsg)
+   {
+      System.out.println("--- QueueTestMDB onMessage ");
+      ++TestStatusBean.queueRan;
+   }
+}

Added: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/invalidtxmdb/TestStatus.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/invalidtxmdb/TestStatus.java	                        (rev 0)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/invalidtxmdb/TestStatus.java	2007-03-15 18:54:36 UTC (rev 61346)
@@ -0,0 +1,30 @@
+/*
+ * 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.invalidtxmdb;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public interface TestStatus
+{
+   int queueFired();
+}

Added: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/invalidtxmdb/TestStatusBean.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/invalidtxmdb/TestStatusBean.java	                        (rev 0)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/invalidtxmdb/TestStatusBean.java	2007-03-15 18:54:36 UTC (rev 61346)
@@ -0,0 +1,49 @@
+/*
+ * 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.invalidtxmdb;
+
+import javax.ejb.Stateless;
+import javax.ejb.Remote;
+
+import org.jboss.logging.Logger;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+ at Stateless
+ at Remote(TestStatus.class)
+public class TestStatusBean implements TestStatus
+{
+   private static final Logger log = Logger.getLogger(TestStatusBean.class);
+   
+   public static int queueRan = 0;
+
+   public void clear()
+   {
+      queueRan = 0;
+   }
+
+   public int queueFired()
+   {
+      return queueRan;
+   }
+}

Added: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/invalidtxmdb/unit/MDBUnitTestCase.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/invalidtxmdb/unit/MDBUnitTestCase.java	                        (rev 0)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/invalidtxmdb/unit/MDBUnitTestCase.java	2007-03-15 18:54:36 UTC (rev 61346)
@@ -0,0 +1,101 @@
+/*
+ * 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.invalidtxmdb.unit;
+
+import javax.jms.Queue;
+import javax.jms.QueueConnection;
+import javax.jms.QueueConnectionFactory;
+import javax.jms.QueueSender;
+import javax.jms.QueueSession;
+import javax.jms.TextMessage;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import junit.framework.Test;
+
+import org.jboss.ejb3.InitialContextFactory;
+import org.jboss.ejb3.test.invalidtxmdb.TestStatus;
+import org.jboss.logging.Logger;
+import org.jboss.test.JBossTestCase;
+
+/**
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public class MDBUnitTestCase extends JBossTestCase
+{
+   private static final Logger log = Logger.getLogger(MDBUnitTestCase.class);
+
+   public MDBUnitTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testQueue() throws Exception
+   {
+      TestStatus status = (TestStatus) getInitialContext().lookup(
+            "TestStatusBean/remote");
+      QueueConnection cnn = null;
+      QueueSender sender = null;
+      QueueSession session = null;
+
+      Queue queue = (Queue) getInitialContext().lookup("queue/mdbtest");
+      QueueConnectionFactory factory = getQueueConnectionFactory();
+      cnn = factory.createQueueConnection();
+      session = cnn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
+
+      TextMessage msg = session.createTextMessage("Hello World");
+
+      sender = session.createSender(queue);
+      sender.send(msg);
+      session.close();
+      cnn.close();
+
+      Thread.sleep(2000);
+      assertEquals(0, status.queueFired());
+   }
+   
+   protected QueueConnectionFactory getQueueConnectionFactory()
+      throws Exception
+   {
+      try
+      {
+         return (QueueConnectionFactory) getInitialContext().lookup(
+               "ConnectionFactory");
+      }
+      catch (NamingException e)
+      {
+         return (QueueConnectionFactory) getInitialContext().lookup(
+               "java:/ConnectionFactory");
+      }
+   }
+   
+   protected InitialContext getInitialContext() throws Exception
+   {
+      return InitialContextFactory.getInitialContext();
+   }
+
+   public static Test suite() throws Exception
+   {
+      return getDeploySetup(MDBUnitTestCase.class, "invalidtxmdb-test.jar");
+   }
+
+}
\ No newline at end of file




More information about the jboss-cvs-commits mailing list