From 22e8478aa364609eb93ad873d179492ba5048ff8 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Mon, 8 Dec 2014 10:52:54 -0800 Subject: [PATCH 1/2] Cross-reference "Create a deployable war" how-to Add a tip for both the Maven and Gradle "Packaging executable jar and war files" section referring to the how-to. Fixes gh-2086 --- spring-boot-docs/src/main/asciidoc/build-tool-plugins.adoc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/spring-boot-docs/src/main/asciidoc/build-tool-plugins.adoc b/spring-boot-docs/src/main/asciidoc/build-tool-plugins.adoc index fcadd0f9ff..f82328ef80 100644 --- a/spring-boot-docs/src/main/asciidoc/build-tool-plugins.adoc +++ b/spring-boot-docs/src/main/asciidoc/build-tool-plugins.adoc @@ -154,6 +154,9 @@ need to mark the embedded container dependencies as "`provided`", e.g: ---- +TIP: See the "`<>`" section for more details on +how to create a deployable war file. + Advanced configuration options and examples are available in the {spring-boot-maven-plugin-site}/[plugin info page]. @@ -359,6 +362,10 @@ named "`providedRuntime`", e.g: } ---- +TIP: See the "`<>`" section for more details on +how to create a deployable war file. + + [[build-tool-plugins-gradle-running-applications]] === Running a project in-place From c23a764a1c9d4095c23a1f9a6c2df1d599add35c Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Mon, 8 Dec 2014 11:11:22 -0800 Subject: [PATCH 2/2] Set the default session timeout to 30 mins Update AbstractConfigurableEmbeddedServletContainer to set the default session timeout to 30 minutes. Also correct Javadoc to specify that the default is '30 minutes'. Fixes gh-2084 --- .../AbstractConfigurableEmbeddedServletContainer.java | 5 ++++- .../embedded/ConfigurableEmbeddedServletContainer.java | 4 ++-- .../jetty/JettyEmbeddedServletContainerFactory.java | 7 ++++--- .../tomcat/TomcatEmbeddedServletContainerFactory.java | 8 ++++---- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/spring-boot/src/main/java/org/springframework/boot/context/embedded/AbstractConfigurableEmbeddedServletContainer.java b/spring-boot/src/main/java/org/springframework/boot/context/embedded/AbstractConfigurableEmbeddedServletContainer.java index f341ffd2c4..e29af11a8b 100644 --- a/spring-boot/src/main/java/org/springframework/boot/context/embedded/AbstractConfigurableEmbeddedServletContainer.java +++ b/spring-boot/src/main/java/org/springframework/boot/context/embedded/AbstractConfigurableEmbeddedServletContainer.java @@ -37,6 +37,9 @@ import org.springframework.util.Assert; public abstract class AbstractConfigurableEmbeddedServletContainer implements ConfigurableEmbeddedServletContainer { + private static final int DEFAULT_SESSION_TIMEOUT = (int) TimeUnit.SECONDS + .toMinutes(30); + private String contextPath = ""; private boolean registerDefaultServlet = true; @@ -57,7 +60,7 @@ public abstract class AbstractConfigurableEmbeddedServletContainer implements private InetAddress address; - private int sessionTimeout; + private int sessionTimeout = DEFAULT_SESSION_TIMEOUT; private Ssl ssl; diff --git a/spring-boot/src/main/java/org/springframework/boot/context/embedded/ConfigurableEmbeddedServletContainer.java b/spring-boot/src/main/java/org/springframework/boot/context/embedded/ConfigurableEmbeddedServletContainer.java index ff06841579..21531ad0bf 100644 --- a/spring-boot/src/main/java/org/springframework/boot/context/embedded/ConfigurableEmbeddedServletContainer.java +++ b/spring-boot/src/main/java/org/springframework/boot/context/embedded/ConfigurableEmbeddedServletContainer.java @@ -49,8 +49,8 @@ public interface ConfigurableEmbeddedServletContainer { void setPort(int port); /** - * The session timeout in seconds (default 30). If 0 or negative then sessions never - * expire. + * The session timeout in seconds (default 30 minutes). If 0 or negative then sessions + * never expire. * @param sessionTimeout the session timeout */ void setSessionTimeout(int sessionTimeout); diff --git a/spring-boot/src/main/java/org/springframework/boot/context/embedded/jetty/JettyEmbeddedServletContainerFactory.java b/spring-boot/src/main/java/org/springframework/boot/context/embedded/jetty/JettyEmbeddedServletContainerFactory.java index ae96d19186..06f18a89f7 100644 --- a/spring-boot/src/main/java/org/springframework/boot/context/embedded/jetty/JettyEmbeddedServletContainerFactory.java +++ b/spring-boot/src/main/java/org/springframework/boot/context/embedded/jetty/JettyEmbeddedServletContainerFactory.java @@ -28,6 +28,7 @@ import java.util.List; import org.eclipse.jetty.http.MimeTypes; import org.eclipse.jetty.server.Connector; import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.server.SessionManager; import org.eclipse.jetty.server.handler.ErrorHandler; import org.eclipse.jetty.server.ssl.SslSocketConnector; import org.eclipse.jetty.servlet.ErrorPageErrorHandler; @@ -227,13 +228,13 @@ public class JettyEmbeddedServletContainerFactory extends .getClassLoader())) { addJspServlet(context); } - ServletContextInitializer[] initializersToUse = mergeInitializers(initializers); Configuration[] configurations = getWebAppContextConfigurations(context, initializersToUse); context.setConfigurations(configurations); - context.getSessionHandler().getSessionManager() - .setMaxInactiveInterval(getSessionTimeout()); + int sessionTimeout = (getSessionTimeout() > 0 ? getSessionTimeout() : -1); + SessionManager sessionManager = context.getSessionHandler().getSessionManager(); + sessionManager.setMaxInactiveInterval(sessionTimeout); postProcessWebAppContext(context); } diff --git a/spring-boot/src/main/java/org/springframework/boot/context/embedded/tomcat/TomcatEmbeddedServletContainerFactory.java b/spring-boot/src/main/java/org/springframework/boot/context/embedded/tomcat/TomcatEmbeddedServletContainerFactory.java index 51fa948a82..f3e17fcdb7 100644 --- a/spring-boot/src/main/java/org/springframework/boot/context/embedded/tomcat/TomcatEmbeddedServletContainerFactory.java +++ b/spring-boot/src/main/java/org/springframework/boot/context/embedded/tomcat/TomcatEmbeddedServletContainerFactory.java @@ -344,12 +344,12 @@ public class TomcatEmbeddedServletContainerFactory extends for (MimeMappings.Mapping mapping : getMimeMappings()) { context.addMimeMapping(mapping.getExtension(), mapping.getMimeType()); } - long timeout = getSessionTimeout(); - if (timeout > 0) { + long sessionTimeout = getSessionTimeout(); + if (sessionTimeout > 0) { // Tomcat timeouts are in minutes - timeout = Math.max(TimeUnit.SECONDS.toMinutes(timeout), 1L); + sessionTimeout = Math.max(TimeUnit.SECONDS.toMinutes(sessionTimeout), 1L); } - context.setSessionTimeout((int) timeout); + context.setSessionTimeout((int) sessionTimeout); for (TomcatContextCustomizer customizer : this.tomcatContextCustomizers) { customizer.customize(context); }