为WebService指定线程池
Posted KoKo
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了为WebService指定线程池相关的知识,希望对你有一定的参考价值。
通过阅读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服务发布成功");
}
}
以上是关于为WebService指定线程池的主要内容,如果未能解决你的问题,请参考以下文章