package com.emr.controller;

import org.apache.cxf.Bus;
import org.apache.cxf.bus.CXFBusFactory;
import org.apache.cxf.endpoint.EndpointImplFactory;
import org.apache.cxf.endpoint.dynamic.DynamicClientFactory;
import org.apache.cxf.jaxws.support.JaxWsEndpointImplFactory;

import java.util.List;

/**
 * @ProjectName:
 * @Description:
 * @Param 传输参数
 * @Return
 * @Author: 曾文和
 * @CreateDate: 2019/9/11 16:15
 * @UpdateUser: 曾文和
 * @UpdateDate: 2019/9/11 16:15
 * @UpdateRemark: 更新说明
 * @Version: 1.0
 */
public class JAXDynamicClientFactory extends DynamicClientFactory {
    protected JAXDynamicClientFactory(Bus bus) {
        super(bus);
    }

    @Override
    protected EndpointImplFactory getEndpointImplFactory() {
        return JaxWsEndpointImplFactory.getSingleton();
    }

    @Override
    protected boolean allowWrapperOps() {
        return true;
    }


    public static JAXDynamicClientFactory newInstance() {
        Bus bus = CXFBusFactory.getThreadDefaultBus();
        return new JAXDynamicClientFactory(bus);
    }
    @Override
    public boolean compileJavaSrc(String classPath, List srcList, String dest) {
        org.apache.cxf.common.util.Compiler javaCompiler
                = new org.apache.cxf.common.util.Compiler();
        javaCompiler.setEncoding("UTF-8");
        javaCompiler.setClassPath(classPath);
        javaCompiler.setOutputDir(dest);
        javaCompiler.setTarget("1.8");
        return javaCompiler.compileFiles(srcList);
    }
}
