Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #20517

Re: Seeking info on JAXB and custom annotations

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder2.hal-mli.net!feeder.erje.net!eu.feeder.erje.net!news.albasani.net!.POSTED!not-for-mail
From Sebastian <sebastian@undisclosed.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: Seeking info on JAXB and custom annotations
Date Wed, 19 Dec 2012 12:49:52 +0100
Organization albasani.net
Lines 50
Message-ID <kas9gj$q31$1@news.albasani.net> (permalink)
References <kaqsov$hf1$1@news.albasani.net> <50d11591$0$290$14726298@news.sunsite.dk>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding 8bit
X-Trace news.albasani.net vO3fGwidVoBGPbQaNiPsSdRhkdD9KBTqWojNPFbp2AxBDmCUB8OufeF8ibRuWDxvw11L5y3k+kItTQkVUtcsuINywQLjGtJbkfQJbFz9U8hFtWn74+S/YjhpIpCvCeMd
NNTP-Posting-Date Wed, 19 Dec 2012 11:47:31 +0000 (UTC)
Injection-Info news.albasani.net; logging-data="Tcw7KcXZypXilqFIS3Ux9HnOB4dOFoA7r6JhWTbo6WoSXkWkEmY38oYaJ9V36bGfcMVMYgLKFG8c7nleBwhKT/5behkrPYRPgx8Map/vAWP8SjJbk52OfhjBjXPS4Feq"; mail-complaints-to="abuse@albasani.net"
User-Agent Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9
In-Reply-To <50d11591$0$290$14726298@news.sunsite.dk>
Cancel-Lock sha1:AMIS3j5BPrRKAIkt+wCQXWfHWBc=
Xref csiph.com comp.lang.java.programmer:20517

Show key headers only | View raw


Am 19.12.2012 02:17, schrieb Arne Vajhøj:
> On 12/18/2012 6:06 PM, Sebastian wrote:
>> Does anyone know if (and how) it is possible to
>>
>> a) generate Java classes with custom annotations from xsd schema, using
>> xjc? (The annotations would be on fields, but placing them on the
>> corresponding getters would be acceptable.) I have googled a bit, and
>> one possibiliy appears to be the annox plugin.
>
> What form would the annotations have in the schema?
>
> XML schema annotations does not seem to be a good match for
> Java annotations.

The Annotate Plugin page has a good explanation:
http://confluence.highsource.org/display/J2B/Annotate+Plugin

See also the Annox user guide for the view that
in fact Java annotations can be elegantly expressed as XML elements.
http://confluence.highsource.org/display/ANX/User+guide

Unfortunately, I have not been able to get the plugin to work so far, 
and am looking for alternative recommendations.

>> b) marshall/unmarshall these classes to XML and back with JAXB,
>> preserving the custom annotations? I have found no helpful information
>> on this part of the problem.
>
> You do not marshall/unmarshall classes. You marshall/unmarshall
> objects. But annotations are per class not per object.
>
> I think clarification is needed.
>
> Arne

I guess I was confused here by the fact that the XML representation of 
an object generated by JAXB will not contain annotation elements, but of 
course the annotation is part of the Java class that will be 
instantiated when unmarshalling.

(I am talking of custom annotation available at runtime via reflection, 
i. e. defined in the annotation class with 
@Retention(RetentionPolicy.RUNTIME). I want to be able to inspect the 
annotation on an object after it has been unmarshalled.)

-- Sebastian



Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Seeking info on JAXB and custom annotations Sebastian <sebastian@undisclosed.invalid> - 2012-12-19 00:06 +0100
  Re: Seeking info on JAXB and custom annotations Arne Vajhøj <arne@vajhoej.dk> - 2012-12-18 20:17 -0500
    Re: Seeking info on JAXB and custom annotations Sebastian <sebastian@undisclosed.invalid> - 2012-12-19 12:49 +0100
      Re: Seeking info on JAXB and custom annotations Sebastian <sebastian@undisclosed.invalid> - 2012-12-19 19:23 +0100

csiph-web