2325ffaa14b036341e7067c8a274c716a07b173a
[so.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.onap.so.adapters.requestsdb.application;
22
23 import java.util.Arrays;
24 import java.util.HashSet;
25 import javax.xml.ws.Endpoint;
26 import org.apache.cxf.Bus;
27 import org.apache.cxf.feature.LoggingFeature;
28 import org.apache.cxf.jaxrs.openapi.OpenApiFeature;
29 import org.apache.cxf.jaxws.EndpointImpl;
30 import org.apache.cxf.transport.servlet.CXFServlet;
31 import org.onap.so.adapters.requestsdb.MsoRequestsDbAdapter;
32 import org.onap.so.logging.cxf.interceptor.SOAPLoggingInInterceptor;
33 import org.onap.so.logging.cxf.interceptor.SOAPLoggingOutInterceptor;
34 import org.springframework.beans.factory.annotation.Autowired;
35 import org.springframework.boot.web.servlet.ServletRegistrationBean;
36 import org.springframework.context.annotation.Bean;
37 import org.springframework.context.annotation.Configuration;
38
39
40 @Configuration
41 public class CXFConfiguration {
42
43     @Autowired
44     private Bus bus;
45
46     @Autowired
47     private MsoRequestsDbAdapter requestDbAdapterImpl;
48
49     @Bean
50     public ServletRegistrationBean cxfServlet() {
51
52         return new ServletRegistrationBean(new CXFServlet(), "/services/*");
53     }
54
55     @Bean
56     public Endpoint requestEndpointk() {
57         EndpointImpl endpoint = new EndpointImpl(bus, requestDbAdapterImpl);
58         endpoint.publish("/RequestsDbAdapter");
59         LoggingFeature logFeature = new LoggingFeature();
60         logFeature.setPrettyLogging(true);
61         logFeature.initialize(bus);
62         endpoint.getFeatures().add(logFeature);
63         endpoint.getInInterceptors().add(new SOAPLoggingInInterceptor());
64         endpoint.getOutInterceptors().add(new SOAPLoggingOutInterceptor());
65         endpoint.getOutFaultInterceptors().add(new SOAPLoggingOutInterceptor());
66         return endpoint;
67     }
68
69     @Bean
70     public OpenApiFeature createSwaggerFeature() {
71         OpenApiFeature openApiFeature = new OpenApiFeature();
72         openApiFeature.setPrettyPrint(true);
73         openApiFeature.setTitle("SO Request Adapter");
74         openApiFeature.setContactName("The ONAP SO team");
75         openApiFeature.setDescription("This project is the SO Orchestration Engine");
76         openApiFeature.setVersion("1.0.0");
77         openApiFeature.setResourcePackages(new HashSet<String>(Arrays.asList("org.onap.so.adapters.requestdb")));
78         openApiFeature.setScan(true);
79         return openApiFeature;
80     }
81
82 }