users@jersey.java.net

Re: [Jersey] Re: Does Jersey support jaxb external customization?

From: Paul Sandoz <Paul.Sandoz_at_oracle.com>
Date: Thu, 29 Jul 2010 15:35:37 +0200

On Jul 28, 2010, at 5:29 PM, Tatu Saloranta wrote:

> On Wed, Jul 28, 2010 at 1:59 AM, Pavel Bucek <Pavel.Bucek_at_sun.com>
> wrote:
>> This would need to create some kind of fake classloader, which
>> would provide
>> annotations from external location, like a file..
>>
>> .. unfortunately, I don't know about any project which can do this,
>> JAXB nor
>> Jersey don't support anything like it by itself. You should probably
>> re-generate your JAXB beans (it should be simple if you have XSD
>> schema) or
>> implement custom classloader (but it might not be easy task).
>
> Another way to actually implement something like this is using "mix-in
> annotation" approach that Jackson takes -- allow attaching annotations
> from mix-in classes into target classes on runtime. Such mix-in
> annotations override annotations on matched methods (fields,
> constructors, static methods). Calling code just registers these
> associations, and code that uses annotations for configuring handling
> handle merging of annotations automatically, for all annotation types.
>
> Doing this is not trivial but was much simpler than code generation
> alternatives would be.
>

Yes, and way better than using an XML file.

Paul.