[jboss-cvs] JBossAS SVN: r61353 - in trunk/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 15:55:48 EDT 2007
Author: bdecoste
Date: 2007-03-15 15:55:48 -0400 (Thu, 15 Mar 2007)
New Revision: 61353
Added:
trunk/ejb3/src/resources/test/invalidtxmdb/
trunk/ejb3/src/resources/test/invalidtxmdb/mdbtest-service.xml
trunk/ejb3/src/test/org/jboss/ejb3/test/invalidtxmdb/
trunk/ejb3/src/test/org/jboss/ejb3/test/invalidtxmdb/QueueTestMDB.java
trunk/ejb3/src/test/org/jboss/ejb3/test/invalidtxmdb/TestStatus.java
trunk/ejb3/src/test/org/jboss/ejb3/test/invalidtxmdb/TestStatusBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/invalidtxmdb/unit/
trunk/ejb3/src/test/org/jboss/ejb3/test/invalidtxmdb/unit/MDBUnitTestCase.java
Modified:
trunk/ejb3/build-test.xml
trunk/ejb3/src/main/org/jboss/ejb3/Ejb3AnnotationHandler.java
Log:
[EJBTHREE-831] MDBs only support REQUIRED and NOT_SUPPORTED
Modified: trunk/ejb3/build-test.xml
===================================================================
--- trunk/ejb3/build-test.xml 2007-03-15 19:36:45 UTC (rev 61352)
+++ trunk/ejb3/build-test.xml 2007-03-15 19:55:48 UTC (rev 61353)
@@ -2362,7 +2362,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">
@@ -3100,7 +3116,7 @@
</jar>
</target>
- <target name="jars" depends="descriptortypo, libdeployment, homeinterface, timestampentity, arjuna, mdbtransactions, unauthenticatedprincipal, clusteredservice, invoker, classloader,
+ <target name="jars" depends="invalidtxmdb, descriptortypo, libdeployment, homeinterface, timestampentity, arjuna, mdbtransactions, unauthenticatedprincipal, clusteredservice, invoker, classloader,
circulardependency, jsp, timerdependency, servicedependency, servlet, stateless14, webservices, ear, ejbthree440,
ejbthree454, ejbthree653, ejbthree670, ejbthree712, ejbthree751, aspectdomain, ejbcontext, schema, mail, scopedclassloader, dependency,
securitydomain, enventry,
@@ -3818,6 +3834,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: trunk/ejb3/src/main/org/jboss/ejb3/Ejb3AnnotationHandler.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/Ejb3AnnotationHandler.java 2007-03-15 19:36:45 UTC (rev 61352)
+++ trunk/ejb3/src/main/org/jboss/ejb3/Ejb3AnnotationHandler.java 2007-03-15 19:55:48 UTC (rev 61353)
@@ -25,19 +25,19 @@
import javassist.bytecode.ClassFile;
import javassist.bytecode.annotation.Annotation;
import javassist.bytecode.annotation.StringMemberValue;
-import org.jboss.annotation.ejb.ResourceAdapter;
import org.jboss.aop.AspectManager;
import org.jboss.aop.DomainDefinition;
import org.jboss.ejb3.metamodel.EnterpriseBean;
-import org.jboss.ejb3.metamodel.MessageDrivenBean;
import org.jboss.ejb3.mdb.ConsumerContainer;
import org.jboss.ejb3.mdb.MDB;
-import org.jboss.ejb3.mdb.inflow.JBossMessageEndpointFactory;
import org.jboss.ejb3.service.ServiceContainer;
import org.jboss.ejb3.stateful.StatefulContainer;
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 +152,7 @@
else if (ejbType == EJB_TYPE.MESSAGE_DRIVEN)
{
MDB container = getMDB(ejbIndex);
+ validateMDBTransactionAttribute(container);
container.setJaccContextId(getJaccContextId());
containers.add(container);
}
@@ -173,6 +174,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: trunk/ejb3/src/resources/test/invalidtxmdb/mdbtest-service.xml
===================================================================
--- trunk/ejb3/src/resources/test/invalidtxmdb/mdbtest-service.xml (rev 0)
+++ trunk/ejb3/src/resources/test/invalidtxmdb/mdbtest-service.xml 2007-03-15 19:55:48 UTC (rev 61353)
@@ -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: trunk/ejb3/src/test/org/jboss/ejb3/test/invalidtxmdb/QueueTestMDB.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/invalidtxmdb/QueueTestMDB.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/invalidtxmdb/QueueTestMDB.java 2007-03-15 19:55:48 UTC (rev 61353)
@@ -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: trunk/ejb3/src/test/org/jboss/ejb3/test/invalidtxmdb/TestStatus.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/invalidtxmdb/TestStatus.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/invalidtxmdb/TestStatus.java 2007-03-15 19:55:48 UTC (rev 61353)
@@ -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: trunk/ejb3/src/test/org/jboss/ejb3/test/invalidtxmdb/TestStatusBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/invalidtxmdb/TestStatusBean.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/invalidtxmdb/TestStatusBean.java 2007-03-15 19:55:48 UTC (rev 61353)
@@ -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: trunk/ejb3/src/test/org/jboss/ejb3/test/invalidtxmdb/unit/MDBUnitTestCase.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/invalidtxmdb/unit/MDBUnitTestCase.java (rev 0)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/invalidtxmdb/unit/MDBUnitTestCase.java 2007-03-15 19:55:48 UTC (rev 61353)
@@ -0,0 +1,85 @@
+/*
+ * 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.QueueConnectionFactory;
+
+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
+ {
+ try
+ {
+ TestStatus status = (TestStatus) getInitialContext().lookup("TestStatusBean/remote");
+ fail("TestStatusBean should not have deployed");
+ }
+ catch (javax.naming.NameNotFoundException e)
+ {
+ }
+ }
+
+ 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