2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.so.adapters.vfc;
23 import java.util.Arrays;
25 import org.apache.cxf.Bus;
26 import org.apache.cxf.endpoint.Server;
27 import org.apache.cxf.feature.LoggingFeature;
28 import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
29 import org.apache.cxf.jaxrs.swagger.Swagger2Feature;
30 import org.apache.cxf.transport.servlet.CXFServlet;
31 import org.onap.so.adapters.vfc.rest.VfcAdapterRest;
32 import org.onap.so.logging.jaxrs.filter.JaxRsFilterLogging;
33 import org.springframework.beans.factory.annotation.Autowired;
34 import org.springframework.boot.web.servlet.ServletRegistrationBean;
35 import org.springframework.context.annotation.Bean;
36 import org.springframework.context.annotation.Configuration;
38 import com.fasterxml.jackson.databind.ObjectMapper;
39 import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
43 public class CXFConfiguration {
49 private VfcAdapterRest vfcAdapterRest;
52 private JaxRsFilterLogging jaxRsFilterLogging;
55 private ObjectMapper mapper;
58 public ServletRegistrationBean cxfServlet() {
59 return new ServletRegistrationBean(new CXFServlet(), "/services/*");
63 public Server rsServer() {
64 JAXRSServerFactoryBean endpoint = new JAXRSServerFactoryBean();
66 endpoint.setServiceBeans(Arrays.<Object>asList(vfcAdapterRest));
67 endpoint.setAddress("/");
68 endpoint.setFeatures(Arrays.asList(createSwaggerFeature(), new LoggingFeature()));
69 endpoint.setProviders(Arrays.asList(new JacksonJsonProvider(mapper),jaxRsFilterLogging));
70 return endpoint.create();
74 public Swagger2Feature createSwaggerFeature() {
75 Swagger2Feature swagger2Feature = new Swagger2Feature();
76 swagger2Feature.setPrettyPrint(true);
77 swagger2Feature.setTitle("SO VFC Adapter");
78 swagger2Feature.setContact("The ONAP SO team");
79 swagger2Feature.setDescription("This project is the SO Orchestration Engine");
80 swagger2Feature.setVersion("1.0.0");
81 swagger2Feature.setResourcePackage("org.onap.so.adapters.vfc.rest");
82 swagger2Feature.setScan(true);
83 return swagger2Feature;