[jboss-cvs] JBossAS SVN: r73696 - in projects/metadata/trunk/src: test/java/org/jboss/test/metadata and 4 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue May 27 03:45:27 EDT 2008


Author: emuckenhuber
Date: 2008-05-27 03:45:27 -0400 (Tue, 27 May 2008)
New Revision: 73696

Added:
   projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/AbstractHomeProcessor.java
   projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyStateful21.java
   projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta41/
   projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta41/MultipleReturnTypeBean.java
   projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta41/MultipleReturnTypeHome.java
   projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta41/MyFailingStatelessBean.java
   projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta41/MyOtherFailingStateLessBean.java
   projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta41/MyOtherStatelessHome.java
   projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta41/MyStateful21Local.java
   projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta41/MyStateful21Remote.java
   projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta41/MyStatefulBean.java
   projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta41/MyStatefulLocalHome.java
   projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta41/MyStatefulRemoteHome.java
   projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta41/WrongCreateStatelessBean.java
   projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta41/WrongCreateStatelessHome.java
   projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta41/unit/
   projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta41/unit/HomeProcessingUnitTestCase.java
Modified:
   projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/AbstractSessionBeanProcessor.java
   projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/LocalHomeProcessor.java
   projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/LocalProcessor.java
   projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/RemoteHomeProcessor.java
   projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/RemoteProcessor.java
   projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyStatefulHome.java
   projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyStateless21Bean.java
   projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/multiview/MultiviewBean.java
Log:
JBMETA-41

Added: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/AbstractHomeProcessor.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/AbstractHomeProcessor.java	                        (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/AbstractHomeProcessor.java	2008-05-27 07:45:27 UTC (rev 73696)
@@ -0,0 +1,99 @@
+/*
+ * 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.metadata.annotation.creator.ejb;
+
+import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.metadata.annotation.creator.AbstractFinderUser;
+import org.jboss.metadata.annotation.finder.AnnotationFinder;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public abstract class AbstractHomeProcessor extends AbstractFinderUser
+{
+   /** . */
+   private final static String CREATE = "create"; 
+   
+   protected AbstractHomeProcessor(AnnotationFinder<AnnotatedElement> finder)
+   {
+      super(finder);
+   }
+
+   protected static Class<?> getCreateReturnSignature(Class<?> cls, boolean isStateless)
+   {
+      List<Class<?>> types = new ArrayList<Class<?>>();
+      List<Method> declaredMethods = getCreateMethods(cls);
+      
+      if(isStateless)
+      {
+         // A stateless session bean must define exactly one create method with no arguments
+         if(declaredMethods.size() != 1)
+            throw new IllegalStateException("EJB 3.0 Specification Violation (4.6.8 Bullet 4, 4.6.10 Bullet 4): \""
+                  + "A stateless session bean must define exactly one create method with no arguments." + "\"; found in "
+                  + cls.getName());
+       
+         Method method = declaredMethods.get(0);
+         // Check create(void)
+         if(! method.getName().equals("create") || method.getParameterTypes().length != 0 )
+            throw new IllegalStateException("EJB 3.0 Specification Violation (4.6.8 Bullet 4, 4.6.10 Bullet 4): \""
+                  + "A stateless session bean must define exactly one create method with no arguments." + "\"; found in "
+                  + cls.getName());
+      }
+
+      // A home interface must define one or more create<METHOD> methods
+      if(declaredMethods.size() == 0)
+         throw new IllegalStateException("EJB 3.0 Core Specification Violation (4.6.8 Bullet 5): EJB2.1 Home Interface "
+               + cls + " does not declare a \'create<METHOD>\' method");
+      
+      for(Method method : declaredMethods)
+      {
+         if(!types.contains(method.getReturnType()))
+         {
+            types.add(method.getReturnType());
+         }
+      }
+      
+      // The return type for a create<METHOD> method must be the session bean’s remote / local interface type
+      if(types.size() != 1)
+         throw new IllegalStateException("An EJB 2.1 view can't have multiple remote/local interfaces");      
+      
+      return types.get(0);
+   }
+   
+   protected static List<Method> getCreateMethods(Class<?> cls)
+   {
+      List<Method> declaredCreateMethods = new ArrayList<Method>();
+      for(Method method : cls.getDeclaredMethods())
+      {
+         if(method.getName().startsWith(CREATE))
+         {
+            declaredCreateMethods.add(method);
+         }
+      }
+      return declaredCreateMethods;
+   }  
+}

Modified: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/AbstractSessionBeanProcessor.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/AbstractSessionBeanProcessor.java	2008-05-27 06:08:09 UTC (rev 73695)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/AbstractSessionBeanProcessor.java	2008-05-27 07:45:27 UTC (rev 73696)
@@ -22,8 +22,6 @@
 package org.jboss.metadata.annotation.creator.ejb;
 
 import java.lang.reflect.AnnotatedElement;
-import java.util.ArrayList;
-import java.util.List;
 
 import javax.ejb.TransactionManagement;
 import javax.ejb.TransactionManagementType;
@@ -46,18 +44,13 @@
  */
 public abstract class AbstractSessionBeanProcessor extends AbstractEnterpriseBeanProcessor<SessionBeanMetaData> implements Creator<Class<?>, SessionBeanMetaData>, Processor<EjbJar3xMetaData, Class<?>>
 {
-   private List<Processor<SessionBeanMetaData, Class<?>>> topLevelProcessors;
-   
+  
    protected AbstractSessionBeanProcessor(AnnotationFinder<AnnotatedElement> finder)
    {
       super(finder);
-      
-      // TODO: configure somehow
-      
-      topLevelProcessors = new ArrayList<Processor<SessionBeanMetaData,Class<?>>>();
-      topLevelProcessors.add(new LocalHomeProcessor(finder));
-      
+
       addTypeProcessor(new LocalProcessor(finder));
+      addTypeProcessor(new LocalHomeProcessor(finder));
       addTypeProcessor(new RemoteProcessor(finder));
       addTypeProcessor(new RemoteHomeProcessor(finder));
 
@@ -96,17 +89,8 @@
       if(txMgmt != null)
          txType = txMgmt.value();
       bean.setTransactionType(txType);
-
-      processTopLevel(bean, beanClass);
       
       return bean;
    }
    
-   private void processTopLevel(SessionBeanMetaData bean, Class<?> cls)
-   {    
-      for(Processor<SessionBeanMetaData, Class<?>> processor : topLevelProcessors)
-      {
-         processor.process(bean, cls);
-      }
-   }
 }

Modified: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/LocalHomeProcessor.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/LocalHomeProcessor.java	2008-05-27 06:08:09 UTC (rev 73695)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/LocalHomeProcessor.java	2008-05-27 07:45:27 UTC (rev 73696)
@@ -23,9 +23,10 @@
 
 import java.lang.reflect.AnnotatedElement;
 
+import javax.ejb.EJBLocalHome;
+import javax.ejb.EJBLocalObject;
 import javax.ejb.LocalHome;
 
-import org.jboss.metadata.annotation.creator.AbstractFinderUser;
 import org.jboss.metadata.annotation.creator.Processor;
 import org.jboss.metadata.annotation.finder.AnnotationFinder;
 import org.jboss.metadata.ejb.spec.SessionBeanMetaData;
@@ -34,9 +35,10 @@
  * Comment
  *
  * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision: $
+ * @version $Revision$
  */
-public class LocalHomeProcessor extends AbstractFinderUser implements Processor<SessionBeanMetaData, Class<?>>
+public class LocalHomeProcessor extends AbstractHomeProcessor
+   implements Processor<SessionBeanMetaData, Class<?>>
 {
    public LocalHomeProcessor(AnnotationFinder<AnnotatedElement> finder)
    {
@@ -48,7 +50,30 @@
       LocalHome annotation = finder.getAnnotation(type, LocalHome.class);
       if(annotation == null)
          return;
+
+      Class<?> localHome = annotation.value();
+      if(!EJBLocalHome.class.isAssignableFrom(localHome)) 
+         throw new IllegalStateException("Declared EJB 2.1 Home Interface " + localHome.getName() + " does not extend "
+               + EJBLocalHome.class.getName() + " as required by EJB 3.0 Core Specification 4.6.10"); 
       
-      metaData.setLocalHome(annotation.value().getName());
+      metaData.setLocalHome(localHome.getName());
+      
+      // Processing the local interface
+      setLocal(metaData, localHome, metaData.isStateless());
    }
+   
+   private void setLocal(SessionBeanMetaData metaData, Class<?> localHome, boolean isStateless)
+   {
+      Class<?> businessInterface = getCreateReturnSignature(localHome, metaData.isStateless());
+      if(! EJBLocalObject.class.isAssignableFrom(businessInterface))
+         throw new IllegalStateException("EJB 3.0 Core Specification Violation (4.6.9): The session bean’s local interface "+ businessInterface + " must extend the javax.ejb.EJBLocalObject interface.");
+
+      // As the LocalProcessor allows a @Local which extends EjbHomeObject it should not fail on the same interface
+      if(metaData.getLocal() != null  && !metaData.getLocal().equals(businessInterface.getName()))
+         throw new IllegalStateException("2.1 bean " + metaData.getEjbName() + " already has a local interface " + metaData.getLocal() + ", can't add " + businessInterface.getName());
+      
+      metaData.setLocal(businessInterface.getName());
+
+   }
+   
 }

Modified: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/LocalProcessor.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/LocalProcessor.java	2008-05-27 06:08:09 UTC (rev 73695)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/LocalProcessor.java	2008-05-27 07:45:27 UTC (rev 73696)
@@ -52,9 +52,7 @@
       // EJB 3 4.6.9
       if(EJBLocalObject.class.isAssignableFrom(businessInterface))
       {
-         if(metaData.getLocal() != null)
-            throw new IllegalArgumentException("2.1 bean " + metaData.getEjbName() + " already has a local interface " + metaData.getLocal() + ", can't add " + businessInterface.getName());
-         metaData.setLocal(businessInterface.getName());
+         throw new IllegalStateException("EJB 3.0 Core Specification Violation (4.6.6): The session bean’s business interface "+ businessInterface + " must not extend the javax.ejb.EJBLocalObject interface.");
       }
       else
       {

Modified: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/RemoteHomeProcessor.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/RemoteHomeProcessor.java	2008-05-27 06:08:09 UTC (rev 73695)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/RemoteHomeProcessor.java	2008-05-27 07:45:27 UTC (rev 73696)
@@ -23,9 +23,10 @@
 
 import java.lang.reflect.AnnotatedElement;
 
+import javax.ejb.EJBHome;
+import javax.ejb.EJBObject;
 import javax.ejb.RemoteHome;
 
-import org.jboss.metadata.annotation.creator.AbstractFinderUser;
 import org.jboss.metadata.annotation.creator.Processor;
 import org.jboss.metadata.annotation.finder.AnnotationFinder;
 import org.jboss.metadata.ejb.spec.SessionBeanMetaData;
@@ -34,9 +35,9 @@
  * @RemoteHome annotation processor.
  *
  * @author Scott.Stark at jboss.org
- * @version $Revision: $
+ * @version $Revision$
  */
-public class RemoteHomeProcessor extends AbstractFinderUser
+public class RemoteHomeProcessor extends AbstractHomeProcessor
    implements Processor<SessionBeanMetaData, Class<?>>
 {  
    public RemoteHomeProcessor(AnnotationFinder<AnnotatedElement> finder)
@@ -50,6 +51,30 @@
       if(remote == null)
          return;
 
-      metaData.setHome(remote.value().getName());
+      Class<?> remoteHome = remote.value();
+      
+      if(!EJBHome.class.isAssignableFrom(remoteHome))
+         throw new IllegalStateException("Declared EJB 2.1 Home Interface " + remoteHome.getName() + " does not extend "
+               + EJBHome.class.getName() + " as required by EJB 3.0 Core Specification 4.6.8"); 
+      
+      metaData.setHome(remoteHome.getName());
+
+      // Processing the remote interface
+      setRemote(metaData, remoteHome, metaData.isStateless());
    }
+   
+   private void setRemote(SessionBeanMetaData metaData, Class<?> remoteHome, boolean isStateless)
+   {
+      Class<?> businessInterface = getCreateReturnSignature(remoteHome, metaData.isStateless());
+      if(! EJBObject.class.isAssignableFrom(businessInterface))
+         throw new IllegalStateException("EJB 3.0 Core Specification Violation (4.6.7): The session bean’s remote interface "+ businessInterface + " must extend the javax.ejb.EJBObject interface.");
+      
+      // As the RemoteProcessor allows a @Remote which extends EjbObject it should not fail on the same interface
+      if(metaData.getRemote() != null && !metaData.getRemote().equals(businessInterface.getName()))
+         throw new IllegalStateException("2.1 bean " + metaData.getEjbName() + " already has a remote interface " + metaData.getRemote() + ", can't add " + businessInterface.getName());
+         
+      metaData.setRemote(businessInterface.getName());
+
+   }
+   
 }

Modified: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/RemoteProcessor.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/RemoteProcessor.java	2008-05-27 06:08:09 UTC (rev 73695)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/RemoteProcessor.java	2008-05-27 07:45:27 UTC (rev 73696)
@@ -52,9 +52,7 @@
       // EJB 3 4.6.7
       if(EJBObject.class.isAssignableFrom(businessInterface))
       {
-         if(metaData.getRemote() != null)
-            throw new IllegalArgumentException("2.1 bean " + metaData.getEjbName() + " already has a remote interface " + metaData.getRemote() + ", can't add " + businessInterface.getName());
-         metaData.setRemote(businessInterface.getName());
+         throw new IllegalStateException("EJB 3.0 Core Specification Violation (4.6.6): The session bean’s business interface "+ businessInterface + " must not extend the javax.ejb.EJBObject interface.");
       }
       else
       {

Added: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyStateful21.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyStateful21.java	                        (rev 0)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyStateful21.java	2008-05-27 07:45:27 UTC (rev 73696)
@@ -0,0 +1,34 @@
+/*
+ * 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.test.metadata.annotation.ejb3;
+
+import javax.ejb.EJBObject;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public interface MyStateful21 extends EJBObject, MyStateful
+{
+
+}
+

Modified: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyStatefulHome.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyStatefulHome.java	2008-05-27 06:08:09 UTC (rev 73695)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyStatefulHome.java	2008-05-27 07:45:27 UTC (rev 73696)
@@ -29,5 +29,5 @@
  */
 public interface MyStatefulHome extends EJBHome
 {
-   public MyStateful create(String x);
+   public MyStateful21 create(String x);
 }

Modified: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyStateless21Bean.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyStateless21Bean.java	2008-05-27 06:08:09 UTC (rev 73695)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/MyStateless21Bean.java	2008-05-27 07:45:27 UTC (rev 73696)
@@ -21,7 +21,6 @@
  */
 package org.jboss.test.metadata.annotation.ejb3;
 
-import javax.ejb.Local;
 import javax.ejb.LocalHome;
 import javax.ejb.Stateless;
 
@@ -29,10 +28,9 @@
  * An EJB 2.1 local stateless bean
  *
  * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision: $
+ * @version $Revision$
  */
 @Stateless
- at Local(MyStateless21Local.class)
 @LocalHome(MyStateless21Home.class)
 public class MyStateless21Bean
 {

Modified: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/multiview/MultiviewBean.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/multiview/MultiviewBean.java	2008-05-27 06:08:09 UTC (rev 73695)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/annotation/ejb3/multiview/MultiviewBean.java	2008-05-27 07:45:27 UTC (rev 73696)
@@ -22,7 +22,6 @@
 package org.jboss.test.metadata.annotation.ejb3.multiview;
 
 import javax.ejb.Init;
-import javax.ejb.Remote;
 import javax.ejb.RemoteHome;
 import javax.ejb.Stateful;
 
@@ -33,11 +32,10 @@
  * EJB 3 4.6.2
  * 
  * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision: $
+ * @version $Revision$
  */
 @Stateful
 @RemoteHome(MultiviewHome.class)
- at Remote(Multiview21Remote.class)
 public class MultiviewBean implements Multiview3Remote
 {
    @Init

Added: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta41/MultipleReturnTypeBean.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta41/MultipleReturnTypeBean.java	                        (rev 0)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta41/MultipleReturnTypeBean.java	2008-05-27 07:45:27 UTC (rev 73696)
@@ -0,0 +1,37 @@
+/*
+ * 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.test.metadata.jbmeta41;
+
+import javax.ejb.LocalHome;
+import javax.ejb.Stateful;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+ at Stateful
+ at LocalHome(MultipleReturnTypeHome.class)
+public class MultipleReturnTypeBean
+{
+
+}
+

Added: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta41/MultipleReturnTypeHome.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta41/MultipleReturnTypeHome.java	                        (rev 0)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta41/MultipleReturnTypeHome.java	2008-05-27 07:45:27 UTC (rev 73696)
@@ -0,0 +1,40 @@
+/*
+ * 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.test.metadata.jbmeta41;
+
+import javax.ejb.EJBLocalHome;
+
+import org.jboss.test.metadata.jbmeta42.MyStateless21Local;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public interface MultipleReturnTypeHome extends EJBLocalHome 
+{
+   
+   MyStateless21Local createStateless();
+   
+   MyStateful21Local createStateful(String string);
+
+}
+

Added: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta41/MyFailingStatelessBean.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta41/MyFailingStatelessBean.java	                        (rev 0)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta41/MyFailingStatelessBean.java	2008-05-27 07:45:27 UTC (rev 73696)
@@ -0,0 +1,40 @@
+/*
+ * 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.test.metadata.jbmeta41;
+
+import javax.ejb.RemoteHome;
+import javax.ejb.Stateless;
+
+/**
+ * A broken stateless bean which refers to remotehome which has more than 
+ * one create method
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+ at Stateless
+ at RemoteHome(MyStatefulRemoteHome.class)
+public class MyFailingStatelessBean
+{
+
+}
+

Added: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta41/MyOtherFailingStateLessBean.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta41/MyOtherFailingStateLessBean.java	                        (rev 0)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta41/MyOtherFailingStateLessBean.java	2008-05-27 07:45:27 UTC (rev 73696)
@@ -0,0 +1,40 @@
+/*
+ * 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.test.metadata.jbmeta41;
+
+import javax.ejb.LocalHome;
+import javax.ejb.Stateless;
+
+/**
+ * A broken stateless bean which refers to a localHome, which returns
+ * a interface of remote interface
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+ at Stateless
+ at LocalHome(MyOtherStatelessHome.class)
+public class MyOtherFailingStateLessBean
+{
+
+}
+

Added: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta41/MyOtherStatelessHome.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta41/MyOtherStatelessHome.java	                        (rev 0)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta41/MyOtherStatelessHome.java	2008-05-27 07:45:27 UTC (rev 73696)
@@ -0,0 +1,36 @@
+/*
+ * 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.test.metadata.jbmeta41;
+
+import javax.ejb.EJBLocalHome;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public interface MyOtherStatelessHome extends EJBLocalHome
+{
+
+   MyStateful21Remote create();
+   
+}
+

Added: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta41/MyStateful21Local.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta41/MyStateful21Local.java	                        (rev 0)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta41/MyStateful21Local.java	2008-05-27 07:45:27 UTC (rev 73696)
@@ -0,0 +1,34 @@
+/*
+ * 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.test.metadata.jbmeta41;
+
+import javax.ejb.EJBLocalObject;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public interface MyStateful21Local extends EJBLocalObject
+{
+
+}
+

Added: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta41/MyStateful21Remote.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta41/MyStateful21Remote.java	                        (rev 0)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta41/MyStateful21Remote.java	2008-05-27 07:45:27 UTC (rev 73696)
@@ -0,0 +1,34 @@
+/*
+ * 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.test.metadata.jbmeta41;
+
+import javax.ejb.EJBObject;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public interface MyStateful21Remote extends EJBObject
+{
+
+}
+

Added: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta41/MyStatefulBean.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta41/MyStatefulBean.java	                        (rev 0)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta41/MyStatefulBean.java	2008-05-27 07:45:27 UTC (rev 73696)
@@ -0,0 +1,39 @@
+/*
+ * 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.test.metadata.jbmeta41;
+
+import javax.ejb.LocalHome;
+import javax.ejb.RemoteHome;
+import javax.ejb.Stateful;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+ at Stateful
+ at LocalHome(MyStatefulLocalHome.class)
+ at RemoteHome(MyStatefulRemoteHome.class)
+public class MyStatefulBean
+{
+
+}
+

Added: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta41/MyStatefulLocalHome.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta41/MyStatefulLocalHome.java	                        (rev 0)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta41/MyStatefulLocalHome.java	2008-05-27 07:45:27 UTC (rev 73696)
@@ -0,0 +1,36 @@
+/*
+ * 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.test.metadata.jbmeta41;
+
+import javax.ejb.EJBLocalHome;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public interface MyStatefulLocalHome extends EJBLocalHome
+{
+   MyStateful21Local create();
+   
+   MyStateful21Local create(String string);
+}
+

Added: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta41/MyStatefulRemoteHome.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta41/MyStatefulRemoteHome.java	                        (rev 0)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta41/MyStatefulRemoteHome.java	2008-05-27 07:45:27 UTC (rev 73696)
@@ -0,0 +1,38 @@
+/*
+ * 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.test.metadata.jbmeta41;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public interface MyStatefulRemoteHome extends javax.ejb.EJBHome
+{
+
+   MyStateful21Remote create();
+   
+   MyStateful21Remote create(String string);
+   
+   MyStateful21Remote create(String string, int integer);
+   
+}
+

Added: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta41/WrongCreateStatelessBean.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta41/WrongCreateStatelessBean.java	                        (rev 0)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta41/WrongCreateStatelessBean.java	2008-05-27 07:45:27 UTC (rev 73696)
@@ -0,0 +1,37 @@
+/*
+ * 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.test.metadata.jbmeta41;
+
+import javax.ejb.LocalHome;
+import javax.ejb.Stateless;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+ at Stateless
+ at LocalHome(WrongCreateStatelessHome.class)
+public class WrongCreateStatelessBean
+{
+
+}
+

Added: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta41/WrongCreateStatelessHome.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta41/WrongCreateStatelessHome.java	                        (rev 0)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta41/WrongCreateStatelessHome.java	2008-05-27 07:45:27 UTC (rev 73696)
@@ -0,0 +1,36 @@
+/*
+ * 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.test.metadata.jbmeta41;
+
+import javax.ejb.EJBLocalHome;
+
+/**
+ * A stateless session bean must define exactly one create method with no arguments.
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public interface WrongCreateStatelessHome extends EJBLocalHome
+{
+   MyStateful21Local create(String string);
+}
+

Added: projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta41/unit/HomeProcessingUnitTestCase.java
===================================================================
--- projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta41/unit/HomeProcessingUnitTestCase.java	                        (rev 0)
+++ projects/metadata/trunk/src/test/java/org/jboss/test/metadata/jbmeta41/unit/HomeProcessingUnitTestCase.java	2008-05-27 07:45:27 UTC (rev 73696)
@@ -0,0 +1,172 @@
+/*
+ * 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.test.metadata.jbmeta41.unit;
+
+import java.lang.reflect.AnnotatedElement;
+import java.util.Collection;
+import java.util.HashSet;
+
+import junit.framework.TestCase;
+
+import org.jboss.metadata.annotation.creator.ejb.EjbJar30Creator;
+import org.jboss.metadata.annotation.finder.AnnotationFinder;
+import org.jboss.metadata.annotation.finder.DefaultAnnotationFinder;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+import org.jboss.metadata.ejb.spec.EjbJar30MetaData;
+import org.jboss.test.metadata.common.PackageScanner;
+import org.jboss.test.metadata.jbmeta41.MultipleReturnTypeBean;
+import org.jboss.test.metadata.jbmeta41.MyFailingStatelessBean;
+import org.jboss.test.metadata.jbmeta41.MyOtherFailingStateLessBean;
+import org.jboss.test.metadata.jbmeta41.MyStateful21Local;
+import org.jboss.test.metadata.jbmeta41.MyStateful21Remote;
+import org.jboss.test.metadata.jbmeta41.MyStatefulBean;
+import org.jboss.test.metadata.jbmeta41.WrongCreateStatelessBean;
+import org.jboss.test.metadata.jbmeta42.MyStateless21Local;
+import org.jboss.test.metadata.jbmeta42.MyStateless21Remote;
+import org.jboss.test.metadata.jbmeta42.MyStatelessLocal;
+import org.jboss.test.metadata.jbmeta42.MyStatelessRemote;
+
+/**
+ * Test processing of the local and remote business interfaces of a EJB 2.x Local/Remote Home
+ * 
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class HomeProcessingUnitTestCase extends TestCase
+{
+      
+   public void testStatelessHomeandLocalHome()
+   {
+      Collection<Class<?>> classes = PackageScanner.loadClasses("org.jboss.test.metadata.jbmeta42");
+      
+      JBossSessionBeanMetaData sessionBeanMetaData = getSessionBeanMetaData(classes, "MyStatelessBean");
+      assertNotNull(sessionBeanMetaData);
+      
+      // Check if EjbHome and EjbLocalHome are defined
+      assertEquals(MyStateless21Local.class.getName(), sessionBeanMetaData.getLocal());
+      assertEquals(MyStateless21Remote.class.getName(), sessionBeanMetaData.getRemote());
+      
+      // 
+      assertTrue(sessionBeanMetaData.getBusinessLocals().contains(MyStatelessLocal.class.getName()));
+      assertFalse(sessionBeanMetaData.getBusinessLocals().contains(MyStateless21Local.class.getName()));
+      
+      assertTrue(sessionBeanMetaData.getBusinessRemotes().contains(MyStatelessRemote.class.getName()));
+      assertFalse(sessionBeanMetaData.getBusinessRemotes().contains(MyStateless21Remote.class.getName()));
+   }
+   
+   public void testStatefulHomeandLocalHome()
+   {
+      Collection<Class<?>> classes = new HashSet<Class<?>>();
+      classes.add(MyStatefulBean.class);
+      
+      JBossSessionBeanMetaData sessionBeanMetaData = getSessionBeanMetaData(classes, "MyStatefulBean");
+      assertNotNull(sessionBeanMetaData);
+      
+      //
+      assertEquals(MyStateful21Local.class.getName(), sessionBeanMetaData.getLocal());
+      assertEquals(MyStateful21Remote.class.getName(), sessionBeanMetaData.getRemote());
+   }
+   
+   // Test multiple create methods on a stateless bean 
+   public void testMyFailingStatelessBean()
+   {
+      try
+      {
+         Collection<Class<?>> classes = new HashSet<Class<?>>();
+         classes.add(MyFailingStatelessBean.class);
+         
+         getSessionBeanMetaData(classes, "MyFailingStatelessBean");
+         fail("A stateless session bean must define exactly one create method with no arguments");
+      }
+      catch(Exception e)
+      {
+         // ok
+      }
+   }
+   
+   // Test a wrong remote interface as a return type of a localHome
+   public void testMyOhterFailingStatelessBean()
+   {
+      try
+      {
+         Collection<Class<?>> classes = new HashSet<Class<?>>();
+         classes.add(MyOtherFailingStateLessBean.class);
+         
+         getSessionBeanMetaData(classes, "MyOtherFailingStateLessBean");
+         fail("The session bean’s local interface interface org.jboss.test.metadata.jbmeta41.MyStateful21Remote must extend the javax.ejb.EJBLocalObject");
+      }
+      catch(Exception e)
+      {
+         // ok
+      }
+   }
+   
+   //
+   public void testMultipleReturnTypeBean()
+   {
+      try
+      {
+         Collection<Class<?>> classes = new HashSet<Class<?>>();
+         classes.add(MultipleReturnTypeBean.class);
+         
+         getSessionBeanMetaData(classes, "MultipleReturnTypeBean");
+         fail("An EJB 2.1 view can't have multiple remote/local interfaces");
+      }
+      catch(Exception e)
+      {
+         // ok
+      }
+   }
+   
+   public void testWrongCreateStatelessBean()
+   {
+      try
+      {
+         Collection<Class<?>> classes = new HashSet<Class<?>>();
+         classes.add(WrongCreateStatelessBean.class);
+         
+         getSessionBeanMetaData(classes, "WrongCreateStatelessBean");
+         fail("A stateless session bean must define exactly one create method with no arguments.");
+      }
+      catch(Exception e)
+      {
+         // ok
+      }
+   }
+   
+   
+   private JBossSessionBeanMetaData getSessionBeanMetaData(Collection<Class<?>> classes, String enterpriseBean)
+   {
+      AnnotationFinder<AnnotatedElement> finder = new DefaultAnnotationFinder<AnnotatedElement>();
+      EjbJar30Creator creator = new EjbJar30Creator(finder);
+      EjbJar30MetaData specMetaData = creator.create(classes);
+      
+      assertEquals("3.0", specMetaData.getVersion());
+
+      JBossMetaData mergedMetaData = new JBossMetaData();
+      JBossMetaData metaData = null;
+      mergedMetaData.merge(metaData, specMetaData);
+      
+      return (JBossSessionBeanMetaData) mergedMetaData.getEnterpriseBean(enterpriseBean);
+   }
+}
\ No newline at end of file




More information about the jboss-cvs-commits mailing list