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

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Aug 29 03:31:12 EDT 2007


Author: ALRubinger
Date: 2007-08-29 03:31:12 -0400 (Wed, 29 Aug 2007)
New Revision: 64941

Modified:
   trunk/ejb3/src/main/org/jboss/ejb3/EJBContainer.java
Log:
EJBTHREE-1025: Added check during processing of metadata in EJB3 Deployments to ensure that @Local and @Remote do not indicate the same interface, or are both used on a bean impl without the "value" attribute set.

Modified: trunk/ejb3/src/main/org/jboss/ejb3/EJBContainer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/EJBContainer.java	2007-08-29 07:23:16 UTC (rev 64940)
+++ trunk/ejb3/src/main/org/jboss/ejb3/EJBContainer.java	2007-08-29 07:31:12 UTC (rev 64941)
@@ -41,6 +41,7 @@
 import javax.annotation.PostConstruct;
 import javax.annotation.PreDestroy;
 import javax.ejb.EJBContext;
+import javax.ejb.EJBException;
 import javax.ejb.Local;
 import javax.ejb.Remote;
 import javax.ejb.Timeout;
@@ -493,6 +494,9 @@
             }
          }
          
+         // EJBTHREE-1025
+         this.checkForDuplicateLocalAndRemoteInterfaces();
+         
          // once the metadata is setup we can resolve the business interfaces
          this.businessInterfaces = resolveBusinessInterfaces();
          
@@ -504,7 +508,47 @@
          Thread.currentThread().setContextClassLoader(old);
       }
    }
+   
+   /**
+    * Ensures that the bean does not implement any one interface as both @Local and @Remote
+    *
+    * @throws EJBException If the bean does implements any one interface as both @Local and @Remote
+    */
+   protected void checkForDuplicateLocalAndRemoteInterfaces() throws EJBException
+   {
+      // Initialize Error Message
+      String errorMessage = "Local and Remote Interfaces cannot have duplicate interface for bean " + this.getEjbName()
+            + " (EJBTHREE-1025)";
 
+      // Obtain annotations, if found
+      Local local = (Local) resolveAnnotation(Local.class);
+      Remote remote = (Remote) resolveAnnotation(Remote.class);
+
+      // If either local or remote is unspecified, return safely - there can be no overlap
+      if (local == null || remote == null)
+      {
+         return;
+      }
+
+      // Ensure "value" attribute of both local and remote are not blank
+      if (local.value().length < 1 && local.value().length < 1)
+      {
+         throw new EJBException(errorMessage);
+      }
+
+      // Iterate through local and remote interfaces, ensuring any one interface is not being used for both local and remote exposure
+      for (Class localClass : local.value())
+      {
+         for (Class remoteClass : remote.value())
+         {
+            if (localClass.equals(remoteClass))
+            {
+               throw new EJBException(errorMessage);
+            }
+         }
+      }
+   }
+
    public EnterpriseBean getXml()
    {
       return xml;




More information about the jboss-cvs-commits mailing list