Skip to content

Commit

Permalink
[HWKMETRICS-185] Manually add the jackson provider to the list of pro…
Browse files Browse the repository at this point in the history
…viders.
  • Loading branch information
Stefan Negrea committed Aug 11, 2015
1 parent 185cec9 commit dea31ad
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,23 @@
*/
package org.hawkular.metrics.api.jaxrs.util;

import javax.ws.rs.Consumes;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.ext.ContextResolver;
import javax.ws.rs.ext.Provider;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;

/**
* @author Stefan Negrea
*/
@Provider
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public class JacksonConfig implements ContextResolver<ObjectMapper> {
private final ObjectMapper mapper;

Expand All @@ -35,6 +41,9 @@ public JacksonConfig() throws Exception {
mapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true);
mapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
mapper.configure(SerializationFeature.WRITE_EMPTY_JSON_ARRAYS, false);
mapper.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false);
}

@Override
Expand Down
10 changes: 10 additions & 0 deletions api/metrics-api-jaxrs-1.1/src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@
</param-value>
</context-param>

<context-param>
<param-name>resteasy.providers</param-name>
<param-value>org.hawkular.metrics.api.jaxrs.util.JacksonConfig</param-value>
</context-param>

<context-param>
<param-name>resteasy.scan.providers</param-name>
<param-value>true</param-value>
</context-param>

<filter>
<filter-name>TenantFilter</filter-name>
<filter-class>org.hawkular.metrics.api.jaxrs.filter.TenantFilter</filter-class>
Expand Down

0 comments on commit dea31ad

Please sign in to comment.