Makes hosted mode really, really work with -noserver when the remote process is serving from your WAR folder.
- The reason for the refactor is that the code now captured in HostedMode.doStartup() was not getting run in -noserver mode
- Will sort in a follow-up commit.
Review by: bobv
git-svn-id: https://google-web-toolkit.googlecode.com/svn/releases/1.6@4317 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/dev/core/src/com/google/gwt/dev/GWTShell.java b/dev/core/src/com/google/gwt/dev/GWTShell.java
index 63c70b2..d40783b 100644
--- a/dev/core/src/com/google/gwt/dev/GWTShell.java
+++ b/dev/core/src/com/google/gwt/dev/GWTShell.java
@@ -194,13 +194,14 @@
}
@Override
- protected void shutDownServer() {
+ protected void doShutDownServer() {
// Stop the HTTP server.
//
EmbeddedTomcatServer.stop();
}
- protected int startUpServer() {
+ @Override
+ protected int doStartUpServer() {
// TODO(bruce): make tomcat work in terms of the modular launcher
String whyFailed = EmbeddedTomcatServer.start(getTopLogger(), getPort(),
options);
diff --git a/dev/core/src/com/google/gwt/dev/HostedMode.java b/dev/core/src/com/google/gwt/dev/HostedMode.java
index 351e10b..71dc0f5 100644
--- a/dev/core/src/com/google/gwt/dev/HostedMode.java
+++ b/dev/core/src/com/google/gwt/dev/HostedMode.java
@@ -269,7 +269,7 @@
}
@Override
- protected void shutDownServer() {
+ protected void doShutDownServer() {
if (server != null) {
try {
server.stop();
@@ -285,7 +285,10 @@
}
@Override
- protected int startUpServer() {
+ protected boolean doStartup() {
+ if (!super.doStartup()) {
+ return false;
+ }
tempWorkDir = options.getWorkDir() == null;
if (tempWorkDir) {
try {
@@ -293,7 +296,7 @@
} catch (IOException e) {
System.err.println("Unable to create hosted mode work directory");
e.printStackTrace();
- return -1;
+ return false;
}
}
@@ -314,10 +317,14 @@
link(loadLogger, module, false);
} catch (UnableToCompleteException e) {
// Already logged.
- return -1;
+ return false;
}
}
+ return true;
+ }
+ @Override
+ protected int doStartUpServer() {
try {
TreeLogger serverLogger = getTopLogger().branch(TreeLogger.INFO,
"Starting HTTP on port " + getPort(), null);
diff --git a/dev/core/src/com/google/gwt/dev/HostedModeBase.java b/dev/core/src/com/google/gwt/dev/HostedModeBase.java
index 1c5f4d4..f3d8078 100644
--- a/dev/core/src/com/google/gwt/dev/HostedModeBase.java
+++ b/dev/core/src/com/google/gwt/dev/HostedModeBase.java
@@ -530,6 +530,18 @@
return true;
}
+ protected boolean doStartup() {
+ loadRequiredNativeLibs();
+
+ // Create the main app window.
+ openAppWindow();
+
+ // Initialize the logger.
+ //
+ initializeLogger();
+ return true;
+ }
+
/**
* Derived classes can override to set a default port.
*/
@@ -622,11 +634,9 @@
if (!runTomcat) {
return;
}
- shutDownServer();
+ doShutDownServer();
}
- protected abstract void shutDownServer();
-
protected void sleep() {
display.sleep();
}
@@ -638,17 +648,12 @@
started = true;
- loadRequiredNativeLibs();
-
- // Create the main app window.
- openAppWindow();
-
- // Initialize the logger.
- //
- initializeLogger();
+ if (!doStartup()) {
+ return false;
+ }
if (runTomcat) {
- int resultPort = startUpServer();
+ int resultPort = doStartUpServer();
if (resultPort < 0) {
return false;
}
@@ -658,7 +663,9 @@
return true;
}
- protected abstract int startUpServer();
+ protected abstract void doShutDownServer();
+
+ protected abstract int doStartUpServer();
private Shell createTrackedBrowserShell() {
final Shell shell = new Shell(display);