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.sdnc;
23 import java.util.Arrays;
24 import javax.xml.ws.Endpoint;
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.jaxws.EndpointImpl;
31 import org.apache.cxf.transport.servlet.CXFServlet;
32 import org.onap.so.adapters.sdnc.sdncrest.SNIROResponse;
33 import org.onap.so.logging.cxf.interceptor.SOAPLoggingInInterceptor;
34 import org.onap.so.logging.cxf.interceptor.SOAPLoggingOutInterceptor;
35 import org.onap.so.logging.jaxrs.filter.JaxRsFilterLogging;
36 import org.springframework.beans.factory.annotation.Autowired;
37 import org.springframework.boot.web.servlet.ServletRegistrationBean;
38 import org.springframework.context.annotation.Bean;
39 import org.springframework.context.annotation.Configuration;
40 import com.fasterxml.jackson.databind.DeserializationFeature;
41 import com.fasterxml.jackson.databind.ObjectMapper;
42 import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
45 @Configuration("CXFConfiguration")
46 public class CXFConfiguration {
48 JAXRSServerFactoryBean endpoint;
54 private JaxRsFilterLogging jaxRsFilterLogging;
57 private SDNCAdapterPortType sdncAdapterPortImpl;
60 private SNIROResponse sniroResponse;
63 private ObjectMapper mapper;
66 public Server rsServer() {
67 endpoint = new JAXRSServerFactoryBean();
68 mapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
70 endpoint.setServiceBeans(Arrays.<Object>asList(sniroResponse));
71 endpoint.setAddress("/rest");
72 endpoint.setFeatures(Arrays.asList(createSwaggerFeature(), new LoggingFeature()));
73 endpoint.setProviders(Arrays.asList(new JacksonJsonProvider(mapper), jaxRsFilterLogging));
74 return endpoint.create();
78 public ServletRegistrationBean cxfServlet() {
79 return new ServletRegistrationBean(new CXFServlet(), "/adapters/*");
83 public Endpoint sndcAdapter() {
84 EndpointImpl wsdlEndpoint = new EndpointImpl(bus, sdncAdapterPortImpl);
85 wsdlEndpoint.getInInterceptors().add(new SOAPLoggingInInterceptor());
86 wsdlEndpoint.getOutInterceptors().add(new SOAPLoggingOutInterceptor());
87 wsdlEndpoint.getOutFaultInterceptors().add(new SOAPLoggingOutInterceptor());
88 wsdlEndpoint.publish("/SDNCAdapter");
94 public Swagger2Feature createSwaggerFeature() {
95 Swagger2Feature swagger2Feature = new Swagger2Feature();
96 swagger2Feature.setBasePath("/services/rest");
97 swagger2Feature.setPrettyPrint(true);
98 swagger2Feature.setTitle("SO Orchestration Application");
99 swagger2Feature.setContact("The ONAP SO team");
100 swagger2Feature.setDescription("This project is the SO Orchestration Engine");
101 swagger2Feature.setVersion("1.0.0");
102 swagger2Feature.setResourcePackage("org.onap.so.adapters.sdnc");
103 swagger2Feature.setScan(true);
104 return swagger2Feature;