package com.ruoyi.ccb.config;

import com.ruoyi.ccb.service.CcbService;
import lombok.AllArgsConstructor;
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;

@Configuration
@AllArgsConstructor
public class CxfConfig {

    private final CcbService ccbService;

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

    @Bean
    public Endpoint endpoint() {
        EndpointImpl endpoint = new EndpointImpl(springBus(), ccbService);
        endpoint.publish("/ccb");
        return endpoint;
    }

}
