From 3873dcffd15d4f5a0b2be75de3c723e703dfadbf Mon Sep 17 00:00:00 2001 From: antelder Date: Fri, 16 Oct 2009 11:04:36 +0000 Subject: Fixes for JCA90003 - constructor args need to be annotated git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@825841 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/introspect/impl/ConstructorProcessor.java | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'java/sca/modules/implementation-java/src/main') diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorProcessor.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorProcessor.java index b49dbb5fe7..2d5470c08c 100644 --- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorProcessor.java +++ b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorProcessor.java @@ -26,6 +26,8 @@ import org.apache.tuscany.sca.implementation.java.JavaConstructorImpl; import org.apache.tuscany.sca.implementation.java.JavaImplementation; import org.apache.tuscany.sca.implementation.java.JavaParameterImpl; import org.apache.tuscany.sca.implementation.java.introspect.BaseJavaClassVisitor; +import org.oasisopen.sca.annotation.Property; +import org.oasisopen.sca.annotation.Reference; /** * Handles processing of a constructor decorated with @@ -76,9 +78,30 @@ public class ConstructorProcessor extends BaseJavaClassVisitor { if (!isDefault && value.length != parameters.length) { throw new InvalidConstructorException("Invalid Number of names in @Constructor"); } + + for (JavaParameterImpl p : parameters) { + if (!hasAnnotation(p)) { + throw new InvalidConstructorException("JCA90003 constructor parameters must have @Property or @Reference annotation"); + } + } + for (int i = 0; i < parameters.length; i++) { parameters[i].setName(i < value.length ? value[i] : ""); } type.setConstructor(definition); } + + private boolean hasAnnotation(JavaParameterImpl p) { + if (p.getAnnotations() != null && p.getAnnotations().length > 0) { + return true; + } +// TODO: need to verify JCA90003 as it seems like any annotation should be ok not just SCA ref or prop +// if (p.getAnnotation(Reference.class) != null) { +// return true; +// } +// if (p.getAnnotation(Property.class) != null) { +// return true; +// } + return false; + } } -- cgit v1.2.3