diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2009-10-16 11:04:36 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2009-10-16 11:04:36 +0000 |
commit | 3873dcffd15d4f5a0b2be75de3c723e703dfadbf (patch) | |
tree | 20aff336f16113010c53fd6ad7a3ce57663da49e /java/sca/modules/implementation-java/src | |
parent | 804d7164fd6f084fea2a298534f00ab26a5e6578 (diff) |
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
Diffstat (limited to 'java/sca/modules/implementation-java/src')
2 files changed, 24 insertions, 1 deletions
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; + } } diff --git a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorProcessorTestCase.java b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorProcessorTestCase.java index 625aec4858..3674d01e24 100644 --- a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorProcessorTestCase.java +++ b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorProcessorTestCase.java @@ -127,7 +127,7 @@ public class ConstructorProcessorTestCase { private static class Foo { @org.oasisopen.sca.annotation.Constructor("foo") - public Foo(String foo) { + public Foo(@Property String foo) { } } |