Serve GWT UI from ResourceServlet
We already have a somewhat-featureful static content servlet for serving data from /static; use it for the GWT UI as well. Java's zip filesystem support makes the war case easy; we don't have to do the extract-to-a-directory hack that makes it work with Jetty. The developer case is also pretty easy, though we have to move the filter to recompile the GWT UI into the httpd package. One other wrinkle is that the GWT build process puts bogus timestamps on the GWT compiler output, so we need to pretend the timestamps on all the files are the startup time of the server. This means clients will have to re-download large identical JS assets after a server restart even if the assets didn't change. Gerrit has mostly pretty good uptime so this is not a huge deal. Change-Id: I0a7ade3cadf3a4a4e1726b56b87b0cbe4c6e0c93
This commit is contained in:
@@ -27,12 +27,16 @@ import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.net.JarURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.nio.file.FileSystem;
|
||||
import java.nio.file.FileSystems;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.security.CodeSource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.SortedMap;
|
||||
@@ -296,6 +300,7 @@ public final class GerritLauncher {
|
||||
}
|
||||
|
||||
private static volatile File myArchive;
|
||||
private static volatile FileSystem myArchiveFs;
|
||||
private static volatile File myHome;
|
||||
|
||||
/**
|
||||
@@ -304,11 +309,29 @@ public final class GerritLauncher {
|
||||
* @return local path of the Gerrit WAR file.
|
||||
* @throws FileNotFoundException if the code cannot guess the location.
|
||||
*/
|
||||
public static File getDistributionArchive() throws FileNotFoundException {
|
||||
if (myArchive == null) {
|
||||
myArchive = locateMyArchive();
|
||||
public static File getDistributionArchive()
|
||||
throws FileNotFoundException, IOException {
|
||||
File result = myArchive;
|
||||
if (result == null) {
|
||||
synchronized (GerritLauncher.class) {
|
||||
result = myArchive;
|
||||
if (result != null) {
|
||||
return result;
|
||||
}
|
||||
result = locateMyArchive();
|
||||
myArchiveFs = FileSystems.newFileSystem(
|
||||
URI.create("jar:" + result.toPath().toUri()),
|
||||
Collections.<String, String> emptyMap());
|
||||
myArchive = result;
|
||||
}
|
||||
}
|
||||
return myArchive;
|
||||
return result;
|
||||
}
|
||||
|
||||
public static FileSystem getDistributionArchiveFileSystem()
|
||||
throws FileNotFoundException, IOException {
|
||||
getDistributionArchive();
|
||||
return myArchiveFs;
|
||||
}
|
||||
|
||||
private static File locateMyArchive() throws FileNotFoundException {
|
||||
|
||||
Reference in New Issue
Block a user