Replaced all tabs with spaces in java and pom.xml
[so.git] / adapters / mso-vfc-adapter / src / main / java / org / onap / so / adapters / vfc / 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.vfc;
22
23 import java.util.Arrays;
24 import org.apache.cxf.Bus;
25 import org.apache.cxf.endpoint.Server;
26 import org.apache.cxf.feature.LoggingFeature;
27 import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
28 import org.apache.cxf.jaxrs.swagger.Swagger2Feature;
29 import org.apache.cxf.transport.servlet.CXFServlet;
30 import org.onap.so.adapters.vfc.rest.VfcAdapterRest;
31 import org.onap.so.logging.jaxrs.filter.JaxRsFilterLogging;
32 import org.springframework.beans.factory.annotation.Autowired;
33 import org.springframework.boot.web.servlet.ServletRegistrationBean;
34 import org.springframework.context.annotation.Bean;
35 import org.springframework.context.annotation.Configuration;
36 import com.fasterxml.jackson.databind.ObjectMapper;
37 import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
38
39
40 @Configuration
41 public class CXFConfiguration {
42
43     @Autowired
44     private Bus bus;
45
46     @Autowired
47     private VfcAdapterRest vfcAdapterRest;
48
49     @Autowired
50     private JaxRsFilterLogging jaxRsFilterLogging;
51
52     @Autowired
53     private ObjectMapper mapper;
54
55     @Bean
56     public ServletRegistrationBean cxfServlet() {
57         return new ServletRegistrationBean(new CXFServlet(), "/services/*");
58     }
59
60     @Bean
61     public Server rsServer() {
62         JAXRSServerFactoryBean endpoint = new JAXRSServerFactoryBean();
63         endpoint.setBus(bus);
64         endpoint.setServiceBeans(Arrays.<Object>asList(vfcAdapterRest));
65         endpoint.setAddress("/");
66         endpoint.setFeatures(Arrays.asList(createSwaggerFeature(), new LoggingFeature()));
67         endpoint.setProviders(Arrays.asList(new JacksonJsonProvider(mapper), jaxRsFilterLogging));
68         return endpoint.create();
69     }
70
71     @Bean
72     public Swagger2Feature createSwaggerFeature() {
73         Swagger2Feature swagger2Feature = new Swagger2Feature();
74         swagger2Feature.setPrettyPrint(true);
75         swagger2Feature.setTitle("SO VFC Adapter");
76         swagger2Feature.setContact("The ONAP SO team");
77         swagger2Feature.setDescription("This project is the SO Orchestration Engine");
78         swagger2Feature.setVersion("1.0.0");
79         swagger2Feature.setResourcePackage("org.onap.so.adapters.vfc.rest");
80         swagger2Feature.setScan(true);
81         return swagger2Feature;
82     }
83
84 }