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", but make MessageBodyWriter
provider access it using just null?
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
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. But
ideally I want to use sensible values, if for nothing else just as
documentation.
-+ Tatu +-