[jboss-cvs] JBossAS SVN: r108646 - in projects/metadata/ejb/trunk/src: main/java/org/jboss/metadata/annotation/creator/ejb/jboss and 4 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Oct 19 06:41:43 EDT 2010


Author: jaikiran
Date: 2010-10-19 06:41:42 -0400 (Tue, 19 Oct 2010)
New Revision: 108646

Added:
   projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/EjbClassThreadLocal.java
   projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/jboss/EjbClassThreadLocal.java
   projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jbmeta305/
   projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jbmeta305/BaseBean.java
   projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jbmeta305/ChildBean.java
   projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jbmeta305/EchoLocal.java
   projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jbmeta305/EchoRemote.java
   projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jbmeta305/OtherLocal.java
   projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jbmeta305/OtherRemote.java
   projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jbmeta305/unit/
   projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jbmeta305/unit/LocalRemoteSuperClassBeanTestCase.java
Modified:
   projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/AbstractEnterpriseBeanProcessor.java
   projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/LocalProcessor.java
   projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/RemoteProcessor.java
   projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/jboss/AbstractEnterpriseBeanProcessor.java
   projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/jboss/LocalProcessor.java
   projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/jboss/RemoteProcessor.java
   projects/metadata/ejb/trunk/src/test/java/org/jboss/test/metadata/jbmeta40/unit/ImplicitLocalIntefaceUnitTestCase.java
   projects/metadata/ejb/trunk/src/test/java/org/jboss/test/metadata/jbmeta40/unit/JBossImplicitLocalIntefaceUnitTestCase.java
Log:
JBMETA-305 Do not pick up @Local and @Remote from super class(es) of bean class

Modified: projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/AbstractEnterpriseBeanProcessor.java
===================================================================
--- projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/AbstractEnterpriseBeanProcessor.java	2010-10-19 10:08:04 UTC (rev 108645)
+++ projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/AbstractEnterpriseBeanProcessor.java	2010-10-19 10:41:42 UTC (rev 108646)
@@ -24,6 +24,7 @@
 import org.jboss.metadata.annotation.creator.AbstractComponentProcessor;
 import org.jboss.metadata.annotation.creator.DeclareRolesProcessor;
 import org.jboss.metadata.annotation.creator.Processor;
+import org.jboss.metadata.annotation.creator.ejb.EjbClassThreadLocal;
 import org.jboss.metadata.annotation.finder.AnnotationFinder;
 import org.jboss.metadata.ejb.spec.*;
 import org.jboss.metadata.javaee.spec.EnvironmentRefsGroupMetaData;
@@ -79,65 +80,72 @@
       if(beanMetaData == null)
          return;
 
-      EjbNameThreadLocal.ejbName.set(beanMetaData.getEjbName());
-
-      EnvironmentRefsGroupMetaData env = (EnvironmentRefsGroupMetaData) beanMetaData.getJndiEnvironmentRefsGroup();
-      if(env == null)
+      try
       {
-         env = new EnvironmentRefsGroupMetaData();
-         beanMetaData.setJndiEnvironmentRefsGroup(env);
-      }
-      super.process(env, beanClass);
+         EjbNameThreadLocal.ejbName.set(beanMetaData.getEjbName());
+         EjbClassThreadLocal.ejbClass.set(beanClass);
 
-      
-      if(ejbJarMetaData.getEnterpriseBeans() == null)
-         ejbJarMetaData.setEnterpriseBeans(new EnterpriseBeansMetaData());
-      
-      ejbJarMetaData.getEnterpriseBeans().add(beanMetaData);
-      processClass(beanMetaData, beanClass);
-
-      AssemblyDescriptorMetaData assembly = ejbJarMetaData.getAssemblyDescriptor();
-      if(assembly == null)
-      {
-         assembly = new AssemblyDescriptorMetaData();
-         ejbJarMetaData.setAssemblyDescriptor(assembly);
+         EnvironmentRefsGroupMetaData env = (EnvironmentRefsGroupMetaData) beanMetaData.getJndiEnvironmentRefsGroup();
+         if(env == null)
+         {
+            env = new EnvironmentRefsGroupMetaData();
+            beanMetaData.setJndiEnvironmentRefsGroup(env);
+         }
+         super.process(env, beanClass);
+   
+         
+         if(ejbJarMetaData.getEnterpriseBeans() == null)
+            ejbJarMetaData.setEnterpriseBeans(new EnterpriseBeansMetaData());
+         
+         ejbJarMetaData.getEnterpriseBeans().add(beanMetaData);
+         processClass(beanMetaData, beanClass);
+   
+         AssemblyDescriptorMetaData assembly = ejbJarMetaData.getAssemblyDescriptor();
+         if(assembly == null)
+         {
+            assembly = new AssemblyDescriptorMetaData();
+            ejbJarMetaData.setAssemblyDescriptor(assembly);
+         }
+         // @DeclareRoles
+         SecurityRolesMetaData securityRoles = assembly.getSecurityRoles();
+         if(securityRoles == null)
+         {
+            securityRoles = new SecurityRolesMetaData();
+            assembly.setSecurityRoles(securityRoles);
+         }
+         super.processClass(securityRoles, beanClass);
+         // @DenyAll
+         ExcludeListMetaData excludes = assembly.getExcludeList();
+         if(excludes == null)
+         {
+            excludes = new ExcludeListMetaData();
+            assembly.setExcludeList(excludes);
+         }
+         super.processClass(excludes, beanClass);
+   
+         // @RolesAllowed, @PermitAll
+         MethodPermissionsMetaData permissions = assembly.getMethodPermissions();
+         if(permissions == null)
+         {
+            permissions = new MethodPermissionsMetaData();
+            assembly.setMethodPermissions(permissions);
+         }
+         super.processClass(permissions, beanClass);
+   
+         // @Interceptors
+         InterceptorBindingsMetaData interceptors = assembly.getInterceptorBindings();
+         if(interceptors == null)
+         {
+            interceptors = new InterceptorBindingsMetaData();
+            assembly.setInterceptorBindings(interceptors);
+         }
+         super.processClass(interceptors, beanClass);
       }
-      // @DeclareRoles
-      SecurityRolesMetaData securityRoles = assembly.getSecurityRoles();
-      if(securityRoles == null)
+      finally
       {
-         securityRoles = new SecurityRolesMetaData();
-         assembly.setSecurityRoles(securityRoles);
+         EjbNameThreadLocal.ejbName.set(null);
+         EjbClassThreadLocal.ejbClass.set(null);
       }
-      super.processClass(securityRoles, beanClass);
-      // @DenyAll
-      ExcludeListMetaData excludes = assembly.getExcludeList();
-      if(excludes == null)
-      {
-         excludes = new ExcludeListMetaData();
-         assembly.setExcludeList(excludes);
-      }
-      super.processClass(excludes, beanClass);
-
-      // @RolesAllowed, @PermitAll
-      MethodPermissionsMetaData permissions = assembly.getMethodPermissions();
-      if(permissions == null)
-      {
-         permissions = new MethodPermissionsMetaData();
-         assembly.setMethodPermissions(permissions);
-      }
-      super.processClass(permissions, beanClass);
-
-      // @Interceptors
-      InterceptorBindingsMetaData interceptors = assembly.getInterceptorBindings();
-      if(interceptors == null)
-      {
-         interceptors = new InterceptorBindingsMetaData();
-         assembly.setInterceptorBindings(interceptors);
-      }
-      super.processClass(interceptors, beanClass);
-
-      EjbNameThreadLocal.ejbName.set(null);
    }
    
    /**

Added: projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/EjbClassThreadLocal.java
===================================================================
--- projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/EjbClassThreadLocal.java	                        (rev 0)
+++ projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/EjbClassThreadLocal.java	2010-10-19 10:41:42 UTC (rev 108646)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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;
+
+/**
+ * Holds the EJB class currently being processed by the metadata processors
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+class EjbClassThreadLocal
+{
+   static ThreadLocal<Class<?>> ejbClass = new ThreadLocal<Class<?>>();
+}

Modified: projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/LocalProcessor.java
===================================================================
--- projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/LocalProcessor.java	2010-10-19 10:08:04 UTC (rev 108645)
+++ projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/LocalProcessor.java	2010-10-19 10:41:42 UTC (rev 108646)
@@ -31,6 +31,7 @@
 import org.jboss.metadata.annotation.creator.AbstractFinderUser;
 import org.jboss.metadata.annotation.creator.Processor;
 import org.jboss.metadata.annotation.creator.ProcessorUtils;
+import org.jboss.metadata.annotation.creator.ejb.EjbClassThreadLocal;
 import org.jboss.metadata.annotation.finder.AnnotationFinder;
 import org.jboss.metadata.ejb.spec.BusinessLocalsMetaData;
 import org.jboss.metadata.ejb.spec.SessionBeanMetaData;
@@ -71,11 +72,17 @@
       if(local == null)
          return;
       
+      Class<?> beanClass = EjbClassThreadLocal.ejbClass.get();
+      
       if(type.isInterface())
       {
-         addBusinessInterface(metaData, type);
+         // make sure it's a directly implemented interface
+         if (beanClass != null && this.isDirectlyImplementedInterface(beanClass, type))
+         {
+            addBusinessInterface(metaData, type);
+         }
       }
-      else
+      else if (type.getName().equals(metaData.getEjbClass())) // we ignore super classes and pick up @Local only from the bean class
       {
          if(local.value() == null || local.value().length == 0)
          {
@@ -96,4 +103,31 @@
    {
       return ProcessorUtils.createAnnotationSet(Local.class);
    }
+   
+   /**
+    * Returns true if the passed interface <code>intf</code> is in the implements 
+    * clause of the <code>beanClass</code> or if the <code>intf</code> is a superinterface
+    * of one of the interfaces in the implements clause of the <code>beanClass</code>.
+    * 
+    * Returns false otherwise
+    * @param beanClass The EJB class
+    * @param intf The interface being checked
+    * @return
+    */
+   private boolean isDirectlyImplementedInterface(Class<?> beanClass, Class<?> intf)
+   {
+      if (!intf.isInterface())
+      {
+         throw new IllegalArgumentException(intf + " is not an interface");
+      }
+      Class<?>[] directlyImplementedInterfaces = beanClass.getInterfaces();
+      for (Class<?> directlyImplementedInterface : directlyImplementedInterfaces)
+      {
+         if (intf.isAssignableFrom(directlyImplementedInterface))
+         {
+            return true;
+         }
+      }
+      return false;
+   }
 }

Modified: projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/RemoteProcessor.java
===================================================================
--- projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/RemoteProcessor.java	2010-10-19 10:08:04 UTC (rev 108645)
+++ projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/RemoteProcessor.java	2010-10-19 10:41:42 UTC (rev 108646)
@@ -31,6 +31,7 @@
 import org.jboss.metadata.annotation.creator.AbstractFinderUser;
 import org.jboss.metadata.annotation.creator.Processor;
 import org.jboss.metadata.annotation.creator.ProcessorUtils;
+import org.jboss.metadata.annotation.creator.ejb.EjbClassThreadLocal;
 import org.jboss.metadata.annotation.finder.AnnotationFinder;
 import org.jboss.metadata.ejb.spec.BusinessRemotesMetaData;
 import org.jboss.metadata.ejb.spec.SessionBeanMetaData;
@@ -71,11 +72,17 @@
       if(remote == null)
          return;
       
+      Class<?> beanClass = EjbClassThreadLocal.ejbClass.get();
+      
       if(type.isInterface())
       {
-         addBusinessInterface(metaData, type);
+         // make sure it's a directly implemented interface
+         if (beanClass != null && this.isDirectlyImplementedInterface(beanClass, type))
+         {
+            addBusinessInterface(metaData, type);
+         }
       }
-      else
+      else if (type.getName().equals(metaData.getEjbClass())) // we ignore super classes and pick up @Remote only from the bean class
       {
          if(remote.value() == null || remote.value().length == 0)
          {
@@ -96,4 +103,31 @@
    {
       return ProcessorUtils.createAnnotationSet(Remote.class);
    }
+   
+   /**
+    * Returns true if the passed interface <code>intf</code> is in the implements 
+    * clause of the <code>beanClass</code> or if the <code>intf</code> is a superinterface
+    * of one of the interfaces in the implements clause of the <code>beanClass</code>.
+    * 
+    * Returns false otherwise
+    * @param beanClass The EJB class
+    * @param intf The interface being checked
+    * @return
+    */
+   private boolean isDirectlyImplementedInterface(Class<?> beanClass, Class<?> intf)
+   {
+      if (!intf.isInterface())
+      {
+         throw new IllegalArgumentException(intf + " is not an interface");
+      }
+      Class<?>[] directlyImplementedInterfaces = beanClass.getInterfaces();
+      for (Class<?> directlyImplementedInterface : directlyImplementedInterfaces)
+      {
+         if (intf.isAssignableFrom(directlyImplementedInterface))
+         {
+            return true;
+         }
+      }
+      return false;
+   }
 }

Modified: projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/jboss/AbstractEnterpriseBeanProcessor.java
===================================================================
--- projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/jboss/AbstractEnterpriseBeanProcessor.java	2010-10-19 10:08:04 UTC (rev 108645)
+++ projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/jboss/AbstractEnterpriseBeanProcessor.java	2010-10-19 10:41:42 UTC (rev 108646)
@@ -94,10 +94,13 @@
     */
    public void process(JBossMetaData ejbJarMetaData, JBossEnterpriseBeanMetaData beanMetaData, Class<?> beanClass)
    {
-      EjbNameThreadLocal.ejbName.set(beanMetaData.getEjbName());
+      
 
       try
       {
+         EjbNameThreadLocal.ejbName.set(beanMetaData.getEjbName());
+         EjbClassThreadLocal.ejbClass.set(beanClass);
+         
          JBossEnvironmentRefsGroupMetaData env = (JBossEnvironmentRefsGroupMetaData) beanMetaData.getJndiEnvironmentRefsGroup();
          if(env == null)
          {
@@ -158,6 +161,7 @@
       finally
       {
          EjbNameThreadLocal.ejbName.set(null);
+         EjbClassThreadLocal.ejbClass.set(null);
       }
    }
    

Added: projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/jboss/EjbClassThreadLocal.java
===================================================================
--- projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/jboss/EjbClassThreadLocal.java	                        (rev 0)
+++ projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/jboss/EjbClassThreadLocal.java	2010-10-19 10:41:42 UTC (rev 108646)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.jboss;
+
+/**
+ * Holds the EJB class currently being processed by the metadata processors
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+class EjbClassThreadLocal
+{
+   static ThreadLocal<Class<?>> ejbClass = new ThreadLocal<Class<?>>();
+}

Modified: projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/jboss/LocalProcessor.java
===================================================================
--- projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/jboss/LocalProcessor.java	2010-10-19 10:08:04 UTC (rev 108645)
+++ projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/jboss/LocalProcessor.java	2010-10-19 10:41:42 UTC (rev 108646)
@@ -70,12 +70,18 @@
       Local local = finder.getAnnotation(type, Local.class);
       if(local == null)
          return;
-      
+
+      Class<?> beanClass = EjbClassThreadLocal.ejbClass.get();
+
       if(type.isInterface())
       {
-         addBusinessInterface(metaData, type);
+         // make sure it's a directly implemented interface
+         if (beanClass != null && this.isDirectlyImplementedInterface(beanClass, type))
+         {
+            addBusinessInterface(metaData, type);
+         }
       }
-      else
+      else if (type.getName().equals(metaData.getEjbClass())) // we ignore super classes and pick up @Local only from the bean class 
       {
          if(local.value() == null || local.value().length == 0)
          {
@@ -96,4 +102,31 @@
    {
       return ProcessorUtils.createAnnotationSet(Local.class);
    }
+   
+   /**
+    * Returns true if the passed interface <code>intf</code> is in the implements 
+    * clause of the <code>beanClass</code> or if the <code>intf</code> is a superinterface
+    * of one of the interfaces in the implements clause of the <code>beanClass</code>.
+    * 
+    * Returns false otherwise
+    * @param beanClass The EJB class
+    * @param intf The interface being checked
+    * @return
+    */
+   private boolean isDirectlyImplementedInterface(Class<?> beanClass, Class<?> intf)
+   {
+      if (!intf.isInterface())
+      {
+         throw new IllegalArgumentException(intf + " is not an interface");
+      }
+      Class<?>[] directlyImplementedInterfaces = beanClass.getInterfaces();
+      for (Class<?> directlyImplementedInterface : directlyImplementedInterfaces)
+      {
+         if (intf.isAssignableFrom(directlyImplementedInterface))
+         {
+            return true;
+         }
+      }
+      return false;
+   }
 }

Modified: projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/jboss/RemoteProcessor.java
===================================================================
--- projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/jboss/RemoteProcessor.java	2010-10-19 10:08:04 UTC (rev 108645)
+++ projects/metadata/ejb/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/jboss/RemoteProcessor.java	2010-10-19 10:41:42 UTC (rev 108646)
@@ -31,6 +31,7 @@
 import org.jboss.metadata.annotation.creator.AbstractFinderUser;
 import org.jboss.metadata.annotation.creator.Processor;
 import org.jboss.metadata.annotation.creator.ProcessorUtils;
+import org.jboss.metadata.annotation.creator.ejb.jboss.EjbClassThreadLocal;
 import org.jboss.metadata.annotation.finder.AnnotationFinder;
 import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
 import org.jboss.metadata.ejb.spec.BusinessRemotesMetaData;
@@ -71,11 +72,17 @@
       if(remote == null)
          return;
       
+      Class<?> beanClass = EjbClassThreadLocal.ejbClass.get();
+      
       if(type.isInterface())
       {
-         addBusinessInterface(metaData, type);
+         // make sure it's a directly implemented interface
+         if (beanClass != null && this.isDirectlyImplementedInterface(beanClass, type))
+         {
+            addBusinessInterface(metaData, type);
+         }
       }
-      else
+      else if (type.getName().equals(metaData.getEjbClass())) // we ignore super classes and pick up @Local only from the bean class
       {
          if(remote.value() == null || remote.value().length == 0)
          {
@@ -96,4 +103,31 @@
    {
       return ProcessorUtils.createAnnotationSet(Remote.class);
    }
+   
+   /**
+    * Returns true if the passed interface <code>intf</code> is in the implements 
+    * clause of the <code>beanClass</code> or if the <code>intf</code> is a superinterface
+    * of one of the interfaces in the implements clause of the <code>beanClass</code>.
+    * 
+    * Returns false otherwise
+    * @param beanClass The EJB class
+    * @param intf The interface being checked
+    * @return
+    */
+   private boolean isDirectlyImplementedInterface(Class<?> beanClass, Class<?> intf)
+   {
+      if (!intf.isInterface())
+      {
+         throw new IllegalArgumentException(intf + " is not an interface");
+      }
+      Class<?>[] directlyImplementedInterfaces = beanClass.getInterfaces();
+      for (Class<?> directlyImplementedInterface : directlyImplementedInterfaces)
+      {
+         if (intf.isAssignableFrom(directlyImplementedInterface))
+         {
+            return true;
+         }
+      }
+      return false;
+   }
 }

Added: projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jbmeta305/BaseBean.java
===================================================================
--- projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jbmeta305/BaseBean.java	                        (rev 0)
+++ projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jbmeta305/BaseBean.java	2010-10-19 10:41:42 UTC (rev 108646)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.ejb.test.jbmeta305;
+
+import javax.ejb.Stateless;
+
+/**
+ * BaseBean
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+ at Stateless
+public class BaseBean implements OtherLocal, OtherRemote
+{
+
+}

Added: projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jbmeta305/ChildBean.java
===================================================================
--- projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jbmeta305/ChildBean.java	                        (rev 0)
+++ projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jbmeta305/ChildBean.java	2010-10-19 10:41:42 UTC (rev 108646)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.ejb.test.jbmeta305;
+
+import javax.ejb.Stateless;
+
+/**
+ * BeanOne
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+ at Stateless
+public class ChildBean extends BaseBean implements EchoLocal, EchoRemote
+{
+
+}

Added: projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jbmeta305/EchoLocal.java
===================================================================
--- projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jbmeta305/EchoLocal.java	                        (rev 0)
+++ projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jbmeta305/EchoLocal.java	2010-10-19 10:41:42 UTC (rev 108646)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.ejb.test.jbmeta305;
+
+import javax.ejb.Local;
+
+/**
+ * Echo
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+ at Local
+public interface EchoLocal
+{
+
+}

Added: projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jbmeta305/EchoRemote.java
===================================================================
--- projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jbmeta305/EchoRemote.java	                        (rev 0)
+++ projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jbmeta305/EchoRemote.java	2010-10-19 10:41:42 UTC (rev 108646)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.ejb.test.jbmeta305;
+
+import javax.ejb.Remote;
+
+/**
+ * EchoRemote
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+ at Remote
+public interface EchoRemote
+{
+
+}

Added: projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jbmeta305/OtherLocal.java
===================================================================
--- projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jbmeta305/OtherLocal.java	                        (rev 0)
+++ projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jbmeta305/OtherLocal.java	2010-10-19 10:41:42 UTC (rev 108646)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.ejb.test.jbmeta305;
+
+import javax.ejb.Local;
+
+/**
+ * OtherInterface
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+ at Local
+public interface OtherLocal
+{
+
+}

Added: projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jbmeta305/OtherRemote.java
===================================================================
--- projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jbmeta305/OtherRemote.java	                        (rev 0)
+++ projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jbmeta305/OtherRemote.java	2010-10-19 10:41:42 UTC (rev 108646)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.ejb.test.jbmeta305;
+
+import javax.ejb.Remote;
+
+/**
+ * OtherRemote
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+ at Remote
+public interface OtherRemote
+{
+
+}

Added: projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jbmeta305/unit/LocalRemoteSuperClassBeanTestCase.java
===================================================================
--- projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jbmeta305/unit/LocalRemoteSuperClassBeanTestCase.java	                        (rev 0)
+++ projects/metadata/ejb/trunk/src/test/java/org/jboss/metadata/ejb/test/jbmeta305/unit/LocalRemoteSuperClassBeanTestCase.java	2010-10-19 10:41:42 UTC (rev 108646)
@@ -0,0 +1,126 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.ejb.test.jbmeta305.unit;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.lang.reflect.AnnotatedElement;
+import java.util.Collection;
+
+import javax.ejb.Local;
+import javax.ejb.Remote;
+
+import junit.framework.Assert;
+
+import org.jboss.metadata.annotation.creator.ejb.jboss.JBoss50Creator;
+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.BusinessLocalsMetaData;
+import org.jboss.metadata.ejb.spec.BusinessRemotesMetaData;
+import org.jboss.metadata.ejb.test.jbmeta305.ChildBean;
+import org.jboss.metadata.ejb.test.jbmeta305.EchoLocal;
+import org.jboss.metadata.ejb.test.jbmeta305.EchoRemote;
+import org.jboss.metadata.ejb.test.jbmeta305.OtherLocal;
+import org.jboss.metadata.ejb.test.jbmeta305.OtherRemote;
+import org.jboss.test.metadata.common.PackageScanner;
+import org.jboss.test.metadata.common.ScanPackage;
+import org.junit.Test;
+
+/**
+ * Tests that the annotation processors for EJBs do not pick up {@link Local} and {@link Remote}
+ * interfaces from the bean's super class(es).
+ * 
+ * @see https://jira.jboss.org/browse/JBMETA-305
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class LocalRemoteSuperClassBeanTestCase
+{
+
+   /**
+    * Test that the {@link Local} annotation metadata processor doesn't pick up 
+    * the {@link Local} annotation from bean's super class(es)
+    * 
+    * @throws Exception
+    */
+   @Test
+   @ScanPackage("org.jboss.metadata.ejb.test.jbmeta305")
+   public void testLocalBusinessInterface() throws Exception
+   {
+      AnnotationFinder<AnnotatedElement> finder = new DefaultAnnotationFinder<AnnotatedElement>();
+      JBoss50Creator creator = new JBoss50Creator(finder);
+      Collection<Class<?>> classes = PackageScanner.loadClasses();
+      JBossMetaData metaData = creator.create(classes);
+      assertNotNull("Metadata created for bean was null", metaData);
+
+      JBossSessionBeanMetaData childBean = (JBossSessionBeanMetaData) metaData.getEnterpriseBean(ChildBean.class
+            .getSimpleName());
+      Assert.assertNotNull("Session bean metadata was null", childBean);
+
+      // test business locals
+      BusinessLocalsMetaData businessLocals = childBean.getBusinessLocals();
+      Assert.assertNotNull("Business interfaces of " + childBean.getEjbName() + " bean was null", businessLocals);
+      Assert.assertEquals("Unexpected number of business locals for " + childBean.getEjbName() + " bean", 1,
+            businessLocals.size());
+      Assert.assertTrue(EchoLocal.class.getName() + " was expected to be a business local view for "
+            + childBean.getEjbName() + " bean", businessLocals.contains(EchoLocal.class.getName()));
+
+      Assert.assertFalse(OtherLocal.class.getName() + " was *not* expected to be a business local view for "
+            + childBean.getEjbName() + " bean", businessLocals.contains(OtherLocal.class.getName()));
+
+   }
+
+   /**
+    * Test that the {@link Remote} annotation metadata processor doesn't pick up 
+    * the {@link Remote} annotation from bean's super class(es)
+    * 
+    * @throws Exception
+    */
+   @Test
+   @ScanPackage("org.jboss.metadata.ejb.test.jbmeta305")
+   public void testRemoteBusinessInterface() throws Exception
+   {
+      AnnotationFinder<AnnotatedElement> finder = new DefaultAnnotationFinder<AnnotatedElement>();
+      JBoss50Creator creator = new JBoss50Creator(finder);
+      Collection<Class<?>> classes = PackageScanner.loadClasses();
+      JBossMetaData metaData = creator.create(classes);
+      assertNotNull("Metadata created for bean was null", metaData);
+
+      JBossSessionBeanMetaData childBean = (JBossSessionBeanMetaData) metaData.getEnterpriseBean(ChildBean.class
+            .getSimpleName());
+      Assert.assertNotNull("Session bean metadata was null", childBean);
+
+      // test business remotes
+      BusinessRemotesMetaData businessRemotes = childBean.getBusinessRemotes();
+      Assert.assertNotNull("Business interfaces of " + childBean.getEjbName() + " bean was null", businessRemotes);
+      Assert.assertEquals("Unexpected number of business remotes for " + childBean.getEjbName() + " bean", 1,
+            businessRemotes.size());
+      Assert.assertTrue(EchoRemote.class.getName() + " was expected to be a business remote view for "
+            + childBean.getEjbName() + " bean", businessRemotes.contains(EchoRemote.class.getName()));
+      Assert.assertFalse(OtherRemote.class.getName() + " was *not* expected to be a business remote view for "
+            + childBean.getEjbName() + " bean", businessRemotes.contains(OtherRemote.class.getName()));
+
+   }
+}

Modified: projects/metadata/ejb/trunk/src/test/java/org/jboss/test/metadata/jbmeta40/unit/ImplicitLocalIntefaceUnitTestCase.java
===================================================================
--- projects/metadata/ejb/trunk/src/test/java/org/jboss/test/metadata/jbmeta40/unit/ImplicitLocalIntefaceUnitTestCase.java	2010-10-19 10:08:04 UTC (rev 108645)
+++ projects/metadata/ejb/trunk/src/test/java/org/jboss/test/metadata/jbmeta40/unit/ImplicitLocalIntefaceUnitTestCase.java	2010-10-19 10:41:42 UTC (rev 108646)
@@ -36,7 +36,6 @@
 import org.jboss.test.metadata.common.ScanPackage;
 import org.jboss.test.metadata.jbmeta40.ExpectedLocalInterface;
 import org.jboss.test.metadata.jbmeta40.OtherInterface;
-import org.jboss.test.metadata.jbmeta40.RemoteInterface;
 
 /**
  * Test implicit home interfaces (Ejb30Creator)
@@ -106,8 +105,6 @@
       assertNotNull(sb.getBusinessLocals());
       assertTrue(sb.getBusinessLocals().contains(ExpectedLocalInterface.class.getName()));
       assertFalse(sb.getBusinessLocals().contains(OtherInterface.class.getName()));
-      assertNotNull(sb.getBusinessRemotes());
-      assertTrue(sb.getBusinessRemotes().contains(RemoteInterface.class.getName()));
    }
 }
 

Modified: projects/metadata/ejb/trunk/src/test/java/org/jboss/test/metadata/jbmeta40/unit/JBossImplicitLocalIntefaceUnitTestCase.java
===================================================================
--- projects/metadata/ejb/trunk/src/test/java/org/jboss/test/metadata/jbmeta40/unit/JBossImplicitLocalIntefaceUnitTestCase.java	2010-10-19 10:08:04 UTC (rev 108645)
+++ projects/metadata/ejb/trunk/src/test/java/org/jboss/test/metadata/jbmeta40/unit/JBossImplicitLocalIntefaceUnitTestCase.java	2010-10-19 10:41:42 UTC (rev 108646)
@@ -116,8 +116,6 @@
       assertNotNull(sb.getBusinessLocals());
       assertTrue(sb.getBusinessLocals().contains(ExpectedLocalInterface.class.getName()));
       assertFalse(sb.getBusinessLocals().contains(OtherInterface.class.getName()));
-      assertNotNull(sb.getBusinessRemotes());
-      assertTrue(sb.getBusinessRemotes().contains(RemoteInterface.class.getName()));
    }
 }
 



More information about the jboss-cvs-commits mailing list