提交 87af4f3a 编写于 作者: K kohsuke

allow ExecutorService to be supplied from outside

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@18901 71c3de6d-444a-0410-be80-ed276b4c234a
上级 00cf9f43
......@@ -49,10 +49,16 @@ public class CLI implements Closeable {
private final ExecutorService pool;
private final Channel channel;
private final CliEntryPoint entryPoint;
private final boolean ownsPool;
public CLI(URL hudson) throws IOException, InterruptedException {
this(hudson,null);
}
public CLI(URL hudson, ExecutorService exec) throws IOException, InterruptedException {
FullDuplexHttpStream con = new FullDuplexHttpStream(hudson);
pool = Executors.newCachedThreadPool();
ownsPool = exec==null;
pool = exec!=null ? exec : Executors.newCachedThreadPool();
channel = new Channel("Chunked connection to "+hudson,
pool,con.getInputStream(),con.getOutputStream());
new PingThread(channel,30*1000) {
......@@ -71,7 +77,8 @@ public class CLI implements Closeable {
public void close() throws IOException {
channel.close();
pool.shutdown();
if(ownsPool)
pool.shutdown();
}
public int execute(List<String> args, InputStream stdin, OutputStream stdout, OutputStream stderr) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册