2 * ============LICENSE_START===================================================
3 * Copyright (c) 2018 Amdocs
4 * ============================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 * ============LICENSE_END=====================================================
18 package org.onap.sdnc.apps.pomba.networkdiscovery;
20 import java.util.logging.Logger;
22 import javax.ws.rs.ApplicationPath;
23 import javax.ws.rs.client.Client;
24 import javax.ws.rs.client.ClientBuilder;
26 import org.glassfish.jersey.client.ClientConfig;
27 import org.glassfish.jersey.logging.LoggingFeature;
28 import org.glassfish.jersey.server.ResourceConfig;
29 import org.glassfish.jersey.servlet.ServletProperties;
30 import org.onap.sdnc.apps.pomba.networkdiscovery.service.rs.RestServiceImpl;
31 import org.springframework.beans.factory.annotation.Autowired;
32 import org.springframework.context.annotation.Bean;
33 import org.springframework.context.annotation.Primary;
34 import org.springframework.stereotype.Component;
36 import com.fasterxml.jackson.annotation.JsonInclude;
37 import com.fasterxml.jackson.databind.DeserializationFeature;
38 import com.fasterxml.jackson.databind.MapperFeature;
39 import com.fasterxml.jackson.databind.ObjectMapper;
40 import com.fasterxml.jackson.databind.SerializationFeature;
44 public class JerseyConfiguration extends ResourceConfig {
45 private static final Logger log = Logger.getLogger(JerseyConfiguration.class.getName());
49 public ObjectMapper objectMapper() {
50 ObjectMapper objectMapper = new ObjectMapper();
51 objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
52 objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
53 objectMapper.enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES);
54 objectMapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
59 public JerseyConfiguration() {
60 register(RestServiceImpl.class);
61 property(ServletProperties.FILTER_FORWARD_ON_404, true);
62 register(new LoggingFeature(log));
66 public Client jerseyClient() {
67 return ClientBuilder.newClient(new ClientConfig());