langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/server/SjavacServer.java
equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
37 import java.util.Map; |
37 import java.util.Map; |
38 import java.util.Random; |
38 import java.util.Random; |
39 import java.util.concurrent.atomic.AtomicBoolean; |
39 import java.util.concurrent.atomic.AtomicBoolean; |
40 |
40 |
41 import com.sun.tools.sjavac.Util; |
41 import com.sun.tools.sjavac.Util; |
|
42 import com.sun.tools.sjavac.client.PortFileInaccessibleException; |
42 import com.sun.tools.sjavac.comp.PooledSjavac; |
43 import com.sun.tools.sjavac.comp.PooledSjavac; |
43 import com.sun.tools.sjavac.comp.SjavacImpl; |
44 import com.sun.tools.sjavac.comp.SjavacImpl; |
44 |
45 |
45 /** |
46 /** |
46 * The JavacServer class contains methods both to setup a server that responds to requests and methods to connect to this server. |
47 * The JavacServer class contains methods both to setup a server that responds to requests and methods to connect to this server. |
52 */ |
53 */ |
53 public class SjavacServer implements Terminable { |
54 public class SjavacServer implements Terminable { |
54 |
55 |
55 // Used in protocol to indicate which method to invoke |
56 // Used in protocol to indicate which method to invoke |
56 public final static String CMD_COMPILE = "compile"; |
57 public final static String CMD_COMPILE = "compile"; |
57 public final static String CMD_SYS_INFO = "sys-info"; |
|
58 |
58 |
59 final private String portfilename; |
59 final private String portfilename; |
60 final private String logfile; |
60 final private String logfile; |
61 final private String stdouterrfile; |
61 final private String stdouterrfile; |
62 final private int poolsize; |
62 final private int poolsize; |
120 |
120 |
121 |
121 |
122 /** |
122 /** |
123 * Acquire the port file. Synchronized since several threads inside an smart javac wrapper client acquires the same port file at the same time. |
123 * Acquire the port file. Synchronized since several threads inside an smart javac wrapper client acquires the same port file at the same time. |
124 */ |
124 */ |
125 public static synchronized PortFile getPortFile(String filename) throws FileNotFoundException { |
125 public static synchronized PortFile getPortFile(String filename) throws PortFileInaccessibleException { |
126 if (allPortFiles == null) { |
126 if (allPortFiles == null) { |
127 allPortFiles = new HashMap<>(); |
127 allPortFiles = new HashMap<>(); |
128 } |
128 } |
129 PortFile pf = allPortFiles.get(filename); |
129 PortFile pf = allPortFiles.get(filename); |
130 |
130 |