Thanks for quick answer!
On Tue, Apr 28, 2009 at 4:51 AM, Paul Sandoz <Paul.Sandoz_at_sun.com> wrote:
....
> I think there is an issue further on:
>
> if (resolver != null) {
> ObjectMapper mapper = resolver.getContext(ObjectMapper.class);
>
> You should be passing in the "type" argument rather than ObjectMapper.class
Ah! Of course... ObjectMapper.class to get resolver, but then type to
serialize/deserialize. Makes sense once you point it out. :)
...
>> if (type == ObjectMapper.class) { // should always be true
>> return _mapper;
>
> The type should never be equal to ObjectMapper.class unless you want to
> marshall/unmarshall ObjectMapper.
Surprisingly, it does seem to work... :-o
(it shouldn't, since as you point out test should never match)
> What trouble are you running into, are instances of
> ContextResolver<ObjectMapper> being created? is the getContext method being
> called?
Yes; I forgot to update details -- I am indeed getting things to work.
But the remaining problem (if it is any -- may be my misunderstanding) is that:
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
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.
-+ Tatu +-