Class DefaultThreadContextService
- java.lang.Object
-
- de.hybris.platform.commerceservices.threadcontext.impl.DefaultThreadContextService
-
- All Implemented Interfaces:
ThreadContext,ThreadContextService
public class DefaultThreadContextService extends java.lang.Object implements ThreadContextService
Default implementation of the ThreadContextService
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface de.hybris.platform.commerceservices.threadcontext.ThreadContextService
ThreadContextService.Executor<R,T extends java.lang.Throwable>, ThreadContextService.Nothing
-
-
Constructor Summary
Constructors Constructor Description DefaultThreadContextService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ThreadContextcreateLocalThreadContext()<R,T extends java.lang.Throwable>
RexecuteInContext(ThreadContextService.Executor<R,T> wrapper)Execute the wrapper code in the context of the specified user<T> TgetAttribute(java.lang.String name)Returns for the given session attribute name the valueThreadContextgetCurrentContext()voidremoveAttribute(java.lang.String name)Removes the given attribute from the current session.protected voidremoveLocalThreadContext()voidsetAttribute(java.lang.String name, java.lang.Object value)Sets the given value Object to the Session as attribute with the given name
-
-
-
Method Detail
-
getCurrentContext
public ThreadContext getCurrentContext()
- Specified by:
getCurrentContextin interfaceThreadContextService- Returns:
- the current
ThreadContext
-
executeInContext
public <R,T extends java.lang.Throwable> R executeInContext(ThreadContextService.Executor<R,T> wrapper) throws T extends java.lang.Throwable
Description copied from interface:ThreadContextServiceExecute the wrapper code in the context of the specified user- Specified by:
executeInContextin interfaceThreadContextService- Type Parameters:
R- The type of the return valueT- The type of the exception thrown by the wrapper- Parameters:
wrapper- The code to execute in that context- Returns:
- The result of method being executed
- Throws:
T- The exception thrown by the wrapper if an error occursT extends java.lang.Throwable
-
setAttribute
public void setAttribute(java.lang.String name, java.lang.Object value)Description copied from interface:ThreadContextSets the given value Object to the Session as attribute with the given name- Specified by:
setAttributein interfaceThreadContext- Parameters:
name- the name of the attributevalue- the value to be set
-
getAttribute
public <T> T getAttribute(java.lang.String name)
Description copied from interface:ThreadContextReturns for the given session attribute name the value- Specified by:
getAttributein interfaceThreadContext- Parameters:
name- the attribute name- Returns:
nullif no attribute with the given name is stored in the session
-
removeAttribute
public void removeAttribute(java.lang.String name)
Description copied from interface:ThreadContextRemoves the given attribute from the current session. Do nothing if the attribute doesn't exists in the session.- Specified by:
removeAttributein interfaceThreadContext- Parameters:
name- the attribute name
-
createLocalThreadContext
protected ThreadContext createLocalThreadContext()
-
removeLocalThreadContext
protected void removeLocalThreadContext()
-
-