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 usedwith 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
> 



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