Module io.jooby
Package io.jooby

Class RequestScope

java.lang.Object
io.jooby.RequestScope

public final class RequestScope extends Object
Thread-Local request scope implementation useful for save/store request attribute and access to them using a static way.

This is part of public API but usage must be keep to minimum.

Author:
edgar
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T> T
    bind(Object key, T value)
    Binds the given value to the current context for its key.
    static <T> T
    get(Object key)
    Get a previously bind value for the given key or null.
    static boolean
    Check to see if there is already a value associated with the current thread for the given key.
    Exposes thread local state.
    static <T> T
    Unbinds the session (if one) current associated with the context for the given session.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • hasBind

      public static boolean hasBind(@NonNull Object key)
      Check to see if there is already a value associated with the current thread for the given key.
      Parameters:
      key - The key against which to check for a given value within the current thread.
      Returns:
      True if there is currently a session bound.
    • bind

      @Nullable public static <T> T bind(@NonNull Object key, @NonNull T value)
      Binds the given value to the current context for its key.
      Type Parameters:
      T - Bind type.
      Parameters:
      key - The key to be bound.
      value - The value to be bound.
      Returns:
      Any previously bound session (should be null in most cases).
    • unbind

      @Nullable public static <T> T unbind(@NonNull Object key)
      Unbinds the session (if one) current associated with the context for the given session.
      Type Parameters:
      T - Bind type.
      Parameters:
      key - The factory for which to unbind the current session.
      Returns:
      The bound session if one, else null.
    • get

      @Nullable public static <T> T get(@NonNull Object key)
      Get a previously bind value for the given key or null.
      Type Parameters:
      T - Object type.
      Parameters:
      key - Key.
      Returns:
      Binded value or null.
    • threadLocal

      public static ThreadLocal<Map<Object,Object>> threadLocal()
      Exposes thread local state. Internal usage only (don't use it).
      Returns:
      Exposes thread local state. Internal usage only (don't use it).