Class PentahoSessionHolder
- java.lang.Object
-
- org.pentaho.platform.engine.core.system.PentahoSessionHolder
-
public class PentahoSessionHolder extends Object
Stores the IPentahoSession session object for the current thread so that a web service bean can get to it without requiring it to be passed to its methods.Configure using system property
pentaho.sessionHolder.strategy
orsetStrategyName(String)
. Valid values are:MODE_INHERITABLETHREADLOCAL
andMODE_GLOBAL
.Partially inspired by
org.springframework.security.context.SecurityContextHolder
.- Author:
- jamesdixon, mlowery (modifications to support global)
-
-
Field Summary
Fields Modifier and Type Field Description static String
MODE_GLOBAL
Global strategy.static String
MODE_INHERITABLETHREADLOCAL
Inheritable local strategy.static String
SYSTEM_PROPERTY
Key for finding session holder strategy.
-
Constructor Summary
Constructors Constructor Description PentahoSessionHolder()
Default constructor.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static org.pentaho.platform.api.engine.IPentahoSession
getSession()
Returns the IPentahoSession for the current thread.static void
removeSession()
Removes the IPentahoSession for the current thread.static void
setSession(org.pentaho.platform.api.engine.IPentahoSession session)
Sets an IPentahoSession for the current thread.static void
setStrategyName(String strategyName)
Sets the behavior of the session.
-
-
-
Field Detail
-
MODE_INHERITABLETHREADLOCAL
public static final String MODE_INHERITABLETHREADLOCAL
Inheritable local strategy.- See Also:
- Constant Field Values
-
MODE_GLOBAL
public static final String MODE_GLOBAL
Global strategy.- See Also:
- Constant Field Values
-
SYSTEM_PROPERTY
public static final String SYSTEM_PROPERTY
Key for finding session holder strategy.- See Also:
- Constant Field Values
-
-
Method Detail
-
setSession
public static void setSession(org.pentaho.platform.api.engine.IPentahoSession session)
Sets an IPentahoSession for the current thread.- Parameters:
session
- Session to be set.
-
getSession
public static org.pentaho.platform.api.engine.IPentahoSession getSession()
Returns the IPentahoSession for the current thread.- Returns:
- Returns the thread session.
-
removeSession
public static void removeSession()
Removes the IPentahoSession for the current thread. It is important that the framework calls this to prevent session "bleed-through" between requests as threads are reused by the server.
-
setStrategyName
public static void setStrategyName(String strategyName)
Sets the behavior of the session. Valid values are:MODE_INHERITABLETHREADLOCAL
andMODE_GLOBAL
. The changes to the strategy are applied immediately.- Parameters:
strategyName
- Name of the strategy to be used.
-
-