You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shiro.apache.org by ka...@apache.org on 2010/01/29 22:44:26 UTC
svn commit: r904636 -
/incubator/shiro/trunk/core/src/main/java/org/apache/shiro/session/mgt/ExecutorServiceSessionValidationScheduler.java
Author: kaosko
Date: Fri Jan 29 21:44:25 2010
New Revision: 904636
URL: http://svn.apache.org/viewvc?rev=904636&view=rev
Log:
Complete - issue SHIRO-133: Automatically shut down the Session validation thread
http://issues.apache.org/jira/browse/SHIRO-133
- Create the executor as a daemon thread and add javadoc for enableSessionValidation()
Modified:
incubator/shiro/trunk/core/src/main/java/org/apache/shiro/session/mgt/ExecutorServiceSessionValidationScheduler.java
Modified: incubator/shiro/trunk/core/src/main/java/org/apache/shiro/session/mgt/ExecutorServiceSessionValidationScheduler.java
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/core/src/main/java/org/apache/shiro/session/mgt/ExecutorServiceSessionValidationScheduler.java?rev=904636&r1=904635&r2=904636&view=diff
==============================================================================
--- incubator/shiro/trunk/core/src/main/java/org/apache/shiro/session/mgt/ExecutorServiceSessionValidationScheduler.java (original)
+++ incubator/shiro/trunk/core/src/main/java/org/apache/shiro/session/mgt/ExecutorServiceSessionValidationScheduler.java Fri Jan 29 21:44:25 2010
@@ -20,6 +20,7 @@
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import org.slf4j.Logger;
@@ -74,9 +75,19 @@
return this.enabled;
}
+ /**
+ * Creates a single thread {@link ScheduledExecutorService} to validate sessions at fixed intervals
+ * and enables this scheduler. The executor is created as a daemon thread to allow JVM to shut down
+ */
public void enableSessionValidation() {
if (this.interval > 0l) {
- this.service = Executors.newSingleThreadScheduledExecutor();
+ this.service = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() {
+ public Thread newThread(Runnable r) {
+ Thread thread = new Thread(r);
+ thread.setDaemon(true);
+ return thread;
+ }
+ });
this.service.scheduleAtFixedRate(this, interval, interval, TimeUnit.MILLISECONDS);
this.enabled = true;
}