Esempio n. 1
0
  public static void setThreadLocals(
      Map<CentralizedThreadLocal<?>, Object> longLivedThreadLocals,
      Map<CentralizedThreadLocal<?>, Object> shortLivedThreadLocals) {

    ThreadLocalMap threadLocalMap = _longLivedThreadLocals.get();

    for (Map.Entry<CentralizedThreadLocal<?>, Object> entry : longLivedThreadLocals.entrySet()) {

      threadLocalMap.putEntry(entry.getKey(), entry.getValue());
    }

    threadLocalMap = _shortLivedThreadLocals.get();

    for (Map.Entry<CentralizedThreadLocal<?>, Object> entry : shortLivedThreadLocals.entrySet()) {

      threadLocalMap.putEntry(entry.getKey(), entry.getValue());
    }
  }
Esempio n. 2
0
  @Override
  public T get() {
    ThreadLocalMap threadLocalMap = _getThreadLocalMap();

    Entry entry = threadLocalMap.getEntry(this);

    if (entry == null) {
      T value = initialValue();

      threadLocalMap.putEntry(this, value);

      return value;
    } else {
      return (T) entry._value;
    }
  }
Esempio n. 3
0
  @Override
  public void set(T value) {
    ThreadLocalMap threadLocalMap = _getThreadLocalMap();

    threadLocalMap.putEntry(this, value);
  }