FELIX-3199 Add org.apache.felix.http.session.timeout configuration property to specify the session timeout in minutes (as in the web application configuration web.xml file)

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1197019 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyConfig.java b/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyConfig.java
index 177412a..180e966 100644
--- a/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyConfig.java
+++ b/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyConfig.java
@@ -73,6 +73,9 @@
     /** Felix specific property to control whether Jetty uses NIO or not for HTTPS. Valid values are "true", "false". Default is the value of org.apache.felix.http.nio */
     public static final String  FELIX_HTTPS_NIO = "org.apache.felix.https.nio";
 
+    /** Felix specific property to configure the session timeout in minutes (same session-timout in web.xml). Default is servlet container specific */
+    public static final String FELIX_SESSION_TIMEOUT = "org.apache.felix.http.session.timeout";
+
     /** Felix specific property to enable Jetty MBeans. Valid values are "true", "false". Default is false */
     public static final String  FELIX_HTTP_MBEANS = "org.apache.felix.http.mbeans";
 
@@ -92,6 +95,7 @@
     private boolean useHttpNio;
     private boolean useHttpsNio;
     private boolean registerMBeans;
+    private int sessionTimeout;
 
     /**
      * Properties from the configuration not matching any of the
@@ -194,6 +198,15 @@
         return this.clientcert;
     }
 
+    /**
+     * Returns the configured session timeout in minutes or zero if not
+     * configured.
+     */
+    public int getSessionTimeout()
+    {
+        return this.sessionTimeout;
+    }
+
     public void reset()
     {
         update(null);
@@ -220,6 +233,7 @@
         this.useHttpNio = getBooleanProperty(props, FELIX_HTTP_NIO, true);
         this.useHttpsNio = getBooleanProperty(props, FELIX_HTTPS_NIO, this.useHttpNio);
         this.registerMBeans = getBooleanProperty(props, FELIX_HTTP_MBEANS, false);
+        this.sessionTimeout = getIntProperty(props, FELIX_SESSION_TIMEOUT, 0);
 
         // copy rest of the properties
         Enumeration keys = props.keys();
diff --git a/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java b/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java
index b709395..5fdb887 100644
--- a/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java
+++ b/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java
@@ -317,6 +317,9 @@
     private void configureSessionManager(final Context context)
     {
         final SessionManager manager = context.getSessionHandler().getSessionManager();
+
+        manager.setMaxInactiveInterval(this.config.getSessionTimeout() * 60);
+
         manager.setSessionCookie(this.config.getProperty(SessionManager.__SessionCookieProperty, SessionManager.__DefaultSessionCookie));
         manager.setSessionURL(this.config.getProperty(SessionManager.__SessionURLProperty, SessionManager.__DefaultSessionURL));
         manager.setSessionDomain(this.config.getProperty(SessionManager.__SessionDomainProperty, SessionManager.__DefaultSessionDomain));