package com.ann.demo.interfaces.config;

import com.ann.demo.interfaces.HomepageDictionary;
import com.ann.demo.interfaces.impl.HomepageDictionaryImpl;
import org.apache.cxf.Bus;
import org.apache.cxf.bus.spring.SpringBus;
import org.apache.cxf.jaxws.EndpointImpl;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.xml.ws.Endpoint;

/**
 * @Author: LeiJiaXin
 * @Date: 2019/6/11 17:13
 */

@Configuration
public class WebServiceConfig {

    /*//默认servlet路径/*,如果覆写则按照自己定义的来
    @Bean
    public ServletRegistrationBean dispatcherServlet() {
        return new ServletRegistrationBean(new CXFServlet(), "/services/*");
    }*/

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

    //把实现类交给spring管理
    @Bean
    public HomepageDictionary homepageDictionary() {
        return new HomepageDictionaryImpl();
    }

    @Bean
    public Endpoint endpoint() {
        System.out.println("-----------------------已发布-------------------------");
        EndpointImpl endpoint = new EndpointImpl(springBus(), homepageDictionary());
        endpoint.publish("HomepageDictionary");
        return endpoint;
    }

}
