summaryrefslogtreecommitdiffstats
path: root/java/sca/modules/assembly-xml
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2008-11-05 21:54:45 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2008-11-05 21:54:45 +0000
commit763f57649fbcd29c9e38f13e395ad0969ade989e (patch)
treeeaa415f8fe3607d5df4d9af46b38bfe0d628f0e9 /java/sca/modules/assembly-xml
parent4bfc6d6a1d69cfb0fc38546c29af565c8205e681 (diff)
Fix for TUSCANY-2662
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@711710 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/assembly-xml')
-rw-r--r--java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java21
-rw-r--r--java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeProcessor.java1
-rw-r--r--java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java2
-rw-r--r--java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConstrainingTypeProcessor.java3
-rw-r--r--java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/AnyElementReadWriteTestCase.java3
-rw-r--r--java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Calculator.composite2
-rw-r--r--java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorComponent.constrainingType4
-rw-r--r--java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorImpl.componentType6
8 files changed, 33 insertions, 9 deletions
diff --git a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java
index 06b208540a..80c5e807fe 100644
--- a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java
+++ b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java
@@ -249,8 +249,29 @@ abstract class BaseAssemblyProcessor extends BaseStAXArtifactProcessor implement
reference.setMultiplicity(Multiplicity.ONE_N);
} else if (ZERO_N.equals(value)) {
reference.setMultiplicity(Multiplicity.ZERO_N);
+ } else if (ONE_ONE.equals(value)) {
+ reference.setMultiplicity(Multiplicity.ONE_ONE);
}
}
+
+ protected XAttr writeMultiplicity(AbstractReference reference) {
+ Multiplicity multiplicity = reference.getMultiplicity();
+ if (multiplicity != null) {
+ String value = null;
+ if (Multiplicity.ZERO_ONE.equals(multiplicity)) {
+ value = ZERO_ONE;
+ } else if (Multiplicity.ONE_N.equals(multiplicity)) {
+ value = ONE_N;
+ } else if (Multiplicity.ZERO_N.equals(multiplicity)) {
+ value = ZERO_N;
+ } else if (Multiplicity.ONE_ONE.equals(multiplicity)) {
+ value = ONE_ONE;
+ return null;
+ }
+ return new XAttr(MULTIPLICITY, value);
+ }
+ return null;
+ }
/**
* Returns the value of a constrainingType attribute.
diff --git a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeProcessor.java b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeProcessor.java
index 3da39732e9..07e1507449 100644
--- a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeProcessor.java
+++ b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeProcessor.java
@@ -278,6 +278,7 @@ public class ComponentTypeProcessor extends BaseAssemblyProcessor implements StA
writeStart(writer, REFERENCE,
new XAttr(NAME, reference.getName()),
+ writeMultiplicity(reference),
writeTargets(reference),
policyProcessor.writePolicies(reference));
diff --git a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java
index b55e4f5fb8..5aae007739 100644
--- a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java
+++ b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java
@@ -743,6 +743,7 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt
for (ComponentReference reference : component.getReferences()) {
writeStart(writer, REFERENCE, new XAttr(NAME, reference.getName()),
new XAttr(AUTOWIRE, reference.getAutowire()),
+ writeMultiplicity(reference),
writeTargets(reference),
policyProcessor.writePolicies(reference));
@@ -829,6 +830,7 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt
// Write <reference> element
writeStart(writer, REFERENCE, new XAttr(NAME, reference.getName()),
new XAttr(PROMOTE, promote),
+ writeMultiplicity(reference),
policyProcessor.writePolicies(reference));
//write extended attributes
diff --git a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConstrainingTypeProcessor.java b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConstrainingTypeProcessor.java
index 35a1c553b2..7b0751437a 100644
--- a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConstrainingTypeProcessor.java
+++ b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConstrainingTypeProcessor.java
@@ -42,8 +42,8 @@ import org.apache.tuscany.sca.contribution.service.ContributionWriteException;
import org.apache.tuscany.sca.interfacedef.InterfaceContract;
import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.interfacedef.impl.OperationImpl;
-import org.apache.tuscany.sca.policy.PolicyFactory;
import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.policy.PolicyFactory;
import org.w3c.dom.Document;
/**
@@ -214,6 +214,7 @@ public class ConstrainingTypeProcessor extends BaseAssemblyProcessor implements
// Write <reference> elements
for (AbstractReference reference : constrainingType.getReferences()) {
writeStart(writer, REFERENCE, new XAttr(NAME, reference.getName()),
+ writeMultiplicity(reference),
policyProcessor.writePolicies(reference));
extensionProcessor.write(reference.getInterfaceContract(), writer);
diff --git a/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/AnyElementReadWriteTestCase.java b/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/AnyElementReadWriteTestCase.java
index 774fc45703..abf0269c0f 100644
--- a/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/AnyElementReadWriteTestCase.java
+++ b/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/AnyElementReadWriteTestCase.java
@@ -34,13 +34,12 @@ import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtens
import org.apache.tuscany.sca.contribution.processor.ValidatingXMLInputFactory;
import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.junit.Ignore;
import org.junit.Test;
public class AnyElementReadWriteTestCase extends TestCase {
private XMLInputFactory inputFactory;
- String XML = "<?xml version='1.0' encoding='UTF-8'?><composite xmlns=\"http://www.osoa.org/xmlns/sca/1.0\" xmlns:ns1=\"http://www.osoa.org/xmlns/sca/1.0\" targetNamespace=\"http://calc\" name=\"Calculator\"><service name=\"CalculatorService\" promote=\"CalculatorServiceComponent\"><interface.java interface=\"calculator.CalculatorService\" /></service><component name=\"CalculatorServiceComponent\"><reference name=\"addService\" target=\"AddServiceComponent\" /><reference name=\"subtractService\" target=\"SubtractServiceComponent\" /><reference name=\"multiplyService\" target=\"MultiplyServiceComponent\" /><reference name=\"divideService\" target=\"DivideServiceComponent\" /></component><component name=\"AddServiceComponent\" /><component name=\"SubtractServiceComponent\" /><component name=\"MultiplyServiceComponent\" /><component name=\"DivideServiceComponent\" /><x:unknownElement xmlns:x=\"http://x\" uknAttr=\"attribute1\"><y:subUnknownElement1 xmlns:y=\"http://y\" uknAttr1=\"attribute2\" /><x:subUnknownElement2 /></x:unknownElement></composite>";
+ String XML = "<?xml version='1.0' encoding='UTF-8'?><composite xmlns=\"http://www.osoa.org/xmlns/sca/1.0\" xmlns:ns1=\"http://www.osoa.org/xmlns/sca/1.0\" targetNamespace=\"http://calc\" name=\"Calculator\"><service name=\"CalculatorService\" promote=\"CalculatorServiceComponent\"><interface.java interface=\"calculator.CalculatorService\" /></service><component name=\"CalculatorServiceComponent\"><reference name=\"addService\" multiplicity=\"0..1\" target=\"AddServiceComponent\" /><reference name=\"subtractService\" target=\"SubtractServiceComponent\" /><reference name=\"multiplyService\" target=\"MultiplyServiceComponent\" /><reference name=\"divideService\" target=\"DivideServiceComponent\" /></component><component name=\"AddServiceComponent\" /><component name=\"SubtractServiceComponent\" /><component name=\"MultiplyServiceComponent\" /><component name=\"DivideServiceComponent\" /><x:unknownElement xmlns:x=\"http://x\" uknAttr=\"attribute1\"><y:subUnknownElement1 xmlns:y=\"http://y\" uknAttr1=\"attribute2\" /><x:subUnknownElement2 /></x:unknownElement></composite>";
private ExtensibleStAXArtifactProcessor staxProcessor;
@Override
diff --git a/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Calculator.composite b/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Calculator.composite
index cb319e2311..602d42a06a 100644
--- a/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Calculator.composite
+++ b/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/Calculator.composite
@@ -29,7 +29,7 @@
<component name="CalculatorServiceComponent">
<implementation.java class="calculator.CalculatorServiceImpl"/>
- <reference name="addService" target="AddServiceComponent"/>
+ <reference name="addService" multiplicity="0..1" target="AddServiceComponent"/>
<reference name="subtractService" target="SubtractServiceComponent"/>
<reference name="multiplyService" target="MultiplyServiceComponent"/>
<reference name="divideService" target="DivideServiceComponent"/>
diff --git a/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorComponent.constrainingType b/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorComponent.constrainingType
index 072fe8fde1..d6ec9b0ff0 100644
--- a/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorComponent.constrainingType
+++ b/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorComponent.constrainingType
@@ -26,9 +26,9 @@
<interface.java class="calculator.CalculatorService" />
</service>
- <reference name="divideService">
+ <reference name="divideService" multiplicity="1..1">
<interface.java class="calculator.DivideService" />
</reference>
</constrainingType>
- \ No newline at end of file
+
diff --git a/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorImpl.componentType b/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorImpl.componentType
index d67ba3ec2b..299eb8c197 100644
--- a/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorImpl.componentType
+++ b/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/CalculatorImpl.componentType
@@ -20,12 +20,12 @@
<componentType xmlns="http://www.osoa.org/xmlns/sca/1.0">
<service name="CalculatorService">
- <interface.java class="calculator.CalculatorService" />
+ <interface.java interface="calculator.CalculatorService" />
</service>
<reference name="divideService">
- <interface.java class="calculator.DivideService" />
+ <interface.java interface="calculator.DivideService" />
</reference>
</componentType>
- \ No newline at end of file
+