From 8e423d43c93c55fe61eac8901bfe09590dfece68 Mon Sep 17 00:00:00 2001 From: antelder Date: Fri, 16 Oct 2009 09:53:22 +0000 Subject: 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 --- .../java/xml/JavaImplementationProcessor.java | 27 ++++++++++++++++++++++ .../impl-javaxml-validation-messages.properties | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) (limited to 'java/sca/modules/implementation-java') 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 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} -- cgit v1.2.3