users@jersey.java.net

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

From: Tatu Saloranta <tsaloranta_at_gmail.com>
Date: Wed, 28 Jul 2010 08:29:59 -0700

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.

-+ Tatu +-