通过阅读WebService发布过程的源代码,可以配置自定义的线程池
package org.zln.ws.server; import com.sun.xml.internal.ws.api.BindingID;import com.sun.xml.internal.ws.transport.http.server.EndpointImpl;import org.slf4j.Logger;import org.slf4j.LoggerFactory; import javax.xml.ws.WebServiceFeature;import java.util.concurrent.Executor;import java.util.concurrent.Executors; /** * Created by sherry on 16/12/15. */public class Main { /** * 日志 */ private static Logger logger = LoggerFactory.getLogger(Main.class); public static void main(String[] args) { UserService userService = new UserService(); String address = "http://localhost:8080/Service/UserService"; EndpointImpl endpoint = new EndpointImpl(BindingID.parse(userService.getClass()), userService, new WebServiceFeature[0]); Executor executor = Executors.newFixedThreadPool(2); endpoint.setExecutor(executor); endpoint.publish(address); logger.debug("Service服务发布成功"); } }
时间: 2024-12-21 01:01:00