Hi,
We treat JavaBeans as JAXB objects with default mapping rules. I see the
following in the composite file for the property value.
<property name="complexFoo" element="foo:fooElement">
<foo:fooElement>
<foo:a>AValue</foo:a>
<foo:b>BValue</foo:b>
</foo:fooElement>
</property>
Please note both a and b are qualified local elements. With the Java class:
public class MyComplexType {
public String a;
public String b;
}
Both a and b are mapped to non-qualified elements.
If I change the composite file to be:
<property name="complexFoo" element="foo:fooElement">
<foo:fooElement xmlns="">
<a>AValue</a>
<b>BValue</b>
</foo:fooElement>
Then the test case is passing.
If you really want to support the qualified form, I suggest that you
generate JAXB classes using wsimport tool.
Thanks,
Raymond
From: [EMAIL PROTECTED]
Sent: Wednesday, September 24, 2008 5:28 AM
To: [email protected]
Subject: Is it possible to value Complex Properties in Java code ?
Hello,
I've been trying to implement the 'complex properties' principle described
in the SCA 1.0 specifications, but I can never have my complex property
atttributes valued in the corresponding Java code.
At the run, property1 and property2 (described above) get correctly valued,
myComplexProperty is not null, but myComplexProperty.a and
myComplexProperty.b = null.
As I can see 1/ in the SCA specification no example of Java code defining a
complex property, and 2/ as I only see mentions in Tuscany samples of how
will be valued a simple property in the code from a complex description
(using Xpath function to get a simple value from a complex XML description),
I've been wondering if it was possible at all.
(To get a proper XSD-to-Java mapping, I tried to produce the class
'MyComplexType' using the SDO code generation, but I got the same class
definition as I had first wrote myself)
If anyone can tell me if what I want to do is possible or not (and if yes
maybe how), that'd be quite helpful.
Thanks in advance,
Muriel
This is my XSD description :
<schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:foo="http://foo.com"
targetNamespace="http://foo.com"
elementFormDefault="qualified">
<element name="fooElement" type="foo:MyComplexType"/>
<complexType name="MyComplexType">
<sequence>
<element name="a" type="string"/>
<element name="b" type="string"/>
</sequence>
</complexType>
</schema>
This my Complex Type Java class :
public class MyComplexType {
public String a;
public String b;
public void setA(String aVal) { this.a = aVal; }
public void setB(String bVal) { this.b = bVal; }
}
(I tried with a constructor instead of setters, annotated or not, but it
made no difference)
This my class defining the properties :
public class PremierServiceImpl implements PremierService {
@Property public String property1;
private List<String> property2;
@Property(name="property2", required=true)
public void setProperty2( List<String> prop2Val) {
this.property2 = prop2Val;
}
private MyComplexType myComplexProp;
@Property(name="myComplexProp", required=true)
public void setComplexProperty( MyComplexType complexPropVal) {
this.myComplexProp = complexPropVal;
}
}
And this my composite file :
<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:foo="http://foo.com"
xsi:schemaLocation="http://www.w3schools.com samplemu.xsd"
targetNamespace="http://foo.com"
name="Mu">
<property name="complexFoo" element="foo:fooElement">
<foo:fooElement>
<foo:a>AValue</foo:a>
<foo:b>BValue</foo:b>
</foo:fooElement>
</property>
<component name="MuServiceComponent">
<implementation.java class="testmu.MuServiceImpl"/>
<reference name="premierService" target="ServiceComponent1" />
</component>
<component name="ServiceComponent1">
<implementation.java class="testmu.PremierServiceImpl"/>
<property name="property1">1</property>
<property name="property2" many="true">2 22</property>
<property name="myComplexProp" type="foo:MyComplexType"
source="$complexFoo"/>
</component>
</composite>
----------
I Also tried to assign the composite value directly by element, but it
didn't change anything :
<property name="myComplexProp" element="foo:fooElement">
<foo:fooElement>
<foo:a>AValue</foo:a>
<foo:b>BValue</foo:b>
</foo:fooElement>
</property>
Instead of :
<property name="myComplexProp" type="foo:MyComplexType"
source="$complexFoo"/>