camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Basovník (JIRA) <j...@apache.org>
Subject [jira] [Comment Edited] (CAMEL-9649) Do not require @XmlRootElement annotation in JAXB FallbackTypeConverter
Date Mon, 07 Mar 2016 08:25:40 GMT

    [ https://issues.apache.org/jira/browse/CAMEL-9649?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15182740#comment-15182740
] 

Martin Basovník edited comment on CAMEL-9649 at 3/7/16 8:25 AM:
----------------------------------------------------------------

[~davsclaus], do you think it would be useful to add possibility to have several {{@XmlElementDecl}}
annotations for one type?

e.g.
{code:xml}
<request>
<text>world</text>
</request>
{code}

{code:xml}
<response>
<text>Hello world!</text>
</response>
{code}

*ObjectFactory*:
{code:java}
@XmlElementDecl(namespace = "", name = "request")
public JAXBElement<Message> createRequest(Message value) {
        return new JAXBElement<>(REQUEST_QNAME, Message.class, null, value);
}
@XmlElementDecl(namespace = "", name = "response")
public JAXBElement<Message> createResponse(Message value) {
        return new JAXBElement<>(RESPONSE_QNAME, Message.class, null, value);
}
{code}

We would have to somehow pass the {{QName}} parameter of required element to {{convertTo}}
method when it uses {{Exchange}}, e.g.:
* exchange property
* message header
* ???

or add new method to interface {{TypeConverter}} with extra parameter of type {{Object}}.


What do you think? Is this use case interesting for us?




was (Author: mbasovni):
[~davsclaus], do you think it would be useful to add possibility to have several {{@XmlElementDecl}}
annotations for one type?

e.g.
{code:xml}
<request>
<text>world</text>
</request>
{code}

{code:xml}
<response>
<text>Hello world!</text>
</response>
{code}

*ObjectFactory*:
{code:java}
@XmlElementDecl(namespace = "", name = "request")
public JAXBElement<Message> createMessage(Message value) {
        return new JAXBElement<>(REQUEST_QNAME, Message.class, null, value);
}
@XmlElementDecl(namespace = "", name = "response")
public JAXBElement<Message> createMessage(Message value) {
        return new JAXBElement<>(RESPONSE_QNAME, Message.class, null, value);
}
{code}

We would have to somehow pass the {{QName}} parameter of required element to {{convertTo}}
method when it uses {{Exchange}}, e.g.:
* exchange property
* message header
* ???

or add new method to interface {{TypeConverter}} with extra parameter of type {{Object}}.


What do you think? Is this use case interesting for us?



> Do not require @XmlRootElement annotation in JAXB FallbackTypeConverter
> -----------------------------------------------------------------------
>
>                 Key: CAMEL-9649
>                 URL: https://issues.apache.org/jira/browse/CAMEL-9649
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-jaxb
>            Reporter: Martin Basovník
>            Assignee: Claus Ibsen
>             Fix For: 2.17.0
>
>
> We should fix method {{org.apache.camel.converter.jaxb.FallbackTypeConverter#isJaxbType}}.
It can only handle beans with annotation  {{@XmlRootElement}} now. But this annotation is
not necessary. We should check if there is {{ObjectFactory.java}} class in current java package
and explore this class if there is proper method returning {{JAXBElement<T>}} with annotation
{{@XmlElementDecl}}.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message