1
14
15 package com.liferay.util;
16
17 import com.liferay.portal.kernel.util.InitialThreadLocal;
18
19 import java.util.HashSet;
20 import java.util.Set;
21
22
32 public class ThirdPartyThreadLocalRegistry {
33
34 public static void registerThreadLocal(ThreadLocal<?> threadLocal) {
35 Set<ThreadLocal<?>> threadLocalSet = _threadLocalSet.get();
36
37 threadLocalSet.add(threadLocal);
38 }
39
40 public static void resetThreadLocals() {
41 Set<ThreadLocal<?>> threadLocalSet = _threadLocalSet.get();
42
43 if (threadLocalSet == null) {
44 return;
45 }
46
47 for (ThreadLocal<?> threadLocal : threadLocalSet) {
48 threadLocal.remove();
49 }
50 }
51
52 private static ThreadLocal<Set<ThreadLocal<?>>> _threadLocalSet =
53 new InitialThreadLocal<Set<ThreadLocal<?>>>(
54 new HashSet<ThreadLocal<?>>());
55
56 }