dev@jsr311.java.net

Re: JSR311: EntityProviders

From: Stefan Tilkov <stefan.tilkov_at_innoq.com>
Date: Sun, 4 Nov 2007 08:27:40 +0100

On Nov 4, 2007, at 1:25 AM, Marc Hadley wrote:

> On Nov 3, 2007, at 12:02 PM, Stefan Tilkov wrote:
>>
>> 1. There is no way to implement EntityProvider<T> multiple times
>> (for different values of T) within a single class. So if I have a
>> set of related classes I'd like to map e.g. to a single XML
>> vocabulary, I have to create as many EntityProviders as I have
>> classes. Right?
>>
> No, you can implement EntityProvider<Object> and use the
> supports(Class<?>) method to reject types the provider doesn't
> support.
>

But then I'd have a single readFrom and writeTo method, typed with
Object?

>> 2. There is no way to have two different EntityProviders for the
>> same class (e.g. for different MIME types), which means one has to
>> resort to if-else-if-chains on
>> the mediaType parameter. Correct?
>>
> No, you can use @ProduceMime and @ConsumeMime on the provider class
> to declare the media types that it supports. The JSR 311 runtime
> will only call providers that support the appropriate media type.
>

OK; this is the way I expected it to work, but couldn't get it to work
with Jersey 0.4 (but that might be a usage error on my side).

Thanks,
Stefan


> Marc.
>
>>
>
>
> ---
> Marc Hadley <marc.hadley at sun.com>
> CTO Office, Sun Microsystems.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_jsr311.dev.java.net
> For additional commands, e-mail: dev-help_at_jsr311.dev.java.net
>
>