Class DefaultThreadContextService
java.lang.Object
de.hybris.platform.commerceservices.threadcontext.impl.DefaultThreadContextService
- All Implemented Interfaces:
ThreadContext,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 Throwable>, ThreadContextService.Nothing -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected ThreadContext<R,T extends Throwable>
RexecuteInContext(ThreadContextService.Executor<R, T> wrapper) Execute the wrapper code in the context of the specified user<T> TgetAttribute(String name) Returns for the given session attribute name the valuevoidremoveAttribute(String name) Removes the given attribute from the current session.protected voidvoidsetAttribute(String name, Object value) Sets the given value Object to the Session as attribute with the given name
-
Constructor Details
-
DefaultThreadContextService
public DefaultThreadContextService()
-
-
Method Details
-
getCurrentContext
- Specified by:
getCurrentContextin interfaceThreadContextService- Returns:
- the current
ThreadContext
-
executeInContext
public <R,T extends Throwable> R executeInContext(ThreadContextService.Executor<R, T> wrapper) throws TDescription 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 occurs
-
setAttribute
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
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
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
-
removeLocalThreadContext
protected void removeLocalThreadContext()
-