package com.unissoft.serviceconfig;

import com.unissoft.webservice.*;
import com.unissoft.webservice.impl.*;
import org.apache.cxf.Bus;
import org.apache.cxf.bus.spring.SpringBus;
import org.apache.cxf.jaxws.EndpointImpl;
import org.apache.cxf.transport.servlet.CXFServlet;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.xml.ws.Endpoint;

@Configuration
public class CxfConfig {

    @Bean(name = Bus.DEFAULT_BUS_ID)
    public SpringBus springBus() {
        return new SpringBus();
    }

    //温度
    @Bean
    public GrainTemperatureService grainTemperatureService() {
        return new GrainTemperatureServiceImpl();
    }
    @Bean
    public Endpoint uploadGrainTemperatureData() {
        EndpointImpl endpoint = new EndpointImpl(springBus(), grainTemperatureService());
        endpoint.publish("/uploadGrainTemperatureData");
        return endpoint;
    }

    //虫害
    @Bean
    public InsectPestService insectPestService() {
        return new InsectPestServiceImpl();
    }
    @Bean
    public Endpoint uploadInsectPestData() {
        EndpointImpl endpoint = new EndpointImpl(springBus(), insectPestService());
        endpoint.publish("/uploadInsectPestData");
        return endpoint;
    }

    //气体
    @Bean
    public GassService gassService() {
        return new GassServiceImpl();
    }
    @Bean
    public Endpoint uploadGasData() {
        EndpointImpl endpoint = new EndpointImpl(springBus(), gassService());
        endpoint.publish("/uploadGasData");
        return endpoint;
    }

    //多通道气体
    @Bean
    public GasssService gasssService() {
        return new GasssServiceImpl();
    }
    @Bean
    public Endpoint uploadGassData() {
        EndpointImpl endpoint = new EndpointImpl(springBus(), gasssService());
        endpoint.publish("/uploadGassData");
        return endpoint;
    }

    //能耗
    @Bean
    public EnergyService energyService() {
        return new EnergyServiceImpl();
    }
    @Bean
    public Endpoint uploadEenergyData() {
        EndpointImpl endpoint = new EndpointImpl(springBus(), energyService());
        endpoint.publish("/uploadEenergyData");
        return endpoint;
    }

    //数量
    @Bean
    public NumberService numberService() {
        return new NumberServiceImpl();
    }
    @Bean
    public Endpoint uploadNumberData() {
        EndpointImpl endpoint = new EndpointImpl(springBus(), numberService());
        endpoint.publish("/uploadNumberData");
        return endpoint;
    }

    //气象检测记录
    @Bean
    public WeatherService weatherService() {
        return new WeatherServiceImpl();
    }
    @Bean
    public Endpoint uploadWeatherData() {
        EndpointImpl endpoint = new EndpointImpl(springBus(), weatherService());
        endpoint.publish("/uploadWeatherData");
        return endpoint;
    }

    //基础数据信息
    @Bean
    public BasicDataSynchroService basicDataSynchroService() {
        return new BasicDataSynchroServiceImpl();
    }
    @Bean
    public Endpoint uploadGrainpointData() {
        EndpointImpl endpoint = new EndpointImpl(springBus(), basicDataSynchroService());
        endpoint.publish("/basicDataSynchro");
        return endpoint;
    }

}
