Results 1 to 4 of 4

Thread: Get rid of the JAXBElement when using Jaxb2Marshaller

Hybrid View

  1. #1
    Join Date
    Jun 2010
    Location
    Paris
    Posts
    106

    Lightbulb Get rid of the JAXBElement when using Jaxb2Marshaller

    Hello,

    When using JAXB2, depending on the number of elements defined in the the XML schema, the unmarshalled objects can be of type either MyClass (exactly one element) or JAXBElement<MyClass> (more than one element) -- see http://weblogs.java.net/blog/2006/03...mes-not-always.

    This would be very useful if the class org.springframework.oxm.jaxb.Jaxb2Marshaller of the Spring Framework could do the abstraction of the JAXBElement for us, ie. :
    - always returning an object of type MyClass when unmarshalling (by calling the getValue() method on the JAXBElement for us).
    - allowing passing an object of type MyClass when marshalling even though a JAXBElement<MyClass> would normally be expected.

    Then our code wouldn't have any code dependency on the marshaller (JAXB in this case).

    What do you think?

    -- Pierre

  2. #2
    Join Date
    Jun 2010
    Location
    Paris
    Posts
    106

    Default

    Does it make sense for a JIRA as of an improvement of Jaxb2Marshaller ?

  3. #3
    Join Date
    Jun 2010
    Location
    Paris
    Posts
    106

    Default

    Not a single comment in a month?
    Well, for who might be also interested in the subject, here's the JIRA : http://jira.springframework.org/browse/SWS-627

  4. #4
    Join Date
    Apr 2012
    Posts
    24

    Default

    I agree. This is a tedious issue. This is what I've had to do in order to extract the actual object from the JAXBElement:

    Code:
    	<int-xml:unmarshalling-transformer
    		unmarshaller="marshaller" input-channel="channel.unmarshall" output-channel="channel.unmarshall2">
    	</int-xml:unmarshalling-transformer>
    	<int:transformer input-channel="channel.unmarshall2"
    		output-channel="channel.auditTransformer" expression="payload.value" />

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •