aboutsummaryrefslogtreecommitdiff
path: root/id/server/idserverlib/src
diff options
context:
space:
mode:
authorChristian Maierhofer <cmaierhofer@iaik.tugraz.at>2016-05-18 13:36:13 +0200
committerChristian Maierhofer <cmaierhofer@iaik.tugraz.at>2016-05-18 13:36:13 +0200
commit3d88ece5e3ed76f9a023681d5cd2d5a19a863c6f (patch)
tree5a5841ffe8db610d8207607f714f2b53a62afe9d /id/server/idserverlib/src
parent33da825e528c4b04bba9de09ed386bcf606aec39 (diff)
downloadmoa-id-spss-3d88ece5e3ed76f9a023681d5cd2d5a19a863c6f.tar.gz
moa-id-spss-3d88ece5e3ed76f9a023681d5cd2d5a19a863c6f.tar.bz2
moa-id-spss-3d88ece5e3ed76f9a023681d5cd2d5a19a863c6f.zip
Spring-ified AuthenticationSessionCleaner
Diffstat (limited to 'id/server/idserverlib/src')
-rw-r--r--id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/AuthenticationSessionCleaner.java29
1 files changed, 6 insertions, 23 deletions
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/AuthenticationSessionCleaner.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/AuthenticationSessionCleaner.java
index e0552c337..bbb322a4f 100644
--- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/AuthenticationSessionCleaner.java
+++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/AuthenticationSessionCleaner.java
@@ -8,6 +8,8 @@ import java.util.List;
import org.hibernate.HibernateException;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import at.gv.egovernment.moa.id.advancedlogging.TransactionIDUtils;
@@ -29,6 +31,7 @@ import at.gv.egovernment.moa.util.MiscUtil;
* @version $Id$
*/
@Service("AuthenticationSessionCleaner")
+@EnableScheduling
public class AuthenticationSessionCleaner implements Runnable {
@Autowired private IAuthenticationSessionStoreage authenticationSessionStorage;
@@ -36,7 +39,7 @@ public class AuthenticationSessionCleaner implements Runnable {
@Autowired protected AuthConfiguration authConfig;
/** interval the <code>AuthenticationSessionCleaner</code> is run in */
- private static final long SESSION_CLEANUP_INTERVAL = 5 * 60; // 5 min
+ private static final long SESSION_CLEANUP_INTERVAL = 5 * 60 *1000 ; // 5 min
/**
* Runs the thread. Cleans the <code>AuthenticationServer</code> session store
@@ -45,8 +48,8 @@ public class AuthenticationSessionCleaner implements Runnable {
* Cleans up expired session and authentication data stores.
*
*/
+ @Scheduled(fixedRate = SESSION_CLEANUP_INTERVAL)
public void run() {
- while (true) {
try {
Logger.debug("AuthenticationSessionCleaner run");
Date now = new Date();
@@ -66,7 +69,7 @@ public class AuthenticationSessionCleaner implements Runnable {
try {
try {
Object entry = transactionStorage.get(entryKey);
- //if entry is an exception --> log it because is could be unhandled
+ //if entry is an exception --> log it because it could be unhandled
if (entry != null && entry instanceof ExceptionContainer) {
ExceptionContainer exContainer = (ExceptionContainer) entry;
@@ -115,12 +118,6 @@ public class AuthenticationSessionCleaner implements Runnable {
} catch (Exception e) {
Logger.error(MOAIDMessageProvider.getInstance().getMessage("cleaner.01", null), e);
}
- try {
- Thread.sleep(SESSION_CLEANUP_INTERVAL * 1000);
- }
- catch (InterruptedException e) {
- }
- }
}
/**
@@ -143,18 +140,4 @@ public class AuthenticationSessionCleaner implements Runnable {
}
}
}
-
- /**
- * start the sessionCleaner
- */
- public static void start(Runnable clazz) {
- // start the session cleanup thread
- Thread sessionCleaner =
- new Thread(clazz, "AuthenticationSessionCleaner");
- sessionCleaner.setName("SessionCleaner");
- sessionCleaner.setDaemon(true);
- sessionCleaner.setPriority(Thread.MIN_PRIORITY);
- sessionCleaner.start();
- }
-
}