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

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sun Oct 14 20:17:32 EDT 2007


Author: ALRubinger
Date: 2007-10-14 20:17:32 -0400 (Sun, 14 Oct 2007)
New Revision: 66112

Modified:
   trunk/ejb3/src/main/org/jboss/ejb3/ProxyFactoryHelper.java
Log:
EJBTHREE-1062: Ensured that checks for @Remote include those added by ejb-jar.xml metadata, not obtained directly from class annotations

Modified: trunk/ejb3/src/main/org/jboss/ejb3/ProxyFactoryHelper.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/ProxyFactoryHelper.java	2007-10-15 00:15:50 UTC (rev 66111)
+++ trunk/ejb3/src/main/org/jboss/ejb3/ProxyFactoryHelper.java	2007-10-15 00:17:32 UTC (rev 66112)
@@ -77,23 +77,25 @@
    public static Class<?>[] getLocalInterfaces(Container container)
    {
       // Obtain @Local
-      Local li = (javax.ejb.Local) ((EJBContainer) container).resolveAnnotation(javax.ejb.Local.class);
-      
+      Local localAnnotation = ((EJBContainer) container).getAnnotation(javax.ejb.Local.class);
+
+      // Obtain @Remote
+      Remote remoteAnnotation = ((EJBContainer) container).getAnnotation(Remote.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, 
       // this interface is a local business interface unless denoted otherwise
-      if (li == null && container.getBeanClass().getInterfaces().length == 1)
+      if (localAnnotation == null && container.getBeanClass().getInterfaces().length == 1)
       {
          // Obtain the implemented interface
          Class<?> singleInterface =  container.getBeanClass().getInterfaces()[0];
          
          // If not explicitly marked as @Remote, and is a valid business interface
-         if (singleInterface.getAnnotation(Remote.class) == null
-               && container.getBeanClass().getAnnotation(Remote.class) == null
+         if (remoteAnnotation==null
                && businessInterfaces.contains(singleInterface))
          {
             // Return the implemented interface  
@@ -102,17 +104,15 @@
       }
 
       // If @Local is present
-      if (li != null)
+      if (localAnnotation != null)
       {
          // If @Local.value is defined
-         if (li.value().length > 0)
+         if (localAnnotation.value().length > 0)
          {
             // Return the value array defined
-            return li.value();
+            return localAnnotation.value();
          }
-
-
-            
+  
          // If @Local is defined with no value and there are no business interfaces
          if (businessInterfaces.size() == 0){
             throw new RuntimeException("Use of empty @Local on bean class and there are no valid business interfaces: " + container.getEjbName());            
@@ -148,11 +148,8 @@
             //interface is exposed as local business if not denoted as @Remote
             else
             {
-               // Obtain the implemented interface
-               Class<?> singleInterface = container.getBeanClass().getInterfaces()[0];
                // If not explicitly marked as @Remote
-               if (singleInterface.getAnnotation(Remote.class) == null
-                     && container.getBeanClass().getAnnotation(Remote.class) == null)
+               if (remoteAnnotation == null)
                {
                   // Return the implemented interface  
                   return beanClassBusinessInterfaces.toArray(new Class<?>[]
@@ -163,20 +160,20 @@
          }
          
          Class[] rtn = {(Class) businessInterfaces.get(0)};
-         li = new LocalImpl(rtn);
-         ((EJBContainer) container).getAnnotations().addClassAnnotation(javax.ejb.Local.class, li);
+         localAnnotation = new LocalImpl(rtn);
+         ((EJBContainer) container).getAnnotations().addClassAnnotation(javax.ejb.Local.class, localAnnotation);
          return rtn;
       }
 
       Class beanClass = container.getBeanClass();
       String endpoint = getEndpointInterface(container);
-      Class[] ri = getRemoteInterfaces(container);
+      Class[] remoteInterfaces = getRemoteInterfaces(container);
 
-      if (li == null && ri.length == 0 && endpoint == null && (beanClass.getInterfaces() == null || beanClass.getInterfaces().length == 0))
+      if (localAnnotation == null && remoteInterfaces.length == 0 && endpoint == null && (beanClass.getInterfaces() == null || beanClass.getInterfaces().length == 0))
          throw new RuntimeException("bean class has no local, webservice, or remote interfaces defined and does not implement at least one business interface: " + container.getEjbName());
 
       // introspect implemented interfaces.
-      if (li == null)
+      if (localAnnotation == null)
       {
          List<Class<?>> intfs = getBusinessInterfaces(beanClass);
          ArrayList<Class> locals = new ArrayList<Class>();
@@ -189,23 +186,23 @@
          }
          if (locals.size() > 0)
          {
-            li = new LocalImpl(locals.toArray(new Class[]{}));
-            ((Advisor) container).getAnnotations().addClassAnnotation(javax.ejb.Local.class, li);
+            localAnnotation = new LocalImpl(locals.toArray(new Class[]{}));
+            ((Advisor) container).getAnnotations().addClassAnnotation(javax.ejb.Local.class, localAnnotation);
             //return li.value(); ALR Removed (EJBTHREE-751)
          }
       }
 
       // no @Local interfaces implemented
-      if (li == null)
+      if (localAnnotation == null)
       {
          // search for default
          List<Class<?>> interfaces = getBusinessInterfaces(beanClass);
          if (interfaces.size() != 1) return new Class[]{}; // indeterminate
 
          Class intf = interfaces.get(0);
-         if (ri != null)
+         if (remoteInterfaces != null)
          {
-            for (Class rintf : ri)
+            for (Class rintf : remoteInterfaces)
             {
                if (intf.getName().equals(rintf.getName()))
                {
@@ -218,17 +215,17 @@
             return new Class[]{};
 
          Class[] rtn = {intf};
-         li = new LocalImpl(rtn);
-         ((EJBContainer) container).getAnnotations().addClassAnnotation(javax.ejb.Local.class, li);
+         localAnnotation = new LocalImpl(rtn);
+         ((EJBContainer) container).getAnnotations().addClassAnnotation(javax.ejb.Local.class, localAnnotation);
          return rtn;
       }
 
 
       // Check to ensure @Local and @Remote are not defined on the same interface
       // JIRA EJBTHREE-751
-      for (Class remoteInterface : ri)
+      for (Class remoteInterface : remoteInterfaces)
       {
-         for (Class localInterface : li.value())
+         for (Class localInterface : localAnnotation.value())
          {
             if (localInterface.equals(remoteInterface))
             {
@@ -238,7 +235,7 @@
          }
       }
 
-      return li.value();
+      return localAnnotation.value();
    }
 
    /**




More information about the jboss-cvs-commits mailing list