summaryrefslogtreecommitdiffstats
path: root/java/sca/modules/implementation-java/src
diff options
context:
space:
mode:
authorantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2009-10-15 20:53:21 +0000
committerantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2009-10-15 20:53:21 +0000
commitccb626cb08f6871d9dc3eafcfb5a3cc515f3704c (patch)
tree318eec50e7250b3c7a203042466739714f5ce811 /java/sca/modules/implementation-java/src
parent3963a10da002005bd1d32ab30f77238c310123bb (diff)
Fix JCA900011 - @Property on a constructor must not have requoired=false
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@825650 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/implementation-java/src')
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractPropertyProcessor.java5
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PropertyProcessor.java4
-rw-r--r--java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/TestAbstractPropertyProcessorTestCase.java5
3 files changed, 14 insertions, 0 deletions
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractPropertyProcessor.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractPropertyProcessor.java
index 818e9ad048..9154b10ed5 100644
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractPropertyProcessor.java
+++ b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractPropertyProcessor.java
@@ -174,6 +174,10 @@ public abstract class AbstractPropertyProcessor<A extends Annotation> extends Ba
if ("".equals(name)) {
name = parameter.getName();
}
+
+ if (!getRequired(annotation)) {
+ throw new InvalidPropertyException("JCA_90014 Constructor property must not have required=false: " + type.getName());
+ }
JavaElementImpl prop = properties.get(name);
// Setter override field
@@ -192,6 +196,7 @@ public abstract class AbstractPropertyProcessor<A extends Annotation> extends Ba
}
protected abstract String getName(A annotation);
+ protected abstract boolean getRequired(A annotation);
protected abstract void initProperty(Property property, A annotation) throws IntrospectionException;
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PropertyProcessor.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PropertyProcessor.java
index a755146997..4cbd5c013c 100644
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PropertyProcessor.java
+++ b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PropertyProcessor.java
@@ -43,4 +43,8 @@ public class PropertyProcessor extends AbstractPropertyProcessor<Property> {
property.setMustSupply(annotation.required());
}
+ @Override
+ protected boolean getRequired(Property annotation) {
+ return annotation.required();
+ }
}
diff --git a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/TestAbstractPropertyProcessorTestCase.java b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/TestAbstractPropertyProcessorTestCase.java
index 3b56d146a4..6cdc9224bf 100644
--- a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/TestAbstractPropertyProcessorTestCase.java
+++ b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/TestAbstractPropertyProcessorTestCase.java
@@ -142,6 +142,11 @@ public class TestAbstractPropertyProcessorTestCase {
protected String getName(Bar annotation) {
return "test";
}
+
+ @Override
+ protected boolean getRequired(Bar annotation) {
+ return true;
+ }
}
private static class Foo {