[jboss-cvs] JBossAS SVN: r78919 - in projects/ejb3/trunk/core/src: test/java/org/jboss/ejb3/core/test and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Sep 29 06:42:31 EDT 2008


Author: wolfc
Date: 2008-09-29 06:42:31 -0400 (Mon, 29 Sep 2008)
New Revision: 78919

Added:
   projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1506/
   projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1506/TestBean.java
   projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1506/unit/
   projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1506/unit/DescriptorAnnotationTestCase.java
Modified:
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/Ejb3DescriptorHandler.java
Log:
EJBTHREE-1506: make sure a Stateful annotation is added

Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/Ejb3DescriptorHandler.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/Ejb3DescriptorHandler.java	2008-09-29 09:41:08 UTC (rev 78918)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/Ejb3DescriptorHandler.java	2008-09-29 10:42:31 UTC (rev 78919)
@@ -127,6 +127,7 @@
 import org.jboss.ejb3.annotation.impl.SecurityDomainImpl;
 import org.jboss.ejb3.annotation.impl.SerializedConcurrentAccessImpl;
 import org.jboss.ejb3.annotation.impl.ServiceImpl;
+import org.jboss.ejb3.annotation.impl.StatefulImpl;
 import org.jboss.ejb3.annotation.impl.StatelessImpl;
 import org.jboss.ejb3.annotation.impl.TransactionAttributeImpl;
 import org.jboss.ejb3.annotation.impl.TransactionManagementImpl;
@@ -454,6 +455,12 @@
 
       container.setAssemblyDescriptor(dd.getAssemblyDescriptor());
 
+      StatefulImpl annotation = new StatefulImpl(ejbName);
+      if (enterpriseBean != null && !isAnnotatedBean())
+      {
+         addClassAnnotation(container, annotation);
+      }
+
       if(enterpriseBean instanceof JBossSessionBeanMetaData)
          addInterfaces(container, (JBossSessionBeanMetaData) enterpriseBean);
       else
@@ -2078,6 +2085,11 @@
       */
    }
 
+   private void addClassAnnotation(EJBContainer container, Annotation annotation)
+   {
+      addClassAnnotation(container, annotation.annotationType(), annotation);
+   }
+   
    private void addClassAnnotation(EJBContainer container, Class<? extends Annotation> annotationClass, Annotation annotation)
    {
       log.debug("adding class annotation " + annotationClass.getName() + " to "

Added: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1506/TestBean.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1506/TestBean.java	                        (rev 0)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1506/TestBean.java	2008-09-29 10:42:31 UTC (rev 78919)
@@ -0,0 +1,31 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.core.test.ejbthree1506;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class TestBean
+{
+
+}

Added: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1506/unit/DescriptorAnnotationTestCase.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1506/unit/DescriptorAnnotationTestCase.java	                        (rev 0)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1506/unit/DescriptorAnnotationTestCase.java	2008-09-29 10:42:31 UTC (rev 78919)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.core.test.ejbthree1506.unit;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.util.HashMap;
+import java.util.List;
+
+import javax.ejb.Stateful;
+
+import org.jboss.ejb3.Container;
+import org.jboss.ejb3.EJBContainer;
+import org.jboss.ejb3.Ejb3DescriptorHandler;
+import org.jboss.ejb3.core.test.common.AbstractEJB3TestCase;
+import org.jboss.ejb3.core.test.common.MockEjb3Deployment;
+import org.jboss.ejb3.core.test.ejbthree1506.TestBean;
+import org.jboss.ejb3.test.cachepassivation.MockDeploymentUnit;
+import org.jboss.metadata.ejb.jboss.JBossAssemblyDescriptorMetaData;
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeansMetaData;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+import org.jboss.metadata.ejb.spec.SessionType;
+import org.junit.Test;
+
+/**
+ * If I have a SFSB in the descriptor I should be able to find
+ * the corresponding annotation.
+ * 
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class DescriptorAnnotationTestCase extends AbstractEJB3TestCase
+{
+   @Test
+   public void test1() throws Exception
+   {
+      JBossMetaData metaData = new JBossMetaData();
+      JBossEnterpriseBeansMetaData enterpriseBeans = new JBossEnterpriseBeansMetaData();
+      metaData.setEnterpriseBeans(enterpriseBeans);
+      metaData.setAssemblyDescriptor(new JBossAssemblyDescriptorMetaData());
+      JBossSessionBeanMetaData sessionBeanMetaData = new JBossSessionBeanMetaData();
+      sessionBeanMetaData.setEnterpriseBeansMetaData(enterpriseBeans);
+      sessionBeanMetaData.setEjbClass(TestBean.class.getName());
+      sessionBeanMetaData.setEjbName("TestBean");
+      sessionBeanMetaData.setSessionType(SessionType.Stateful);
+      enterpriseBeans.add(sessionBeanMetaData);
+      
+      MockEjb3Deployment deployment = new MockEjb3Deployment(new MockDeploymentUnit(), null);
+      Ejb3DescriptorHandler handler = new Ejb3DescriptorHandler(deployment, metaData);
+      List<Container> containers = handler.getContainers(deployment, new HashMap<String, Container>());
+      
+      Stateful annotation = ((EJBContainer) containers.get(0)).getAnnotation(Stateful.class);
+      assertNotNull("Can't find annotation @Stateful on the container", annotation);
+   }
+}




More information about the jboss-cvs-commits mailing list