Containerization feature of SO
[so.git] / bpmn / mso-infrastructure-bpmn / src / main / java / org / onap / so / bpmn / infrastructure / 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.bpmn.infrastructure;
22
23 import java.util.Arrays;
24
25 import javax.xml.ws.Endpoint;
26
27 import org.apache.cxf.Bus;
28 import org.apache.cxf.endpoint.Server;
29 import org.apache.cxf.feature.LoggingFeature;
30 import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
31 import org.apache.cxf.jaxrs.swagger.Swagger2Feature;
32 import org.apache.cxf.jaxws.EndpointImpl;
33 import org.apache.cxf.transport.servlet.CXFServlet;
34 import org.onap.so.bpmn.common.adapter.sdnc.SDNCCallbackAdapterPortType;
35 import org.onap.so.bpmn.common.adapter.vnf.VnfAdapterNotify;
36 import org.onap.so.bpmn.common.workflow.service.WorkflowAsyncResource;
37 import org.onap.so.bpmn.common.workflow.service.WorkflowMessageResource;
38 import org.onap.so.bpmn.common.workflow.service.WorkflowResource;
39 import org.onap.so.logger.MsoLogger;
40 import org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging;
41 import org.springframework.beans.factory.annotation.Autowired;
42 import org.springframework.boot.web.servlet.ServletRegistrationBean;
43 import org.springframework.context.annotation.Bean;
44 import org.springframework.context.annotation.Configuration;
45
46 import com.fasterxml.jackson.databind.ObjectMapper;
47 import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
48
49
50 @Configuration
51 public class CXFConfiguration {
52     
53         private static final MsoLogger logger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL,CXFConfiguration.class);
54         
55     @Autowired
56     private Bus bus;    
57
58         @Autowired
59         private WorkflowMessageResource wmr;
60         
61         @Autowired
62         private WorkflowResource workflowResource;
63
64         @Autowired
65         private WorkflowAsyncResource workflowAsyncResource;
66         
67         @Autowired
68         private JaxRsFilterLogging jaxRsFilterLogging;
69         
70         @Autowired
71         private ObjectMapper mapper; 
72         
73         @Autowired
74         private SDNCCallbackAdapterPortType sdncAdapterCallbackServiceImpl;
75         
76         @Autowired
77         private VnfAdapterNotify vnfAdapterNotifyServiceImpl;
78         
79         @Bean
80     public ServletRegistrationBean cxfServlet() {
81         return new ServletRegistrationBean(new CXFServlet(), "/mso/*");
82     }
83     
84     @Bean
85     public Endpoint vnfAdapterCallback() {
86         EndpointImpl endpoint = new EndpointImpl(bus, vnfAdapterNotifyServiceImpl);
87         endpoint.publish("/VNFAdaptercallback");
88         return endpoint;
89     }
90         
91     @Bean
92     public Endpoint sndcAdapterCallback() {
93         EndpointImpl endpoint = new EndpointImpl(bus, sdncAdapterCallbackServiceImpl);
94         endpoint.publish("/SDNCAdapterCallbackService");
95         return endpoint;
96     }
97                 
98     @Bean
99     public Server rsServer() {
100         JAXRSServerFactoryBean endpoint = new JAXRSServerFactoryBean();
101         endpoint.setBus(bus);
102         endpoint.setServiceBeans(Arrays.<Object>asList(wmr, workflowResource, workflowAsyncResource));
103         endpoint.setAddress("/");       
104         endpoint.setFeatures(Arrays.asList(createSwaggerFeature(), new LoggingFeature()));
105         endpoint.setProviders(Arrays.asList(new JacksonJsonProvider(mapper),jaxRsFilterLogging));
106        
107         return endpoint.create();
108     }
109
110     @Bean
111     public Swagger2Feature createSwaggerFeature() {
112         Swagger2Feature swagger2Feature= new Swagger2Feature();
113         swagger2Feature.setPrettyPrint(true);
114         swagger2Feature.setTitle("SO Orchestration Application");
115         swagger2Feature.setContact("The ONAP SO team");
116         swagger2Feature.setDescription("This project is the SO Orchestration Engine");
117         swagger2Feature.setVersion("1.0.0");
118         swagger2Feature.setResourcePackage("org.onap.so.bpmn.common.workflow.service");
119         swagger2Feature.setScan(true);
120         return swagger2Feature;
121     }
122 }