Class DefaultThreadContextService

java.lang.Object
de.hybris.platform.commerceservices.threadcontext.impl.DefaultThreadContextService
All Implemented Interfaces:
ThreadContext, ThreadContextService

public class DefaultThreadContextService extends Object implements ThreadContextService
Default implementation of the ThreadContextService
  • Constructor Details

    • DefaultThreadContextService

      public DefaultThreadContextService()
  • Method Details

    • getCurrentContext

      public ThreadContext getCurrentContext()
      Specified by:
      getCurrentContext in interface ThreadContextService
      Returns:
      the current ThreadContext
    • executeInContext

      public <R, T extends Throwable> R executeInContext(ThreadContextService.Executor<R,T> wrapper) throws T
      Description copied from interface: ThreadContextService
      Execute the wrapper code in the context of the specified user
      Specified by:
      executeInContext in interface ThreadContextService
      Type Parameters:
      R - The type of the return value
      T - 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

      public void setAttribute(String name, Object value)
      Description copied from interface: ThreadContext
      Sets the given value Object to the Session as attribute with the given name
      Specified by:
      setAttribute in interface ThreadContext
      Parameters:
      name - the name of the attribute
      value - the value to be set
    • getAttribute

      public <T> T getAttribute(String name)
      Description copied from interface: ThreadContext
      Returns for the given session attribute name the value
      Specified by:
      getAttribute in interface ThreadContext
      Parameters:
      name - the attribute name
      Returns:
      null if no attribute with the given name is stored in the session
    • removeAttribute

      public void removeAttribute(String name)
      Description copied from interface: ThreadContext
      Removes the given attribute from the current session. Do nothing if the attribute doesn't exists in the session.
      Specified by:
      removeAttribute in interface ThreadContext
      Parameters:
      name - the attribute name
    • createLocalThreadContext

      protected ThreadContext createLocalThreadContext()
    • removeLocalThreadContext

      protected void removeLocalThreadContext()