Browse Source

Merge pull request #12150 in DESIGN/design from release/11.0 to bugfix/11.0

* commit '5cbacf682fd218600e790b719e33d5ecee5e08c7':
  REPORT-96107 8.0和11.0.2能双开,8.0和11.0.14不能双开--调整
  REPORT-96107 8.0和11.0.2能双开,8.0和11.0.14不能双开--魔数
  REPORT-96107 8.0和11.0.2能双开,8.0和11.0.14不能双开--方案调整
  REPORT-96107 8.0和11.0.2能双开,8.0和11.0.14不能双开
bugfix/11.0
superman 2 years ago
parent
commit
db17f1c9b4
  1. 19
      designer-base/src/main/java/com/fr/design/utils/DesignUtils.java

19
designer-base/src/main/java/com/fr/design/utils/DesignUtils.java

@ -66,8 +66,8 @@ import java.util.concurrent.TimeoutException;
* Some util method of Designer * Some util method of Designer
*/ */
public class DesignUtils { public class DesignUtils {
private static int port = DesignerPort.getInstance().getMessagePort();
private static Integer port;
private static boolean started = false; private static boolean started = false;
@ -80,6 +80,9 @@ public class DesignUtils {
} }
public synchronized static int getPort() { public synchronized static int getPort() {
if (port == null) {
setPort(DesignerPort.getInstance().getMessagePort());
}
return port; return port;
} }
@ -93,7 +96,6 @@ public class DesignUtils {
return started; return started;
} }
/** /**
* 判断设计器端口是否被其他程序占用 * 判断设计器端口是否被其他程序占用
* 尝试去通信无回应就是其他程序占用端口否则需要继续判断是否为设计器进程未关闭 * 尝试去通信无回应就是其他程序占用端口否则需要继续判断是否为设计器进程未关闭
@ -103,7 +105,7 @@ public class DesignUtils {
public static boolean isPortOccupied() { public static boolean isPortOccupied() {
ExecutorService executor = null; ExecutorService executor = null;
Future<String> future = null; Future<String> future = null;
try (Socket socket = new Socket("localhost", port); try (Socket socket = new Socket("localhost", getPort());
BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream(), StandardCharsets.UTF_8)); BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream(), StandardCharsets.UTF_8));
PrintWriter writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(socket.getOutputStream(), StandardCharsets.UTF_8)))) { PrintWriter writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(socket.getOutputStream(), StandardCharsets.UTF_8)))) {
writer.println("check"); writer.println("check");
@ -167,7 +169,7 @@ public class DesignUtils {
if (lines == null || lines.length == 0) { if (lines == null || lines.length == 0) {
return; return;
} }
try (Socket socket = new Socket("localhost", port)) { try (Socket socket = new Socket("localhost", getPort())) {
clientSend(lines, socket); clientSend(lines, socket);
} catch (Exception ignore) { } catch (Exception ignore) {
@ -190,7 +192,7 @@ public class DesignUtils {
try { try {
serverSocket = new ServerSocket(startPort); serverSocket = new ServerSocket(startPort);
} catch (IOException e1) { } catch (IOException e1) {
FineLoggerFactory.getLogger().error("Cannot create server socket on " + port); FineLoggerFactory.getLogger().error("Cannot create server socket on " + getPort());
} }
while (true) { while (true) {
try { try {
@ -221,7 +223,7 @@ public class DesignUtils {
@Override @Override
public void run() { public void run() {
DesignerStartupContext context = DesignerStartupContext.getInstance(); DesignerStartupContext context = DesignerStartupContext.getInstance();
// 如果在启动页展示中 // 如果在启动页展示中
if (DesignerStartupUtil.openTemplateIfOnWaiting(f)) { if (DesignerStartupUtil.openTemplateIfOnWaiting(f)) {
return; return;
@ -231,7 +233,7 @@ public class DesignUtils {
// 之前就有这样的问题 // 之前就有这样的问题
return; return;
} }
// 打开模板 // 打开模板
DesignerContext.getDesignerFrame().openTemplate(new FileFILE(f)); DesignerContext.getDesignerFrame().openTemplate(new FileFILE(f));
} }
@ -250,7 +252,7 @@ public class DesignUtils {
reader.close(); reader.close();
socket.close(); socket.close();
} else { } else {
FineLoggerFactory.getLogger().error("Cannot create server socket on " + port); FineLoggerFactory.getLogger().error("Cannot create server socket on " + getPort());
break; break;
} }
} catch (IOException ignored) { } catch (IOException ignored) {
@ -484,6 +486,7 @@ public class DesignUtils {
/** /**
* 获取设计器可用字体 * 获取设计器可用字体
*
* @return * @return
*/ */
public static String[] getAvailableFontFamilyNames4Report() { public static String[] getAvailableFontFamilyNames4Report() {

Loading…
Cancel
Save