On Apr 29, 2009, at 7:45 PM, Tatu Saloranta wrote:
> On Wed, Apr 29, 2009 at 12:43 AM, Paul Sandoz <Paul.Sandoz_at_sun.com>
> wrote:
>> Hi Tatu,
>>
>> _providers.getContextResolver(ObjectMapper.class, null) will match
>> say:
>>
>> @Provider MyResolver implements ContextResolver<ObjectMapper> { ... }
>> @Provider("*/*") MyResolver implements
>> ContextResolver<ObjectMapper> { ...
>> }
>>
>> _providers.getContextResolver(ObjectMapper.class,
>> MedaType.APPLICATION_JSON_TYPE) will match say:
>>
>> @Provider("application/json") MyResolver implements
>> ContextResolver<ObjectMapper> { ... }
>>
>> but will not match:
>>
>> @Provider("*/*") MyResolver implements
>> ContextResolver<ObjectMapper> { ...
>> }
>
> Interesting. Sounds like it is opposite of what I would expect...
>
> But then again perhaps it makes sense.
>
> So, if I am correct, I should declare that my ObjectMapper context
> provider produces "application/json",
Yes.
> but make MessageBodyWriter
> provider access it using just null?
>
No, if things were working described in the previous email you should
just do this:
ContextResolver<ObjectMaper> r =
_providers.getContextResolver(ObjectMapper.class, mediaType);
but i implemented things incorrectly.
Perhaps the best recommendation is for developers to implement a
ContextResolver<ObjectMapper> with no @Produces until i fix things. I
have logged an issue:
https://jersey.dev.java.net/issues/show_bug.cgi?id=288
> What I am trying to achieve is just this:
>
> * MessageBodyWriter/Reader should be able to process all variants of
> json (application/json, text/json, xxx/xxx+json)
> * reader/writer needs ObjectMapper; if none injected, it uses one with
> default settings
> * There needs to be a way to inject configured ObjectMapper for
> reader/writer to use
>
Yes, that is correct.
> So question is just combination of media types (within @Produces for
> providers) that connect things as expected. ObjectMapper is not useful
> for types other than json, so there should be no collisions.
Correct, since it will only be utilized by the readers/writers that
kick in for JSON-based media types. So a declaration of @Produces("*/
*") just declares it for any JSON-based media type as supported by the
readers/writers.
> But
> ideally I want to use sensible values, if for nothing else just as
> documentation.
Yes. Thanks for your persistence here, you have found a number of
issues i need to fix!
Paul.
>
>
> -+ Tatu +-
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>