org.olat.core.logging.activity
Class ThreadLocalUserActivityLoggerInstaller

java.lang.Object
  extended by org.olat.core.logging.activity.ThreadLocalUserActivityLoggerInstaller

public class ThreadLocalUserActivityLoggerInstaller
extends java.lang.Object

Helper class to install the IUserActivityLogger with the ThreadLocalUserActivityLogger.

This class should only be used in a few select core olat places to assure a ThreadLocalUserActivityLogger is set up during event handling and in doDispose().

There are two groups of methods in this class: those used for running a piece of code with a guaranteed and managed IUserActivityLogger set in the ThreadLocalUserActivityLogger - and those doing initialization.

Initial Date: 21.10.2009

Author:
Stefan

Constructor Summary
ThreadLocalUserActivityLoggerInstaller()
           
 
Method Summary
static IUserActivityLogger createEmptyUserActivityLogger()
          FRAMEWORK USE ONLY Returns an empty UserActivityLogger
static void initEmptyUserActivityLogger()
          FRAMEWORK USE ONLY Sets the ThreadLocal's UserActivityLogger to a generic one
static void initUserActivityLogger(javax.servlet.http.HttpServletRequest request)
          FRAMEWORK USE ONLY Sets the ThreadLocal's UserActivityLogger to a generic one wrapping the given request's session
static void resetUserActivityLogger()
          FRAMEWORK USE ONLY Sets the ThreadLocal's UserActivityLogger back to null
static void runWithUserActivityLogger(java.lang.Runnable runnable, IUserActivityLogger logger)
          Run the given runnable with the given IUserActivityLogger as the ThreadLocalUserActivityLogger.
static void runWithUserActivityLoggerWithException(RunnableWithException runnable, IUserActivityLogger logger)
          Run the given runnable (which allows an Exception to be thrown) with the given IUserActivityLogger as the ThreadLocalUserActivityLogger.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ThreadLocalUserActivityLoggerInstaller

public ThreadLocalUserActivityLoggerInstaller()
Method Detail

runWithUserActivityLoggerWithException

public static void runWithUserActivityLoggerWithException(RunnableWithException runnable,
                                                          IUserActivityLogger logger)
                                                   throws java.lang.Exception
Run the given runnable (which allows an Exception to be thrown) with the given IUserActivityLogger as the ThreadLocalUserActivityLogger.

Parameters:
runnable - the runnable to be run
logger - the logger to be set during the runnable.run call
Throws:
java.lang.Exception - thrown by runnable.run

runWithUserActivityLogger

public static void runWithUserActivityLogger(java.lang.Runnable runnable,
                                             IUserActivityLogger logger)
Run the given runnable with the given IUserActivityLogger as the ThreadLocalUserActivityLogger.

Parameters:
runnable - the runnable to be run
logger - the logger to be set during the runnable.run call

initUserActivityLogger

public static void initUserActivityLogger(javax.servlet.http.HttpServletRequest request)
FRAMEWORK USE ONLY Sets the ThreadLocal's UserActivityLogger to a generic one wrapping the given request's session

Parameters:
request -

initEmptyUserActivityLogger

public static void initEmptyUserActivityLogger()
FRAMEWORK USE ONLY Sets the ThreadLocal's UserActivityLogger to a generic one

Parameters:
request -

createEmptyUserActivityLogger

public static IUserActivityLogger createEmptyUserActivityLogger()
FRAMEWORK USE ONLY Returns an empty UserActivityLogger


resetUserActivityLogger

public static void resetUserActivityLogger()
FRAMEWORK USE ONLY Sets the ThreadLocal's UserActivityLogger back to null