summaryrefslogtreecommitdiffstats
path: root/java/sca
diff options
context:
space:
mode:
Diffstat (limited to 'java/sca')
-rw-r--r--java/sca/itest/properties/src/main/resources/ConstructorPropertyInjection.composite32
-rw-r--r--java/sca/itest/properties/src/main/resources/Outer.composite4
-rw-r--r--java/sca/itest/properties/src/main/resources/OuterPropertyTest.composite2
-rw-r--r--java/sca/itest/properties/src/main/resources/PropertyTest.composite46
-rw-r--r--java/sca/itest/properties/src/main/resources/mySimpleService.composite4
-rw-r--r--java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java102
-rw-r--r--java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteAllTestCase.java2
-rw-r--r--java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllCalculator.composite16
-rw-r--r--java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllPolicyCalculator.composite9
-rw-r--r--java/sca/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/POJOTestCase.java5
-rwxr-xr-xjava/sca/modules/databinding-jaxb/src/test/resources/ipo.xsd8
-rw-r--r--java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/JavaPropertyValueObjectFactory.java172
-rw-r--r--java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java2
13 files changed, 236 insertions, 168 deletions
diff --git a/java/sca/itest/properties/src/main/resources/ConstructorPropertyInjection.composite b/java/sca/itest/properties/src/main/resources/ConstructorPropertyInjection.composite
index c0e2fa32d5..24a2cca822 100644
--- a/java/sca/itest/properties/src/main/resources/ConstructorPropertyInjection.composite
+++ b/java/sca/itest/properties/src/main/resources/ConstructorPropertyInjection.composite
@@ -17,25 +17,23 @@
* specific language governing permissions and limitations
* under the License.
-->
-<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200712"
- name="ConstructorPropertyInjection">
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903" name="ConstructorPropertyInjection">
- <component name="Foo1Component">
- <implementation.java
- class="org.apache.tuscany.sca.itest.cdi.Foo1" />
- <property name="bar">fubar</property>
- </component>
+ <component name="Foo1Component">
+ <implementation.java class="org.apache.tuscany.sca.itest.cdi.Foo1" />
+ <property name="bar" value="foobar" />
+ </component>
- <component name="Foo2Component">
- <implementation.java
- class="org.apache.tuscany.sca.itest.cdi.Foo2" />
- <property name="bar">fubar</property>
- </component>
+ <component name="Foo2Component">
+ <implementation.java class="org.apache.tuscany.sca.itest.cdi.Foo2" />
+ <property name="bar">fubar</property>
+ </component>
- <component name="Foo3Component">
- <implementation.java
- class="org.apache.tuscany.sca.itest.cdi.Foo3" />
- <property name="bar">fubar</property>
- </component>
+ <component name="Foo3Component">
+ <implementation.java class="org.apache.tuscany.sca.itest.cdi.Foo3" />
+ <property name="bar">
+ <value>fubar</value>
+ </property>
+ </component>
</composite> \ No newline at end of file
diff --git a/java/sca/itest/properties/src/main/resources/Outer.composite b/java/sca/itest/properties/src/main/resources/Outer.composite
index 587557461e..0ada194cb3 100644
--- a/java/sca/itest/properties/src/main/resources/Outer.composite
+++ b/java/sca/itest/properties/src/main/resources/Outer.composite
@@ -16,9 +16,9 @@
* specific language governing permissions and limitations
* under the License.
-->
-<composite xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200712"
+<composite xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
xmlns:foo="http://foo" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- xsi:schemaLocation="http://docs.oasis-open.org/ns/opencsa/sca/200712 http://docs.oasis-open.org/ns/opencsa/sca/200712" name="Iteration3Composite"
+ xsi:schemaLocation="http://docs.oasis-open.org/ns/opencsa/sca/200903 http://docs.oasis-open.org/ns/opencsa/sca/200903" name="Iteration3Composite"
targetNamespace="http://foo" local="true" autowire="false">
<property name="newLocation" type="xsd:anyURI">Raleigh</property>
diff --git a/java/sca/itest/properties/src/main/resources/OuterPropertyTest.composite b/java/sca/itest/properties/src/main/resources/OuterPropertyTest.composite
index 87840ba16b..75fa0aaa81 100644
--- a/java/sca/itest/properties/src/main/resources/OuterPropertyTest.composite
+++ b/java/sca/itest/properties/src/main/resources/OuterPropertyTest.composite
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
-->
-<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200712"
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
xmlns:foo="http://foo"
targetNamespace="http://foo"
name="OuterPropertyTest"
diff --git a/java/sca/itest/properties/src/main/resources/PropertyTest.composite b/java/sca/itest/properties/src/main/resources/PropertyTest.composite
index e5a92e7d52..4d3715dba6 100644
--- a/java/sca/itest/properties/src/main/resources/PropertyTest.composite
+++ b/java/sca/itest/properties/src/main/resources/PropertyTest.composite
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
-->
-<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200712"
+<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
xmlns:foo="http://foo"
xmlns:cust="http://www.example.com/Customer"
xmlns:dbsdo="http://tuscany.apache.org/xmlns/sca/databinding/sdo/1.0"
@@ -35,7 +35,7 @@
<property name="number" type="xsd:int">1</property>
<property name="complex" type="foo:MyComplexType" >
- <foo:MyComplexValue xsi:type="foo:MyComplexType" >
+ <value xsi:type="foo:MyComplexType" >
<foo:a>a</foo:a>
<foo:b>b</foo:b>
<foo:c>c</foo:c>
@@ -44,11 +44,11 @@
<foo:y>y</foo:y>
<foo:z>z</foo:z>
</foo:x>
- </foo:MyComplexValue>
+ </value>
</property>
<property name="moreComplex" type="foo:MyMoreComplexType">
- <MyMoreComplexValue xmlns="">
+ <value>
<numberSetArray>
<integerNumber>1</integerNumber>
<floatNumber>11</floatNumber>
@@ -73,16 +73,16 @@
<floatNumber>158.68</floatNumber>
<doubleNumber>369.04</doubleNumber>
</numberSet>
- </MyMoreComplexValue>
+ </value>
</property>
<property name="complexFoo" type="foo:MyMoreComplexType">
- <MyMoreComplexValue xmlns="">
+ <value>
<stringArray>TestString_3</stringArray>
<stringArray>TestString_4</stringArray>
<intArray>100</intArray>
<intArray>200</intArray>
- </MyMoreComplexValue>
+ </value>
</property>
<component name="ABCDComponent">
@@ -118,7 +118,7 @@
<implementation.java class="org.apache.tuscany.sca.itest.PropertyComponentImpl"/>
<property name="complexPropertyOne" source="$moreComplex"></property>
<property name="complexPropertyTwo">
- <MyAnotherComplexValue xmlns="">
+ <value>
<stringArray>TestString_1</stringArray>
<stringArray>TestString_2</stringArray>
<intArray>10</intArray>
@@ -143,10 +143,10 @@
<floatNumber>158.68</floatNumber>
<doubleNumber>369.04</doubleNumber>
</numberSet>
- </MyAnotherComplexValue>
+ </value>
</property>
<property name="complexPropertyThree" element="foo:PropertyThreeElement">
- <PropertyThreeElement xmlns="">
+ <PropertyThreeElement xmlns="http://foo">
<stringArray>TestElementString_1</stringArray>
<stringArray>TestElementString_2</stringArray>
<intArray>10</intArray>
@@ -174,7 +174,7 @@
</PropertyThreeElement>
</property>
<property name="complexPropertyFour" element="foo:PropertyFourElement" many="true">
- <PropertyFourElement xmlns="">
+ <PropertyFourElement xmlns="http://foo">
<integerNumber>1</integerNumber>
<floatNumber>11.11</floatNumber>
<doubleNumber>111.111</doubleNumber>
@@ -184,7 +184,7 @@
<doubleNumber>11111.11111</doubleNumber>
</numberSet>
</PropertyFourElement>
- <PropertyFourElement xmlns="">
+ <PropertyFourElement xmlns="http://foo">
<integerNumber>2</integerNumber>
<floatNumber>22.22</floatNumber>
<doubleNumber>222.222</doubleNumber>
@@ -194,7 +194,7 @@
<doubleNumber>22222.22222</doubleNumber>
</numberSet>
</PropertyFourElement>
- <PropertyFourElement xmlns="">
+ <PropertyFourElement xmlns="http://foo">
<integerNumber>3</integerNumber>
<floatNumber>33.33</floatNumber>
<doubleNumber>333.333</doubleNumber>
@@ -207,18 +207,18 @@
</property>
<property name="complexPropertyFive" source="$complexFoo"/>
<property name="sdoProperty" type="cust:Customer">
- <cust:customer>
+ <value>
<cust:firstName>Firstly Name</cust:firstName>
<cust:middleName>Middler Name</cust:middleName>
<cust:lastName>Lasting Name</cust:lastName>
- </cust:customer>
+ </value>
</property>
<property name="customerSdo" type="cust:Customer">
- <cust:customer>
+ <value>
<cust:firstName>Sdo Firstly Name</cust:firstName>
<cust:middleName>Sdo Middler Name</cust:middleName>
<cust:lastName>Sdo Lasting Name</cust:lastName>
- </cust:customer>
+ </value>
</property>
<property name="location" type="xsd:string">RTP</property>
<property name="year" type="xsd:string">2006</property>
@@ -226,21 +226,21 @@
<property name="integerNumbers" many="true" type="xsd:int">1 2 3 4 5 6 7 8 9 10</property>
<property name="intNumbers" many="true" type="xsd:int">10 9 8 7 6 5 4 3 2 1 0</property>
<property name="sdoArray" many="true" type="cust:Customer">
- <cust:customer>
+ <value>
<cust:firstName>Firstly Name 1</cust:firstName>
<cust:middleName>Middler Name 1</cust:middleName>
<cust:lastName>Lasting Name 1</cust:lastName>
- </cust:customer>
- <cust:customer>
+ </value>
+ <value>
<cust:firstName>Firstly Name 2</cust:firstName>
<cust:middleName>Middler Name 2</cust:middleName>
<cust:lastName>Lasting Name 2</cust:lastName>
- </cust:customer>
- <cust:customer>
+ </value>
+ <value>
<cust:firstName>Firstly Name 3</cust:firstName>
<cust:middleName>Middler Name 3</cust:middleName>
<cust:lastName>Lasting Name 3</cust:lastName>
- </cust:customer>
+ </value>
</property>
<property name="complexJAXBPropertyOne" type="rcp:ReturnCodeProperties">
<MyRCProps xmlns="http://test.sca.jaxb/rcprops">
diff --git a/java/sca/itest/properties/src/main/resources/mySimpleService.composite b/java/sca/itest/properties/src/main/resources/mySimpleService.composite
index 1d2bdbf4f8..b22b32bc30 100644
--- a/java/sca/itest/properties/src/main/resources/mySimpleService.composite
+++ b/java/sca/itest/properties/src/main/resources/mySimpleService.composite
@@ -18,9 +18,9 @@
* under the License.
-->
<composite autowire="false" local="true" name="MySimpleService"
- targetNamespace="http://foo" xmlns:foo="http://foo" xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200712"
+ targetNamespace="http://foo" xmlns:foo="http://foo" xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200903"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://docs.oasis-open.org/ns/opencsa/sca/200712 http://docs.oasis-open.org/ns/opencsa/sca/200712 ">
+ xsi:schemaLocation="http://docs.oasis-open.org/ns/opencsa/sca/200903 http://docs.oasis-open.org/ns/opencsa/sca/200903 ">
<service name="MyServiceNew1" promote="MyServiceComponentNew/MyService">
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 c3c1ba7f42..03a087a5ec 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
@@ -21,6 +21,9 @@ package org.apache.tuscany.sca.assembly.xml;
import static javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI;
import static javax.xml.XMLConstants.XMLNS_ATTRIBUTE_NS_URI;
+import static javax.xml.stream.XMLStreamConstants.CDATA;
+import static javax.xml.stream.XMLStreamConstants.CHARACTERS;
+import static javax.xml.stream.XMLStreamConstants.COMMENT;
import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
import static org.apache.tuscany.sca.assembly.xml.Constants.ELEMENT;
@@ -30,6 +33,7 @@ import static org.apache.tuscany.sca.assembly.xml.Constants.MUST_SUPPLY;
import static org.apache.tuscany.sca.assembly.xml.Constants.NAME;
import static org.apache.tuscany.sca.assembly.xml.Constants.ONE_N;
import static org.apache.tuscany.sca.assembly.xml.Constants.ONE_ONE;
+import static org.apache.tuscany.sca.assembly.xml.Constants.PROPERTY;
import static org.apache.tuscany.sca.assembly.xml.Constants.PROPERTY_QNAME;
import static org.apache.tuscany.sca.assembly.xml.Constants.SCA11_NS;
import static org.apache.tuscany.sca.assembly.xml.Constants.TARGET;
@@ -430,6 +434,7 @@ abstract class BaseAssemblyProcessor extends BaseStAXArtifactProcessor {
return null;
}
+ /*
protected List<Extension> readPropertyValue(XMLStreamReader reader) throws XMLStreamException,
ContributionReadException {
List<Extension> values = new ArrayList<Extension>();
@@ -455,7 +460,7 @@ abstract class BaseAssemblyProcessor extends BaseStAXArtifactProcessor {
name = reader.getName();
if (PROPERTY_QNAME.equals(name)) {
isTextForProperty = true;
- continue;
+ break;
}
isTextForProperty = false;
// Read <value>
@@ -489,8 +494,14 @@ abstract class BaseAssemblyProcessor extends BaseStAXArtifactProcessor {
}
break;
}
+ if (reader.hasNext()) {
+ event = reader.next();
+ } else {
+ return values;
+ }
}
}
+ */
/**
* Read a property value into a DOM document.
@@ -517,8 +528,13 @@ abstract class BaseAssemblyProcessor extends BaseStAXArtifactProcessor {
throw ce;
}
- // root element has no namespace and local name "value"
- Element root = document.createElementNS(null, "value");
+ // Collect the property values as <value> elements under the <property>
+ Element root = document.createElementNS(SCA11_NS, "sca:" + PROPERTY);
+ String nameAttr = getString(reader, NAME);
+ if (nameAttr != null) {
+ root.setAttributeNS(SCA11_NS, "sca:" + NAME, nameAttr);
+ }
+ declareNamespace(root, "sca", SCA11_NS);
if (type != null) {
org.w3c.dom.Attr xsi = document.createAttributeNS(XMLNS_ATTRIBUTE_NS_URI, "xmlns:xsi");
xsi.setValue(W3C_XML_SCHEMA_INSTANCE_NS_URI);
@@ -537,7 +553,63 @@ abstract class BaseAssemblyProcessor extends BaseStAXArtifactProcessor {
}
document.appendChild(root);
- loadElement(reader, root);
+ // Start to parse the property
+ QName name = reader.getName(); // Should be sca:property
+
+ // SCA 1.1 supports the @value for simple types
+ String valueAttr = getString(reader, VALUE);
+ if (valueAttr != null) {
+ Element valueElement = document.createElementNS(SCA11_NS, VALUE);
+ root.appendChild(valueElement);
+ valueElement.setTextContent(valueAttr);
+ }
+
+ boolean isTextForProperty = true;
+ StringBuffer text = new StringBuffer();
+
+ int event = reader.getEventType();
+ while (true) {
+ switch (event) {
+ case START_ELEMENT:
+ name = reader.getName();
+ if (PROPERTY_QNAME.equals(name)) {
+ isTextForProperty = true;
+ break;
+ }
+ isTextForProperty = false;
+ // Read <value>
+ if (VALUE_QNAME.equals(name)) {
+ loadElement(reader, root);
+ } else {
+ // Global elements
+ loadElement(reader, root);
+ }
+ break;
+ case XMLStreamConstants.CHARACTERS:
+ case XMLStreamConstants.CDATA:
+ if (isTextForProperty) {
+ text.append(reader.getText());
+ }
+ break;
+ case END_ELEMENT:
+ name = reader.getName();
+ if (PROPERTY_QNAME.equals(name)) {
+ if (root.getChildNodes().getLength() == 0) {
+ // Add the text as an <value>
+ Element valueElement = document.createElementNS(SCA11_NS, VALUE);
+ root.appendChild(valueElement);
+ valueElement.setTextContent(text.toString());
+ }
+ return document;
+ }
+ break;
+ }
+ if (reader.hasNext()) {
+ event = reader.next();
+ } else {
+ break;
+ }
+ }
return document;
}
@@ -607,8 +679,8 @@ abstract class BaseAssemblyProcessor extends BaseStAXArtifactProcessor {
Document document = root.getOwnerDocument();
Node current = root;
while (true) {
- switch (reader.next()) {
- case XMLStreamConstants.START_ELEMENT:
+ switch (reader.getEventType()) {
+ case START_ELEMENT:
QName name = reader.getName();
Element child = createElement(document, name);
@@ -644,20 +716,28 @@ abstract class BaseAssemblyProcessor extends BaseStAXArtifactProcessor {
}
break;
- case XMLStreamConstants.CDATA:
+ case CDATA:
current.appendChild(document.createCDATASection(reader.getText()));
break;
- case XMLStreamConstants.CHARACTERS:
+ case CHARACTERS:
current.appendChild(document.createTextNode(reader.getText()));
break;
- case XMLStreamConstants.END_ELEMENT:
+ case COMMENT:
+ current.appendChild(document.createComment(reader.getText()));
+ break;
+ case END_ELEMENT:
+ // pop the element off the stack
+ current = current.getParentNode();
// if we are back at the root then we are done
if (current == root) {
return;
}
- // pop the element off the stack
- current = current.getParentNode();
+ }
+ if (reader.hasNext()) {
+ reader.next();
+ } else {
+ return;
}
}
}
diff --git a/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteAllTestCase.java b/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteAllTestCase.java
index 1877470cd3..cf86aec6f4 100644
--- a/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteAllTestCase.java
+++ b/java/sca/modules/assembly-xml/src/test/java/org/apache/tuscany/sca/assembly/xml/WriteAllTestCase.java
@@ -152,7 +152,7 @@ public class WriteAllTestCase {
assertEquals(composite.getProperties().get(1).getName(),"prop2");
assertEquals(composite.getProperties().get(1).isMustSupply(), true);
assertEquals(composite.getProperties().get(0).getXSDType(), new QName("http://foo", "MyComplexType"));
- assertEquals(composite.getProperties().get(1).getXSDElement(), new QName("http://docs.oasis-open.org/ns/opencsa/sca/200903", "MyComplexPropertyValue1"));
+ assertEquals(composite.getProperties().get(1).getXSDElement(), new QName("http://foo", "MyComplexPropertyValue1"));
}
}
diff --git a/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllCalculator.composite b/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllCalculator.composite
index 2f1c2e333a..65e709f9b1 100644
--- a/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllCalculator.composite
+++ b/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllCalculator.composite
@@ -107,17 +107,21 @@
</reference>
<property name="prop1" xmlns:foo="http://foo" many="true" type="foo:MyComplexType">
- <ext:testExtension/>
- <MyComplexPropertyValue1 xsi:type="foo:MyComplexType" attr="bar">
+ <value xsi:type="foo:MyComplexType" attr="bar">
<foo:a>AValue</foo:a>
<bar:b xmlns:bar="http://bar">InterestingURI</bar:b>
- </MyComplexPropertyValue1>
- <MyComplexPropertyValue2 xsi:type="foo:MyComplexType" attr="zing">
+ </value>
+ <value xsi:type="foo:MyComplexType" attr="zing">
<foo:a>BValue</foo:a>
<bar:b xmlns:bar="http://bar">BoringURI</bar:b>
- </MyComplexPropertyValue2>
+ </value>
</property>
- <property name="prop2" xmlns:foo="http://foo" mustSupply="true" element="MyComplexPropertyValue1"/>
+ <property name="prop2" xmlns:foo="http://foo" mustSupply="true" element="foo:MyComplexPropertyValue1">
+ <foo:MyComplexPropertyValue1>123</foo:MyComplexPropertyValue1>
+ </property>
+ <property name="prop3" xmlns:foo="http://foo" mustSupply="true" value="123"/>
+ <property name="prop4">123</property>
+ <property name="prop5"><value>123</value></property>
</composite>
diff --git a/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllPolicyCalculator.composite b/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllPolicyCalculator.composite
index 9d5dcead7c..661270d341 100644
--- a/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllPolicyCalculator.composite
+++ b/java/sca/modules/assembly-xml/src/test/resources/org/apache/tuscany/sca/assembly/xml/TestAllPolicyCalculator.composite
@@ -112,15 +112,14 @@
</reference>
<property name="prop1" xmlns:foo="http://foo">
- <ext:testExtension/>
- <MyComplexPropertyValue1 xsi:type="foo:MyComplexType" attr="bar">
+ <value xsi:type="foo:MyComplexType" attr="bar">
<foo:a>AValue</foo:a>
<bar:b xmlns:bar="http://bar">InterestingURI</bar:b>
- </MyComplexPropertyValue1>
- <MyComplexPropertyValue2 xsi:type="foo:MyComplexType" attr="zing">
+ </value>
+ <value xsi:type="foo:MyComplexType" attr="zing">
<foo:a>BValue</foo:a>
<bar:b xmlns:bar="http://bar">BoringURI</bar:b>
- </MyComplexPropertyValue2>
+ </value>
</property>
</composite>
diff --git a/java/sca/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/POJOTestCase.java b/java/sca/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/POJOTestCase.java
index b9370c9387..98aefed546 100644
--- a/java/sca/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/POJOTestCase.java
+++ b/java/sca/modules/databinding-jaxb/src/test/java/org/apache/tuscany/sca/databinding/jaxb/POJOTestCase.java
@@ -209,11 +209,12 @@ public class POJOTestCase {
public void testPrimitive() throws Exception {
JAXBContext context = JAXBContext.newInstance(int.class);
StringWriter writer = new StringWriter();
- JAXBElement<Object> element = new JAXBElement<Object>(new QName("http://ns1", "bean"), Object.class, 1);
+ JAXBElement<Integer> element = new JAXBElement<Integer>(new QName("http://ns1", "bean"), Integer.class, 1);
context.createMarshaller().marshal(element, writer);
// System.out.println(writer.toString());
- Object result = context.createUnmarshaller().unmarshal(new StringReader(writer.toString()));
+ StreamSource source = new StreamSource(new StringReader(writer.toString()));
+ Object result = context.createUnmarshaller().unmarshal(source, int.class);
assertTrue(result instanceof JAXBElement);
JAXBElement e2 = (JAXBElement)result;
assertEquals(1, e2.getValue());
diff --git a/java/sca/modules/databinding-jaxb/src/test/resources/ipo.xsd b/java/sca/modules/databinding-jaxb/src/test/resources/ipo.xsd
index 241ec15d36..04e8cb44f3 100755
--- a/java/sca/modules/databinding-jaxb/src/test/resources/ipo.xsd
+++ b/java/sca/modules/databinding-jaxb/src/test/resources/ipo.xsd
@@ -129,6 +129,14 @@
<pattern value="[A-Z]{2}\d\s\d[A-Z]{2}" />
</restriction>
</simpleType>
+
+ <element name="note" type="ipo:Note" />
+ <complexType name="Note" mixed="true">
+ <sequence>
+ <any namespace="##any" processContents="lax" minOccurs="0"/>
+ </sequence>
+ <anyAttribute/>
+ </complexType>
diff --git a/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/JavaPropertyValueObjectFactory.java b/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/JavaPropertyValueObjectFactory.java
index 3618fa3477..885004b09b 100644
--- a/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/JavaPropertyValueObjectFactory.java
+++ b/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/JavaPropertyValueObjectFactory.java
@@ -57,95 +57,62 @@ public class JavaPropertyValueObjectFactory implements PropertyValueFactory {
public JavaPropertyValueObjectFactory(ExtensionPointRegistry registry) {
this.mediator = registry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(Mediator.class);
}
+
public JavaPropertyValueObjectFactory(Mediator mediator) {
this.mediator = mediator;
}
-
+
+ /**
+ * Introspect the property
+ * @param javaElement
+ * @return
+ */
+ private DataType<?> introspect(JavaElementImpl javaElement) {
+ DataType<XMLType> dt =
+ new DataTypeImpl<XMLType>(null, javaElement.getType(), javaElement.getGenericType(), XMLType.UNKNOWN);
+ mediator.getDataBindings().introspectType(dt, null);
+ return dt;
+ }
+
public ObjectFactory createValueFactory(Property property, Object propertyValue, JavaElementImpl javaElement) {
- isSimpleType = isSimpleType(property);
Document doc = (Document)propertyValue;
+ List<Node> nodes = getValues(doc);
Class<?> javaType = JavaIntrospectionHelper.getBaseType(javaElement.getType(), javaElement.getGenericType());
- Element rootElement = doc.getDocumentElement();
if (property.isMany()) {
- if (isSimpleType) {
- String value = "";
- if (rootElement.getChildNodes().getLength() > 0) {
- value = rootElement.getChildNodes().item(0).getTextContent();
- }
- List<String> values = getSimplePropertyValues(value, javaType);
- if ( javaElement.getType().isArray() ) {
- return new ArrayObjectFactoryImpl(property, values, isSimpleType, javaType);
- } else {
- return new ListObjectFactoryImpl(property, values, isSimpleType, javaType);
- }
+ if (javaElement.getType().isArray()) {
+ return new ArrayObjectFactoryImpl(property, nodes, javaType);
} else {
- if ( javaElement.getType().isArray() ) {
- return new ArrayObjectFactoryImpl(property, getComplexPropertyValues(doc), isSimpleType, javaType);
- } else {
- return new ListObjectFactoryImpl(property, getComplexPropertyValues(doc), isSimpleType, javaType);
- }
+ return new ListObjectFactoryImpl(property, nodes, javaType);
}
} else {
- if (isSimpleType) {
- String value = "";
- if (rootElement.getChildNodes().getLength() > 0) {
- value = rootElement.getChildNodes().item(0).getTextContent();
- }
- return new ObjectFactoryImpl(property, value, isSimpleType, javaType);
- } else {
- List<Node> nodes = getComplexPropertyValues(doc);
- Object value = null;
- if (!nodes.isEmpty()) {
- value = nodes.get(0);
- }
- return new ObjectFactoryImpl(property, value, isSimpleType, javaType);
+ Object value = null;
+ if (!nodes.isEmpty()) {
+ value = nodes.get(0);
}
+ return new ObjectFactoryImpl(property, value, javaType);
}
}
-
+
public ObjectFactory createValueFactory(Property property, Object propertyValue, Class<?> javaType) {
- isSimpleType = isSimpleType(property);
Document doc = (Document)propertyValue;
- Element rootElement = doc.getDocumentElement();
+ List<Node> nodes = getValues(doc);
if (property.isMany()) {
- if (isSimpleType) {
- String value = "";
- if (rootElement.getChildNodes().getLength() > 0) {
- value = rootElement.getChildNodes().item(0).getTextContent();
- }
- List<String> values = getSimplePropertyValues(value, javaType);
- return new ListObjectFactoryImpl(property, values, isSimpleType, javaType);
- } else {
- return new ListObjectFactoryImpl(property, getComplexPropertyValues(doc), isSimpleType, javaType);
- }
+ return new ListObjectFactoryImpl(property, nodes, javaType);
} else {
- if (isSimpleType) {
- String value = "";
- if (rootElement.getChildNodes().getLength() > 0) {
- value = rootElement.getChildNodes().item(0).getTextContent();
- }
- return new ObjectFactoryImpl(property, value, isSimpleType, javaType);
- } else {
- List<Node> nodes = getComplexPropertyValues(doc);
- Object value = null;
- if (!nodes.isEmpty()) {
- value = nodes.get(0);
- }
- return new ObjectFactoryImpl(property, value, isSimpleType, javaType);
+ Object value = null;
+ if (!nodes.isEmpty()) {
+ value = nodes.get(0);
}
-
+ return new ObjectFactoryImpl(property, value, javaType);
}
- }
-
+ }
- public <B> B createPropertyValue(ComponentProperty property, Class<B> type)
- {
+ public <B> B createPropertyValue(ComponentProperty property, Class<B> type) {
ObjectFactory<B> factory = this.createValueFactory(property, property.getValue(), type);
return factory.getInstance();
}
-
abstract class ObjectFactoryImplBase implements ObjectFactory {
protected SimpleTypeMapper simpleTypeMapper = new SimpleTypeMapperImpl();
protected Property property;
@@ -153,15 +120,14 @@ public class JavaPropertyValueObjectFactory implements PropertyValueFactory {
protected Class<?> javaType;
protected DataType<XMLType> sourceDataType;
protected DataType<?> targetDataType;
- boolean isSimpleType;
- public ObjectFactoryImplBase(Property property, Object propertyValue, boolean isSimpleType, Class<?> javaType) {
- this.isSimpleType = isSimpleType;
+ public ObjectFactoryImplBase(Property property, Object propertyValue, Class<?> javaType) {
this.property = property;
this.propertyValue = propertyValue;
this.javaType = javaType;
- sourceDataType = new DataTypeImpl<XMLType>(DOMDataBinding.NAME, Node.class, new XMLType(null, this.property
- .getXSDType()));
+ sourceDataType =
+ new DataTypeImpl<XMLType>(DOMDataBinding.NAME, Node.class,
+ new XMLType(null, this.property.getXSDType()));
TypeInfo typeInfo = null;
if (this.property.getXSDType() != null) {
if (SimpleTypeMapperImpl.isSimpleXSDType(this.property.getXSDType())) {
@@ -185,8 +151,8 @@ public class JavaPropertyValueObjectFactory implements PropertyValueFactory {
}
class ObjectFactoryImpl extends ObjectFactoryImplBase {
- public ObjectFactoryImpl(Property property, Object propertyValue, boolean isSimpleType, Class<?> javaType) {
- super(property, propertyValue, isSimpleType, javaType);
+ public ObjectFactoryImpl(Property property, Object propertyValue, Class<?> javaType) {
+ super(property, propertyValue, javaType);
}
public Object getInstance() throws ObjectCreationException {
@@ -194,11 +160,13 @@ public class JavaPropertyValueObjectFactory implements PropertyValueFactory {
try {
return simpleTypeMapper.toJavaObject(property.getXSDType(), (String)propertyValue, null);
} catch (NumberFormatException ex) {
- throw new ObjectCreationException("Failed to create instance for property "
- + property.getName() + " with value " + propertyValue, ex);
+ throw new ObjectCreationException("Failed to create instance for property " + property.getName()
+ + " with value "
+ + propertyValue, ex);
} catch (IllegalArgumentException ex) {
- throw new ObjectCreationException("Failed to create instance for property "
- + property.getName() + " with value " + propertyValue, ex);
+ throw new ObjectCreationException("Failed to create instance for property " + property.getName()
+ + " with value "
+ + propertyValue, ex);
}
} else {
return mediator.mediate(propertyValue, sourceDataType, targetDataType, null);
@@ -208,8 +176,8 @@ public class JavaPropertyValueObjectFactory implements PropertyValueFactory {
}
class ListObjectFactoryImpl extends ObjectFactoryImplBase {
- public ListObjectFactoryImpl(Property property, List<?> propertyValues, boolean isSimpleType, Class<?> javaType) {
- super(property, propertyValues, isSimpleType, javaType);
+ public ListObjectFactoryImpl(Property property, List<?> propertyValues, Class<?> javaType) {
+ super(property, propertyValues, javaType);
}
@SuppressWarnings("unchecked")
@@ -220,13 +188,19 @@ public class JavaPropertyValueObjectFactory implements PropertyValueFactory {
try {
values.add(simpleTypeMapper.toJavaObject(property.getXSDType(), aValue, null));
} catch (NumberFormatException ex) {
- throw new ObjectCreationException("Failed to create instance for property "
- + property.getName() + " with value " + aValue
- + " from value list of " + propertyValue, ex);
+ throw new ObjectCreationException("Failed to create instance for property " + property
+ .getName()
+ + " with value "
+ + aValue
+ + " from value list of "
+ + propertyValue, ex);
} catch (IllegalArgumentException ex) {
- throw new ObjectCreationException("Failed to create instance for property "
- + property.getName() + " with value " + aValue
- + " from value list of " + propertyValue, ex);
+ throw new ObjectCreationException("Failed to create instance for property " + property
+ .getName()
+ + " with value "
+ + aValue
+ + " from value list of "
+ + propertyValue, ex);
}
}
return values;
@@ -239,10 +213,10 @@ public class JavaPropertyValueObjectFactory implements PropertyValueFactory {
}
}
}
-
+
class ArrayObjectFactoryImpl extends ObjectFactoryImplBase {
- public ArrayObjectFactoryImpl(Property property, List<?> propertyValues, boolean isSimpleType, Class<?> javaType) {
- super(property, propertyValues, isSimpleType, javaType);
+ public ArrayObjectFactoryImpl(Property property, List<?> propertyValues, Class<?> javaType) {
+ super(property, propertyValues, javaType);
}
@SuppressWarnings("unchecked")
@@ -254,13 +228,19 @@ public class JavaPropertyValueObjectFactory implements PropertyValueFactory {
try {
Array.set(values, count++, simpleTypeMapper.toJavaObject(property.getXSDType(), aValue, null));
} catch (NumberFormatException ex) {
- throw new ObjectCreationException("Failed to create instance for property "
- + property.getName() + " with value " + aValue
- + " from value list of " + propertyValue, ex);
+ throw new ObjectCreationException("Failed to create instance for property " + property
+ .getName()
+ + " with value "
+ + aValue
+ + " from value list of "
+ + propertyValue, ex);
} catch (IllegalArgumentException ex) {
- throw new ObjectCreationException("Failed to create instance for property "
- + property.getName() + " with value " + aValue
- + " from value list of " + propertyValue, ex);
+ throw new ObjectCreationException("Failed to create instance for property " + property
+ .getName()
+ + " with value "
+ + aValue
+ + " from value list of "
+ + propertyValue, ex);
}
}
return values;
@@ -275,12 +255,10 @@ public class JavaPropertyValueObjectFactory implements PropertyValueFactory {
}
}
-
-
/**
* Utility methods
*/
-
+
/**
*
* @param property
@@ -301,7 +279,6 @@ public class JavaPropertyValueObjectFactory implements PropertyValueFactory {
return false;
}
-
/**
* Retrieve list of simple property values
* @param concatenatedValue
@@ -331,7 +308,8 @@ public class JavaPropertyValueObjectFactory implements PropertyValueFactory {
* @param document
* @return
*/
- private static List<Node> getComplexPropertyValues(Document document) {
+ private static List<Node> getValues(Document document) {
+ // The root is the property element
Element rootElement = document.getDocumentElement();
List<Node> propValues = new ArrayList<Node>();
NodeList nodes = rootElement.getChildNodes();
diff --git a/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java b/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java
index 8fa3b77ef4..08e38a63cc 100644
--- a/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java
+++ b/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java
@@ -387,7 +387,7 @@ public class NodeImpl implements Node, Client {
// will be extended later with definitions from application contributions
systemContribution = contributionFactory.createContribution();
systemContribution.setURI("http://tuscany.apache.org/SystemContribution");
- systemContribution.setLocation("Derived");
+ systemContribution.setLocation("http://tuscany.apache.org/SystemContribution");
ModelResolver modelResolver = new ExtensibleModelResolver(systemContribution, modelResolvers, modelFactories);
systemContribution.setModelResolver(modelResolver);
systemContribution.setUnresolved(true);