Update Logging
[so.git] / adapters / mso-requests-db-adapter / src / main / java / org / onap / so / adapters / requestsdb / application / CXFConfiguration.java
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 javax.xml.ws.Endpoint;
24
25 import org.apache.cxf.Bus;
26 import org.apache.cxf.feature.LoggingFeature;
27 import org.apache.cxf.jaxrs.swagger.Swagger2Feature;
28 import org.apache.cxf.jaxws.EndpointImpl;
29 import org.apache.cxf.transport.servlet.CXFServlet;
30 import org.onap.so.adapters.requestsdb.MsoRequestsDbAdapter;
31 import org.onap.so.logging.cxf.interceptor.SOAPLoggingInInterceptor;
32 import org.onap.so.logging.cxf.interceptor.SOAPLoggingOutInterceptor;
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;
37
38
39 @Configuration
40 public class CXFConfiguration {
41
42         @Autowired
43         private Bus bus;
44
45         @Autowired
46         private MsoRequestsDbAdapter requestDbAdapterImpl;
47         
48         @Autowired
49         private SOAPLoggingInInterceptor soapInInterceptor;
50         
51         @Autowired
52         private SOAPLoggingOutInterceptor soapOutInterceptor;
53         
54         @Bean
55         public ServletRegistrationBean cxfServlet() {
56         
57                 return new ServletRegistrationBean(new CXFServlet(), "/services/*");
58         }
59
60         @Bean
61         public Endpoint requestEndpointk() {
62                 EndpointImpl endpoint = new EndpointImpl(bus, requestDbAdapterImpl);
63                 endpoint.publish("/RequestsDbAdapter");
64                 LoggingFeature logFeature = new LoggingFeature();
65                 logFeature.setPrettyLogging(true);
66                 logFeature.initialize(bus);
67                 endpoint.getFeatures().add(logFeature);
68                 endpoint.getInInterceptors().add(soapInInterceptor);
69                 endpoint.getOutInterceptors().add(soapOutInterceptor);
70                 endpoint.getOutFaultInterceptors().add(soapOutInterceptor);
71                 return endpoint;
72         }
73
74         @Bean
75         public Swagger2Feature createSwaggerFeature() {
76                 Swagger2Feature swagger2Feature = new Swagger2Feature();
77                 swagger2Feature.setPrettyPrint(true);
78                 swagger2Feature.setTitle("SO Request Adapter");
79                 swagger2Feature.setContact("The ONAP SO team");
80                 swagger2Feature.setDescription("This project is the SO Orchestration Engine");
81                 swagger2Feature.setVersion("1.0.0");
82                 swagger2Feature.setResourcePackage("org.onap.so.adapters.requestdb");
83                 swagger2Feature.setScan(true);
84                 return swagger2Feature;
85         }
86
87 }