From: Ron S. <rs...@re...> - 2015-03-14 23:50:37
|
Hi Anthony, I see that com.fasterxml.jackson.jaxrs.base.ProviderBase, from which org.jboss.resteasy.plugins.providers.jackson.ResteasyJackson2Provider is indirectly derived, has a method /** * Method called to locate {@link ObjectMapper} to use for serialization * and deserialization. If an instance has been explicitly defined by * {@link #setMapper} (or non-null instance passed in constructor), that * will be used. * If not, will try to locate it using standard JAX-RS * <code>ContextResolver</code> mechanism, if it has been properly configured * to access it (by JAX-RS runtime). * Finally, if no mapper is found, will return a default unconfigured * {@link ObjectMapper} instance (one constructed with default constructor * and not modified in any way) * * @param type Class of object being serialized or deserialized; * not checked at this point, since it is assumed that unprocessable * classes have been already weeded out, * but will be passed to <code>ContextResolver</code> as is. * @param mediaType Declared media type for the instance to process: * not used by this method, * but will be passed to <code>ContextResolver</code> as is. */ public MAPPER locateMapper(Class<?> type, MediaType mediaType); So, for example, you could try ResteasyJackson2Provider provider = new ResteasyJackson2Provider(); ObjectMapper mapper = provider.locateMapper(Object.class, MediaType.APPLICATION_JSON_TYPE); in a resource method. Does that work for you? -Ron |