summaryrefslogtreecommitdiffstats
path: root/server/src/com/vaadin
diff options
context:
space:
mode:
authorVladimir Kulev <me@lightoze.net>2015-11-17 00:40:27 +0200
committerVladimir Kulev <me@lightoze.net>2015-11-17 11:14:35 +0200
commit66f297fe1ad372c2e8904710cce5e069ac61897f (patch)
tree0c437d02ebc85e19f4db7914c70a412e82721a0d /server/src/com/vaadin
parentb0b9f4c80602d9dcb55f328607c27a7a0c524847 (diff)
downloadvaadin-framework-66f297fe1ad372c2e8904710cce5e069ac61897f.tar.gz
vaadin-framework-66f297fe1ad372c2e8904710cce5e069ac61897f.zip
Support on-the-fly compiled CSS hot reload from classpath (#16949)
Change-Id: Iadb9b23697c162705d99a7b9b7fd992766d39b19
Diffstat (limited to 'server/src/com/vaadin')
-rw-r--r--server/src/com/vaadin/server/VaadinServlet.java25
1 files changed, 19 insertions, 6 deletions
diff --git a/server/src/com/vaadin/server/VaadinServlet.java b/server/src/com/vaadin/server/VaadinServlet.java
index 61df02feaa..e7799dac67 100644
--- a/server/src/com/vaadin/server/VaadinServlet.java
+++ b/server/src/com/vaadin/server/VaadinServlet.java
@@ -29,6 +29,7 @@ import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLDecoder;
+import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -65,7 +66,7 @@ import elemental.json.JsonObject;
@SuppressWarnings("serial")
public class VaadinServlet extends HttpServlet implements Constants {
- private static class ScssCacheEntry implements Serializable {
+ private class ScssCacheEntry implements Serializable {
private final String css;
private final List<String> sourceUris;
@@ -119,13 +120,24 @@ public class VaadinServlet extends HttpServlet implements Constants {
long newest = 0;
for (String uri : sourceUris) {
File file = new File(uri);
+ URL resource = getService().getClassLoader().getResource(uri);
+ long lastModified = -1L;
if (file.exists()) {
- newest = Math.max(newest, file.lastModified());
- } else if (!uri.startsWith("VAADIN/")) {
+ lastModified = file.lastModified();
+ } else if (resource != null && resource.getProtocol().equals("file")) {
+ try {
+ file = new File(resource.toURI());
+ if (file.exists()) {
+ lastModified = file.lastModified();
+ }
+ } catch (URISyntaxException e) {
+ getLogger().log(Level.WARNING, "Could not resolve timestamp for " + resource, e);
+ }
+ }
+ if (lastModified == -1L && resource == null) {
/*
- * Ignore missing files starting with VAADIN/ since those
- * are fetched from the classpath, report problem and abort
- * for other files.
+ * Ignore missing files found in the classpath,
+ * report problem and abort for other files.
*/
getLogger()
.log(Level.WARNING,
@@ -134,6 +146,7 @@ public class VaadinServlet extends HttpServlet implements Constants {
// -1 means this cache entry will never be valid
return -1;
}
+ newest = Math.max(newest, lastModified);
}
return newest;