2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Modifications Copyright (c) 2019 Samsung
8 * ================================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=========================================================
23 package org.onap.so.bpmn.infrastructure;
25 import java.util.Arrays;
26 import javax.xml.ws.Endpoint;
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.logging.cxf.interceptor.SOAPLoggingInInterceptor;
40 import org.onap.so.logging.cxf.interceptor.SOAPLoggingOutInterceptor;
41 import org.onap.so.logging.jaxrs.filter.JaxRsFilterLogging;
42 import org.slf4j.Logger;
43 import org.slf4j.LoggerFactory;
44 import org.springframework.beans.factory.annotation.Autowired;
45 import org.springframework.boot.web.servlet.ServletRegistrationBean;
46 import org.springframework.context.annotation.Bean;
47 import org.springframework.context.annotation.Configuration;
48 import com.fasterxml.jackson.databind.ObjectMapper;
49 import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
53 public class CXFConfiguration {
55 private static final Logger logger = LoggerFactory.getLogger(CXFConfiguration.class);
61 private WorkflowMessageResource wmr;
64 private WorkflowResource workflowResource;
67 private WorkflowAsyncResource workflowAsyncResource;
70 private JaxRsFilterLogging jaxRsFilterLogging;
73 private ObjectMapper mapper;
76 private SDNCCallbackAdapterPortType sdncAdapterCallbackServiceImpl;
79 private VnfAdapterNotify vnfAdapterNotifyServiceImpl;
82 public ServletRegistrationBean cxfServlet() {
83 return new ServletRegistrationBean(new CXFServlet(), "/mso/*");
87 public Endpoint vnfAdapterCallback() {
88 EndpointImpl endpoint = new EndpointImpl(bus, vnfAdapterNotifyServiceImpl);
89 endpoint.publish("/VNFAdaptercallback");
90 endpoint.getInInterceptors().add(new SOAPLoggingInInterceptor());
91 endpoint.getOutInterceptors().add(new SOAPLoggingOutInterceptor());
92 endpoint.getOutFaultInterceptors().add(new SOAPLoggingOutInterceptor());
97 public Endpoint sndcAdapterCallback() {
98 EndpointImpl endpoint = new EndpointImpl(bus, sdncAdapterCallbackServiceImpl);
99 endpoint.publish("/SDNCAdapterCallbackService");
100 endpoint.getInInterceptors().add(new SOAPLoggingInInterceptor());
101 endpoint.getOutInterceptors().add(new SOAPLoggingOutInterceptor());
102 endpoint.getOutFaultInterceptors().add(new SOAPLoggingOutInterceptor());
107 public Server rsServer() {
108 JAXRSServerFactoryBean endpoint = new JAXRSServerFactoryBean();
109 endpoint.setBus(bus);
110 endpoint.setServiceBeans(Arrays.<Object>asList(wmr, workflowResource, workflowAsyncResource));
111 endpoint.setAddress("/");
112 endpoint.setFeatures(Arrays.asList(createSwaggerFeature(), new LoggingFeature()));
113 endpoint.setProviders(Arrays.asList(new JacksonJsonProvider(mapper), jaxRsFilterLogging));
115 return endpoint.create();
119 public Swagger2Feature createSwaggerFeature() {
120 Swagger2Feature swagger2Feature = new Swagger2Feature();
121 swagger2Feature.setPrettyPrint(true);
122 swagger2Feature.setTitle("SO Orchestration Application");
123 swagger2Feature.setContact("The ONAP SO team");
124 swagger2Feature.setDescription("This project is the SO Orchestration Engine");
125 swagger2Feature.setVersion("1.0.0");
126 swagger2Feature.setResourcePackage("org.onap.so.bpmn.common.workflow.service");
127 swagger2Feature.setScan(true);
128 return swagger2Feature;