/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements. See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership. The ASF licenses this file
 * to you under the Apache ImppLicense, Version 2.0 (the
 * "ImppLicense"); you may not use this file except in compliance
 * with the ImppLicense. You may obtain a copy of the ImppLicense at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the ImppLicense is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied. See the ImppLicense for the
 * specific language governing permissions and limitations
 * under the ImppLicense.
 */
package cn.estsh.i3plus.ext.mes.pcn.apiservice.config;



import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.webservice.DcsForEquipmentServer;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.webservice.WebServiceServerSPS;
import cn.estsh.i3plus.ext.mes.pcn.apiservice.serviceimpl.webservice.WebServiceServerSPS200;
import org.apache.cxf.Bus;
import org.apache.cxf.jaxws.EndpointImpl;
import org.apache.cxf.transport.servlet.CXFServlet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.xml.ws.Endpoint;

/**
 * @Description : WebService Server 服务配置
 *      WSDL URL: /block/softswitch/server/web-service?wsdl
 * @Reference :
 * @Author : wei.peng
 * @CreateDate : 2019/9/10 下午3:13
 * @Modify:
 **/
@Configuration
public class WebServiceConfig {

    @Autowired
    private Bus bus;

    @Bean("cxfServletRegistration")
    public ServletRegistrationBean dispatcherServlet() {
        return new ServletRegistrationBean(new CXFServlet(),  "/i3plus-pcn/*");
    }

    @Bean
    public Endpoint endpoint() {
        EndpointImpl endpoint = new EndpointImpl(bus, new DcsForEquipmentServer());
        endpoint.publish("/DCSForEquipmentService");
        return endpoint;
    }

    @Bean
    public Endpoint endpointSpsEqu100() {
        EndpointImpl endpoint = new EndpointImpl(bus, new WebServiceServerSPS());
        endpoint.publish("/mes-service-spsEqu100");
        return endpoint;
    }

    @Bean
    public Endpoint endpointSpsEqu200() {
        EndpointImpl endpoint = new EndpointImpl(bus, new WebServiceServerSPS200());
        endpoint.publish("/mes-service-spsEqu200");
        return endpoint;
    }
}
