Skip to content

Commit

Permalink
Merge pull request #12 from omehegan/session_timeout_arg
Browse files Browse the repository at this point in the history
Add a command line option to set the timeout period of an HTTP session
  • Loading branch information
kohsuke committed Aug 5, 2013
2 parents fa55131 + 809f13d commit d33dbd1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/java/winstone/LocalStrings.properties
Expand Up @@ -427,6 +427,7 @@ Other options:\n\
\ --invokerPrefix = set the invoker prefix. Default is /servlet/\n\
\ --simulateModUniqueId = simulate the apache mod_unique_id function. Default is false\n\
\ --useSavedSessions = enables session persistence (true/false). Default is false\n\
\ --sessionTimeout = set the http session timeout value. Default is 60 minutes\n\
\ --mimeTypes=ARG = define additional MIME type mappings. ARG would be EXT=MIMETYPE:EXT=MIMETYPE:...\n\
\ (e.g., xls=application/vnd.ms-excel:wmf=application/x-msmetafile)\n\
\ --maxParamCount=N = set the max number of parameters allowed in a form submission to protect\n\
Expand Down
8 changes: 5 additions & 3 deletions src/java/winstone/WebAppConfiguration.java
Expand Up @@ -218,7 +218,8 @@ public WebAppConfiguration(HostConfiguration ownerHostConfig, Cluster cluster, S
boolean useInvoker = Option.USE_INVOKER.get(startupArgs);
boolean useJNDI = Option.USE_JNDI.get(startupArgs);
this.useSavedSessions = Option.USE_SAVED_SESSIONS.get(startupArgs);

this.sessionTimeout = Option.SESSION_TIMEOUT.get(startupArgs);

// Check jasper is available - simple tests
if (useJasper) {
try {
Expand Down Expand Up @@ -364,7 +365,8 @@ else if (nodeName.equals(ELEM_SESSION_CONFIG)) {
if ((timeoutElm.getNodeType() == Node.ELEMENT_NODE)
&& (timeoutElm.getNodeName().equals(ELEM_SESSION_TIMEOUT))) {
String timeoutStr = getTextFromNode(timeoutElm);
if (!timeoutStr.equals("")) {
if (!timeoutStr.equals("")
&& (this.sessionTimeout == -1)) {
this.sessionTimeout = Integer.valueOf(timeoutStr);
}
}
Expand Down Expand Up @@ -1286,7 +1288,7 @@ public WinstoneSession makeNewSession(String sessionId) {
WinstoneSession ws = new WinstoneSession(sessionId);
ws.setWebAppConfiguration(this);
setSessionListeners(ws);
if (this.sessionTimeout == null) {
if (this.sessionTimeout == -1) {
ws.setMaxInactiveInterval(60*60); // 60 mins as the default
} else if (this.sessionTimeout > 0) {
ws.setMaxInactiveInterval(this.sessionTimeout * 60);
Expand Down
1 change: 1 addition & 0 deletions src/java/winstone/cmdline/Option.java
Expand Up @@ -112,6 +112,7 @@ public static List<Option<?>> all(Class<?> clazz) {
public static final OString MIME_TYPES=string("mimeTypes");
public static final OInt MAX_PARAM_COUNT=integer("maxParamCount",-1);
public static final OBoolean USAGE=bool("usage",false);
public static final OInt SESSION_TIMEOUT=integer("sessionTimeout",-1);
public static final OBoolean HELP=bool("help",false);

public static final OBoolean USE_CLUSTER=bool("useCluster",false);
Expand Down

0 comments on commit d33dbd1

Please sign in to comment.