You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by an...@apache.org on 2009/10/16 11:53:23 UTC

svn commit: r825827 - in /tuscany/java/sca/modules/implementation-java/src/main: java/org/apache/tuscany/sca/implementation/java/xml/JavaImplementationProcessor.java resources/impl-javaxml-validation-messages.properties

Author: antelder
Date: Fri Oct 16 09:53:22 2009
New Revision: 825827

URL: http://svn.apache.org/viewvc?rev=825827&view=rev
Log:
Validate SCA annotations in Java impls are not on static members (JCA90002)

Modified:
    tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/xml/JavaImplementationProcessor.java
    tuscany/java/sca/modules/implementation-java/src/main/resources/impl-javaxml-validation-messages.properties

Modified: tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/xml/JavaImplementationProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/xml/JavaImplementationProcessor.java?rev=825827&r1=825826&r2=825827&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/xml/JavaImplementationProcessor.java (original)
+++ tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/xml/JavaImplementationProcessor.java Fri Oct 16 09:53:22 2009
@@ -25,6 +25,7 @@
 import static org.apache.tuscany.sca.implementation.java.xml.JavaImplementationConstants.IMPLEMENTATION_JAVA_QNAME;
 import static org.apache.tuscany.sca.implementation.java.xml.JavaImplementationConstants.SCA11_NS;
 
+import java.lang.annotation.Annotation;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
@@ -187,6 +188,8 @@
 	            return;
 	        }
 
+	        checkNoStaticAnnotations(monitor, javaImplementation);
+	        
 	        javaImplementation.setUnresolved(false);
 	        mergeComponentType(resolver, javaImplementation, context);
 
@@ -199,6 +202,30 @@
     	} // end try
     } // end method
 
+    private void checkNoStaticAnnotations(Monitor monitor, JavaImplementation javaImplementation) {
+        if (javaImplementation.getJavaClass() != null) {
+            Class<?> clazz = javaImplementation.getJavaClass();
+            for (Method m : clazz.getMethods()) {
+                if (Modifier.isStatic(m.getModifiers())) {
+                    for (Annotation a : m.getAnnotations()) {
+                        if (a.annotationType().getName().startsWith("org.oasisopen.sca.annotation")) {
+                            error(monitor, "IllegalSCAAnnotation", javaFactory, javaImplementation.getName(), m.getName());
+                        }
+                    }
+                }
+            }
+            for (Field f : clazz.getFields()) {
+                if (Modifier.isStatic(f.getModifiers())) {
+                    for (Annotation a : f.getAnnotations()) {
+                        if (a.annotationType().getName().startsWith("org.oasisopen.sca.annotation")) {
+                            error(monitor, "IllegalSCAAnnotation", javaFactory, javaImplementation.getName(), f.getName());
+                        }
+                    }
+                }
+            }
+        }
+    }
+
     private JavaElementImpl getMemeber(JavaImplementation impl, String name, Class<?> type) {
         String setter = JavaIntrospectionHelper.toSetter(name);
         try {

Modified: tuscany/java/sca/modules/implementation-java/src/main/resources/impl-javaxml-validation-messages.properties
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-java/src/main/resources/impl-javaxml-validation-messages.properties?rev=825827&r1=825826&r2=825827&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-java/src/main/resources/impl-javaxml-validation-messages.properties (original)
+++ tuscany/java/sca/modules/implementation-java/src/main/resources/impl-javaxml-validation-messages.properties Fri Oct 16 09:53:22 2009
@@ -20,4 +20,4 @@
 #
 ClassNotFoundException = Class Not Found Exception: {0}
 ContributionResolveException = Contribution Resolve Exception occured due to: 
-
+IllegalSCAAnnotation = JCA9002 SCA annotations are not permitted on static members: {0}.{1}