users@jersey.java.net

Re: [Jersey] Re: Adding _at_Provider via META-INF/services, injecting @Context Providers?

From: Tatu Saloranta <tsaloranta_at_gmail.com>
Date: Tue, 28 Apr 2009 10:02:34 -0700

On Tue, Apr 28, 2009 at 9:50 AM, Tatu Saloranta <tsaloranta_at_gmail.com> wrote:
...
> But the remaining problem (if it is any -- may be my
>
> ContextResolver<ObjectMapper> resolver =
> _providers.getContextResolver(ObjectMapper.class, mediaType);
>
> returns null, whereas:
>
> resolver = _providers.getContextResolver(ObjectMapper.class, null);
>
> does not.
>
> I wonder if I need to add both @Consumes and @Produces annotations in

Ok found it: javadocs state it's @Produces that counts.

However:

> ContextResolver<ObjectMapper> implementation?
> Or do these have any effect? If not, what determines MediaType matching rules?
> I can also just try registering ObjectMapper as singleton directly:
> that should work reliably.

I can not make this match anything but exact media type
("application/json"), either via provider or direct instance;
neither @Produces (which defaults to "*/*") nor explicit "*/*" seem to
work. @Produces("application/json") does.

So I wonder if there might be a problem in media type matching code?
This is in jersey 1.0.3.

In the meantime I can just have the fallback call to pass null Media
Type, since that does work ok.

-+ Tatu +-