Re: JSR311: EntityProviders

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Sat, 03 Nov 2007 20:25:01 -0400

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.

> 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.



Marc Hadley <marc.hadley at>
CTO Office, Sun Microsystems.