2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.so.bpmn.infrastructure;
23 import java.util.Arrays;
25 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.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;
46 import com.fasterxml.jackson.databind.ObjectMapper;
47 import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
51 public class CXFConfiguration {
53 private static final MsoLogger logger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL,CXFConfiguration.class);
59 private WorkflowMessageResource wmr;
62 private WorkflowResource workflowResource;
65 private WorkflowAsyncResource workflowAsyncResource;
68 private JaxRsFilterLogging jaxRsFilterLogging;
71 private ObjectMapper mapper;
74 private SDNCCallbackAdapterPortType sdncAdapterCallbackServiceImpl;
77 private VnfAdapterNotify vnfAdapterNotifyServiceImpl;
80 public ServletRegistrationBean cxfServlet() {
81 return new ServletRegistrationBean(new CXFServlet(), "/mso/*");
85 public Endpoint vnfAdapterCallback() {
86 EndpointImpl endpoint = new EndpointImpl(bus, vnfAdapterNotifyServiceImpl);
87 endpoint.publish("/VNFAdaptercallback");
92 public Endpoint sndcAdapterCallback() {
93 EndpointImpl endpoint = new EndpointImpl(bus, sdncAdapterCallbackServiceImpl);
94 endpoint.publish("/SDNCAdapterCallbackService");
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));
107 return endpoint.create();
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;