OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

sca-j message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]


Subject: Re: [sca-j] ISSUE-179: Need type support for @Property when used with SDO


Hi Simon,

Thanks for the research. Don't you think it would be quite odd if the spec required the use of JAXB emitters (this is what I find the most troubling) in order to use SDO with a specific schema type? My argument remains the same. We need a way to simplify the use of SDO as a databinding technology, enabling the developers to work with the minimal number of building blocks. While I agree that the @XmlJavaTypeAdapter seems to "work", it doesn't meet the requirement as something that would be intuitive to use because it introduces extra concepts that the developer doesn't really need. The simple extension that I've proposed provides an easily understandable integration point because the developer only has to deal with the SDO API and XML schema.

The @XmlAnyElement seems like a reasonable approach for the mapping of SDO to <any/>, so I can probably live with it for those use cases that require <any/>. Are there any other JAXB annotations that would have to appear in the Java class in order to make this work?

Dave Booz
STSM, BPM and SCA Architecture
Co-Chair OASIS SCA-Policy TC and SCA-J TC
"Distributed objects first, then world hunger"
Poughkeepsie, NY (845)-435-6093 or 8-295-6093
e-mail:booz@us.ibm.com

Inactive hide details for Simon Nash ---09/05/2009 07:46:03 AM---On Friday's call I took an action to see whether JAXB annotatiSimon Nash ---09/05/2009 07:46:03 AM---On Friday's call I took an action to see whether JAXB annotations can be used to override the defaul


From:

Simon Nash <oasis@cjnash.com>

To:

sca-j@lists.oasis-open.org

Date:

09/05/2009 07:46 AM

Subject:

Re: [sca-j] ISSUE-179: Need type support for @Property when used with SDO





On Friday's call I took an action to see whether JAXB annotations can be
used to override the default JAXB mapping from a Java property type
to a schema type.

The answer is that this can be done with the @XmlJavaTypeAdapter annotation.
If there is a property whose Java type is the interface DataObject and it
needs to be mapped to a specific schema type such as "address", the following
steps are needed:
 1. Create an xsd file for the "address" schema type.
 2. Generate a Java class Address from this xsd file using JAXB.
 3. Create a JAXB adapter class to specify the property mapping, for example:
     public class AddressAdapter extends XmlAdapter<Address, DataObject> {
       public DataObject unmarshal(Address value) {
         // If the SCA runtime will use the JAXB unmarshaller to convert
         // the property value to a Java object, this method needs to
         // contain code to create an instance of DataObject from an Address
         // object passed in by the JAXB unmarshaller. If the property
         // conversion will be done in some other way (e.g., by SDO), this
         // method can just return null.
       }
       public Address marshal(DataObject value) {
         return null; // SCA properties are never converted from Java to XML
       }
     }
 4. Annotate the property whose Java type is DataObject with the
    annotation @XmlJavaTypeAdapter(AddressAdapter.class)
A separate adapter class is required for every schema type that is a possible
mapping target for the property.

If the property needs to be mapped to a specific schema element instead of
a schema type, the steps are the same except that an "address" schema element
is used in step 1, and an additional annotation @XmlElement(name="address")
is used on the property in step 4.

If the property needs to be mapped to a schema <any> element, steps 1, 2 and
3 are not needed.  In step 4, the annotation @XmlAnyElement is used on the
property instead of @XmlJavaTypeAdapter.

I have verified all of the above with some simple test code.

  Simon

David Booz wrote:
>
http://www.osoa.org/jira/browse/JAVA-179
>
> Dave Booz
> STSM, BPM and SCA Architecture
> Co-Chair OASIS SCA-Policy TC and SCA-J TC
> "Distributed objects first, then world hunger"
> Poughkeepsie, NY (845)-435-6093 or 8-295-6093
> e-mail:booz@us.ibm.com
>
> Inactive hide details for David Booz---08/24/2009 04:16:58 PM---TARGET:
> Java CAA CD03 and Java POJO CD01 DESCRIPTION:David Booz---08/24/2009
> 04:16:58 PM---TARGET: Java CAA CD03 and Java POJO CD01 DESCRIPTION:
>
>
> From:
> David Booz/Poughkeepsie/IBM@IBMUS
>
> To:
> sca-j@lists.oasis-open.org
>
> Date:
> 08/24/2009 04:16 PM
>
> Subject:
> [sca-j] NEW ISSUE: Need type support for @Property when used with SDO
>
> ------------------------------------------------------------------------
>
>
>
> TARGET: Java CAA CD03 and Java POJO CD01
>
> DESCRIPTION:
> SDO DataObject can be mapped to any XML schema type, and therefore
> literally <any> as well. There is no way to specify the concrete XML
> type of a Java property who's Java type is SDO DataObject.
>
> PROPOSAL:
> Will be attached to JIRA once the issue is logged.
> Basically, the proposal will introduce two new attributes on @Property,
> xmlType (for specifying the XML schema type) and xmlElement (for
> specifying an XML global element that denotes the type). The new
> attributes are mutually exclusive.
>
>
> Dave Booz
> STSM, BPM and SCA Architecture
> Co-Chair OASIS SCA-Policy TC and SCA-J TC
> "Distributed objects first, then world hunger"
> Poughkeepsie, NY (845)-435-6093 or 8-295-6093
> e-mail:booz@us.ibm.com
>


---------------------------------------------------------------------
To unsubscribe from this mail list, you must leave the OASIS TC that
generates this mail.  Follow this link to all your TCs in OASIS at:
https://www.oasis-open.org/apps/org/workgroup/portal/my_workgroups.php 





[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]