From e0d77331ce3ee5684e247bda314e633ac4faf18d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Cocula?= Date: Mon, 19 Jun 2017 22:51:59 +0200 Subject: [PATCH 1/2] Add the ability to reload modified jsp if a system property "libresonic.development" is set. --- .../libresonic/player/boot/TomcatApplication.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/libresonic-main/src/main/java/org/libresonic/player/boot/TomcatApplication.java b/libresonic-main/src/main/java/org/libresonic/player/boot/TomcatApplication.java index c1e22296..9503b55a 100644 --- a/libresonic-main/src/main/java/org/libresonic/player/boot/TomcatApplication.java +++ b/libresonic-main/src/main/java/org/libresonic/player/boot/TomcatApplication.java @@ -12,14 +12,20 @@ public class TomcatApplication { tomcatFactory.addContextCustomizers((TomcatContextCustomizer) context -> { + boolean development = (System.getProperty("libresonic.development") != null); + // Increase the size and time before eviction of the Tomcat // cache so that resources aren't uncompressed too often. // See https://github.com/jhipster/generator-jhipster/issues/3995 StandardRoot resources = new StandardRoot(); - resources.setCacheMaxSize(100000); - resources.setCacheObjectMaxSize(4000); - resources.setCacheTtl(24 * 3600 * 1000); // 1 day, in milliseconds + if (development) { + resources.setCachingAllowed(false); + } else { + resources.setCacheMaxSize(100000); + resources.setCacheObjectMaxSize(4000); + resources.setCacheTtl(24 * 3600 * 1000); // 1 day, in milliseconds + } context.setResources(resources); // Put Jasper in production mode so that JSP aren't recompiled @@ -27,7 +33,8 @@ public class TomcatApplication { // See http://stackoverflow.com/questions/29653326/spring-boot-application-slow-because-of-jsp-compilation Container jsp = context.findChild("jsp"); if (jsp instanceof Wrapper) { - ((Wrapper) jsp).addInitParameter("development", "false"); + if (development) + ((Wrapper) jsp).addInitParameter("development", Boolean.toString(development)); } }); } From 5ffec4403a9ce1c6c7677fcb5d5f5dd05498cdd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Cocula?= Date: Mon, 19 Jun 2017 23:07:43 +0200 Subject: [PATCH 2/2] Oops. Remove an unnecessary if statement. --- .../main/java/org/libresonic/player/boot/TomcatApplication.java | 1 - 1 file changed, 1 deletion(-) diff --git a/libresonic-main/src/main/java/org/libresonic/player/boot/TomcatApplication.java b/libresonic-main/src/main/java/org/libresonic/player/boot/TomcatApplication.java index 9503b55a..d8290c8b 100644 --- a/libresonic-main/src/main/java/org/libresonic/player/boot/TomcatApplication.java +++ b/libresonic-main/src/main/java/org/libresonic/player/boot/TomcatApplication.java @@ -33,7 +33,6 @@ public class TomcatApplication { // See http://stackoverflow.com/questions/29653326/spring-boot-application-slow-because-of-jsp-compilation Container jsp = context.findChild("jsp"); if (jsp instanceof Wrapper) { - if (development) ((Wrapper) jsp).addInitParameter("development", Boolean.toString(development)); } });