Refactor NBINotifications and serviceHandlerImpl
[transportpce.git] / dmaap-client / src / main / java / org / opendaylight / transportpce / dmaap / client / resource / config / JsonConfigurator.java
1 /*
2  * Copyright © 2021 Orange, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.transportpce.dmaap.client.resource.config;
9
10 import com.fasterxml.jackson.databind.ObjectMapper;
11 import com.fasterxml.jackson.databind.SerializationFeature;
12 import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
13 import javax.ws.rs.ext.ContextResolver;
14
15 public class JsonConfigurator implements ContextResolver<ObjectMapper> {
16
17     private final ObjectMapper mapper;
18
19     public JsonConfigurator() {
20         mapper = new ObjectMapper();
21         mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
22         mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
23         mapper.enable(SerializationFeature.INDENT_OUTPUT);
24         mapper.registerModule(new JavaTimeModule());
25         mapper.registerModule(new PublishNotificationProcessServiceModule());
26     }
27
28     @Override
29     public ObjectMapper getContext(Class<?> type) {
30         return mapper;
31     }
32
33 }