summaryrefslogtreecommitdiffstats
path: root/java/sca/modules/implementation-java
diff options
context:
space:
mode:
authorantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2009-10-16 09:53:22 +0000
committerantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2009-10-16 09:53:22 +0000
commit8e423d43c93c55fe61eac8901bfe09590dfece68 (patch)
treecb7c927432510b6ebf049e4d37a1fc0d54fd3a5b /java/sca/modules/implementation-java
parent148e65bdb1e4c79e3cad2de946be3b404699402c (diff)
Validate SCA annotations in Java impls are not on static members (JCA90002)
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@825827 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/implementation-java')
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/xml/JavaImplementationProcessor.java27
-rw-r--r--java/sca/modules/implementation-java/src/main/resources/impl-javaxml-validation-messages.properties2
2 files changed, 28 insertions, 1 deletions
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/xml/JavaImplementationProcessor.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/xml/JavaImplementationProcessor.java
index 1653e935dc..df67814bd4 100644
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/xml/JavaImplementationProcessor.java
+++ b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/xml/JavaImplementationProcessor.java
@@ -25,6 +25,7 @@ import static org.apache.tuscany.sca.implementation.java.xml.JavaImplementationC
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 @@ public class JavaImplementationProcessor implements StAXArtifactProcessor<JavaIm
return;
}
+ checkNoStaticAnnotations(monitor, javaImplementation);
+
javaImplementation.setUnresolved(false);
mergeComponentType(resolver, javaImplementation, context);
@@ -199,6 +202,30 @@ public class JavaImplementationProcessor implements StAXArtifactProcessor<JavaIm
} // 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 {
diff --git a/java/sca/modules/implementation-java/src/main/resources/impl-javaxml-validation-messages.properties b/java/sca/modules/implementation-java/src/main/resources/impl-javaxml-validation-messages.properties
index 210b715da8..337a0b8458 100644
--- a/java/sca/modules/implementation-java/src/main/resources/impl-javaxml-validation-messages.properties
+++ b/java/sca/modules/implementation-java/src/main/resources/impl-javaxml-validation-messages.properties
@@ -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}