[jboss-cvs] JBossAS SVN: r66071 - trunk/ejb3/src/main/org/jboss/ejb3.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Oct 12 01:49:42 EDT 2007


Author: ALRubinger
Date: 2007-10-12 01:49:42 -0400 (Fri, 12 Oct 2007)
New Revision: 66071

Modified:
   trunk/ejb3/src/main/org/jboss/ejb3/ProxyFactoryHelper.java
Log:
EJBTHREE-1062: Ensured that if bean class has no @Local defined and implements a single interface, that the interface is a valid business interface before exposing as implicit local business interface.

Modified: trunk/ejb3/src/main/org/jboss/ejb3/ProxyFactoryHelper.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/ProxyFactoryHelper.java	2007-10-12 05:40:54 UTC (rev 66070)
+++ trunk/ejb3/src/main/org/jboss/ejb3/ProxyFactoryHelper.java	2007-10-12 05:49:42 UTC (rev 66071)
@@ -76,8 +76,12 @@
     */
    public static Class<?>[] getLocalInterfaces(Container container)
    {
+      // Obtain @Local
       Local li = (javax.ejb.Local) ((EJBContainer) container).resolveAnnotation(javax.ejb.Local.class);
       
+      // Obtain all business interfaces
+      List<Class<?>> businessInterfaces = getBusinessInterfaces(container.getBeanClass());
+      
       // JIRA EJBTHREE-1062
       // EJB 3 4.6.6
       // If no @Local is defined on the bean class, and the bean class implements a single interface, 
@@ -87,9 +91,10 @@
          // Obtain the implemented interface
          Class<?> singleInterface =  container.getBeanClass().getInterfaces()[0];
          
-         // If not explicitly marked as @Remote
+         // If not explicitly marked as @Remote, and is a valid business interface
          if (singleInterface.getAnnotation(Remote.class) == null
-               && container.getBeanClass().getAnnotation(Remote.class) == null)
+               && container.getBeanClass().getAnnotation(Remote.class) == null
+               && businessInterfaces.contains(singleInterface))
          {
             // Return the implemented interface  
             return container.getBeanClass().getInterfaces();            
@@ -106,20 +111,19 @@
             return li.value();
          }
 
-         // Obtain all business interfaces
-         List<Class<?>> list = getBusinessInterfaces(container.getBeanClass());
+
             
          // If @Local is defined with no value and there are no business interfaces
-         if (list.size() == 0){
+         if (businessInterfaces.size() == 0){
             throw new RuntimeException("Use of empty @Local on bean class and there are no valid business interfaces: " + container.getEjbName());            
          }
          // If @Local is defined with no value and there is more than one business interface 
-         else if (list.size() > 0)
+         else if (businessInterfaces.size() > 0)
          {
             // Define list to hold all interfaces implemented directly by bean class that are valid business interfaces
             List<Class<?>> beanClassBusinessInterfaces = new ArrayList<Class<?>>();
             // All business interfaces
-            for(Class<?> businessInterface : list)
+            for(Class<?> businessInterface : businessInterfaces)
             {
                // All interfaces directly implemented by bean class
                for(Class<?> beanClassInterface : container.getBeanClass().getInterfaces())
@@ -158,7 +162,7 @@
             }
          }
          
-         Class[] rtn = {(Class) list.get(0)};
+         Class[] rtn = {(Class) businessInterfaces.get(0)};
          li = new LocalImpl(rtn);
          ((EJBContainer) container).getAnnotations().addClassAnnotation(javax.ejb.Local.class, li);
          return rtn;




More information about the jboss-cvs-commits mailing list