2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.sal.rest.doc.jaxrs;
10 import com.fasterxml.jackson.annotation.JsonInclude;
11 import com.fasterxml.jackson.databind.ObjectMapper;
12 import com.fasterxml.jackson.datatype.jsonorg.JsonOrgModule;
13 import org.opendaylight.controller.sal.rest.doc.swagger.ApiDeclaration;
15 import javax.ws.rs.Consumes;
16 import javax.ws.rs.Produces;
17 import javax.ws.rs.core.MediaType;
18 import javax.ws.rs.ext.ContextResolver;
19 import javax.ws.rs.ext.Provider;
22 @Consumes(MediaType.APPLICATION_JSON)
23 @Produces(MediaType.APPLICATION_JSON)
24 public class JaxbContextResolver implements ContextResolver<ObjectMapper> {
26 private ObjectMapper ctx;
28 public JaxbContextResolver(){
29 ctx = new ObjectMapper();
30 ctx.registerModule(new JsonOrgModule());
31 ctx.getSerializationConfig().withSerializationInclusion(JsonInclude.Include.ALWAYS);
35 public ObjectMapper getContext(Class<?> aClass) {
37 if (ApiDeclaration.class.isAssignableFrom(aClass)){
41 return null;//must return null so that jax-rs can continue context search