Author: kmalhi
Date: Tue Jul 27 20:56:33 2010
New Revision: 979866

URL: http://svn.apache.org/viewvc?rev=979866&view=rev
Log:
OPENEJB-470
Added validation to check that interface annotated @Local or @Remote isn't 
annotated conversely in parent interface

Modified:
    
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
    
openejb/trunk/openejb3/container/openejb-core/src/main/resources/org/apache/openejb/config/rules/Messages.properties
    
openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/rules/InvalidInterfacesTest.java

Modified: 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java?rev=979866&r1=979865&r2=979866&view=diff
==============================================================================
--- 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
 (original)
+++ 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
 Tue Jul 27 20:56:33 2010
@@ -1795,9 +1795,27 @@ public class AnnotationDeployer implemen
                     if (strict && isLocal && isRemote) {
                         validation.fail(ejbName, "ann.localRemote.conflict", 
interfce.getName());
                     } else {
-                        if (isLocal) implemented.local.add(interfce);
-                        if (isRemote) implemented.remote.add(interfce);
+                        Class[] superInterface = interfce.getInterfaces();
+                        if (isLocal) {
+                          for (Class si : superInterface) {
+                            boolean present = 
si.isAnnotationPresent(Remote.class);
+                            if(present){
+                              validation.fail(ejbName, 
"ann.remoteOrLocal.converse.parent", 
interfce.getName(),"Local",si.getName(),"Remote");
+                            }
+                          }
+                          implemented.local.add(interfce);
+                        }
+                        if (isRemote) {
+                          for (Class si : superInterface) {
+                            boolean present = 
si.isAnnotationPresent(Local.class);
+                            if(present){
+                              validation.fail(ejbName, 
"ann.remoteOrLocal.converse.parent", 
interfce.getName(),"Remote",si.getName(),"Local");
+                            }
+                          }
+                          implemented.remote.add(interfce);
+                        }
                     }
+                      
                 }
 
                 interfaces.removeAll(implemented.local);

Modified: 
openejb/trunk/openejb3/container/openejb-core/src/main/resources/org/apache/openejb/config/rules/Messages.properties
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/resources/org/apache/openejb/config/rules/Messages.properties?rev=979866&r1=979865&r2=979866&view=diff
==============================================================================
--- 
openejb/trunk/openejb3/container/openejb-core/src/main/resources/org/apache/openejb/config/rules/Messages.properties
 (original)
+++ 
openejb/trunk/openejb3/container/openejb-core/src/main/resources/org/apache/openejb/config/rules/Messages.properties
 Tue Jul 27 20:56:33 2010
@@ -344,6 +344,15 @@
 2.ann.remoteOrLocal.ejbLocalObject = @{0} used in bean class lists a 
javax.ejb.EJBLocalObject interface. Use @LocalHome with home interface of "{1}".
 3.ann.remoteOrLocal.ejbLocalObject = When applied to a bean class, the @{0} 
annotation must only list business interfaces and cannot list legacy 
EJBLocalObject interfaces.  The EJBLocalHome of interface for "{1}" can be 
annotated on the bean class with @LocalHome
 
+# fail(ejbName, "ann.remoteOrLocal.ejbLocalObject", annotationName, 
interfce.getName());
+1.ann.remoteOrLocal.converse.parent = Interface annotated @Local or @Remote is 
annotated conversely in parent interface.
+2.ann.remoteOrLocal.converse.parent = Interface annotated @Local or @Remote is 
annotated conversely in parent interface. Fix it by annotating both the 
interfaces with the same annotation
+3.ann.remoteOrLocal.converse.parent = Interface {0} is annotated with @{1} 
whereas its parent interface {2} is annotated with @{3}. Ensure that both the 
interfaces are either annotated with @{1} or @{3}. An example would be:\r\n\
+...@{1}\r\n\
+public interface {2}'{}'\r\n\
+...@{1}\r\n\
+public interface {0} extends {2}'{}'
+
 # warn(bean, "ignoredAnnotation", annotationType, beanType, className, 
methodName);
 1.ignoredAnnotation = @{0} is ignored for beans of type {1}
 2.ignoredAnnotation = @{0} is ignored for beans of type {1}.  Class: {2} 
Method: {3}

Modified: 
openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/rules/InvalidInterfacesTest.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/rules/InvalidInterfacesTest.java?rev=979866&r1=979865&r2=979866&view=diff
==============================================================================
--- 
openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/rules/InvalidInterfacesTest.java
 (original)
+++ 
openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/rules/InvalidInterfacesTest.java
 Tue Jul 27 20:56:33 2010
@@ -118,6 +118,14 @@ public class InvalidInterfacesTest {
         return ejbJar;
     
     }
+    @Keys({...@key(value="ann.remoteOrLocal.converse.parent",count=2)})
+    public EjbJar test2(){
+        EjbJar ejbJar = new EjbJar();
+        ejbJar.addEnterpriseBean(new StatelessBean(EBean.class));
+        ejbJar.addEnterpriseBean(new StatelessBean(FBean.class));
+        return ejbJar;
+    
+    }
     @After
     public void after() {
         
SystemInstance.get().setProperty("openejb.strict.interface.declaration", 
"false");
@@ -185,4 +193,14 @@ public class InvalidInterfacesTest {
         public void foo(){}
         @AroundInvoke public Object bar(){return null;}
     }
+    @Local
+    public static interface E{}
+    @Remote
+    public static interface E1 extends E{}
+    public static class EBean implements E1{}
+    @Remote
+    public static interface F{}
+    @Local
+    public static interface F1 extends F{}
+    public static class FBean implements F1{}
 }


Reply via email to