Browse Source

无JIRA任务,加个锁

master
neil 7 years ago
parent
commit
ea372294ca
  1. 31
      designer_base/src/com/fr/start/StartServer.java

31
designer_base/src/com/fr/start/StartServer.java

@ -34,6 +34,7 @@ public class StartServer {
// 原先的tomcatHost放在类TomcatHost里面,很不方便操作,而且因为存在多个进程的原因, // 原先的tomcatHost放在类TomcatHost里面,很不方便操作,而且因为存在多个进程的原因,
// 原先的getInstance()方法无多大意义 // 原先的getInstance()方法无多大意义
private static TomcatHost tomcatHost = null; private static TomcatHost tomcatHost = null;
private static Object lock = new Object();
static { static {
GeneralContext.addEnvChangedListener(new EnvChangedListener() { GeneralContext.addEnvChangedListener(new EnvChangedListener() {
@ -80,15 +81,17 @@ public class StartServer {
} }
private static void initDemoServerAndBrowser() { private static void initDemoServerAndBrowser() {
if (tomcatHost != null) { synchronized (lock) {
if (!tomcatHost.isDemoAppLoaded()) { if (tomcatHost != null) {
tomcatHost.exit(); if (!tomcatHost.isDemoAppLoaded()) {
tomcatHost.exit();
tomcatHost = new TomcatHost(DesignerEnvManager.getEnvManager().getJettyServerPort());
tomcatHost.addAndStartInstallHomeWebApp();
}
} else {
tomcatHost = new TomcatHost(DesignerEnvManager.getEnvManager().getJettyServerPort()); tomcatHost = new TomcatHost(DesignerEnvManager.getEnvManager().getJettyServerPort());
tomcatHost.addAndStartInstallHomeWebApp(); tomcatHost.addAndStartInstallHomeWebApp();
} }
} else {
tomcatHost = new TomcatHost(DesignerEnvManager.getEnvManager().getJettyServerPort());
tomcatHost.addAndStartInstallHomeWebApp();
} }
try { try {
if (!tomcatHost.isStarted()) { if (!tomcatHost.isStarted()) {
@ -105,17 +108,19 @@ public class StartServer {
public static void start() { public static void start() {
try { try {
if (tomcatHost != null) { synchronized (lock) {
if (NEED_LOAD_ENV) { if (tomcatHost != null) {
tomcatHost.exit(); if (NEED_LOAD_ENV) {
tomcatHost.exit();
tomcatHost = new TomcatHost(DesignerEnvManager.getEnvManager().getJettyServerPort());
tomcatHost.addAndStartLocalEnvHomeWebApp();
}
} else {
tomcatHost = new TomcatHost(DesignerEnvManager.getEnvManager().getJettyServerPort()); tomcatHost = new TomcatHost(DesignerEnvManager.getEnvManager().getJettyServerPort());
tomcatHost.addAndStartLocalEnvHomeWebApp(); tomcatHost.addAndStartLocalEnvHomeWebApp();
} }
} else {
tomcatHost = new TomcatHost(DesignerEnvManager.getEnvManager().getJettyServerPort());
tomcatHost.addAndStartLocalEnvHomeWebApp();
} }
if (!tomcatHost.isStarted()) { if (!tomcatHost.isStarted()) {
tomcatHost.start(); tomcatHost.start();

Loading…
Cancel
Save