001
014
015 package com.liferay.portal.kernel.process.local;
016
017 import com.liferay.portal.kernel.concurrent.AsyncBroker;
018 import com.liferay.portal.kernel.util.CentralizedThreadLocal;
019
020 import java.io.Serializable;
021
022
025 public class AsyncBrokerThreadLocal {
026
027 public static AsyncBroker<Long, Serializable> getAsyncBroker() {
028 AsyncBroker<Long, Serializable> asyncBroker =
029 _asyncBrokerThreadLocal.get();
030
031 if (asyncBroker == null) {
032 throw new IllegalStateException("Async broker is not set");
033 }
034
035 return asyncBroker;
036 }
037
038 public static void removeAsyncBroker() {
039 _asyncBrokerThreadLocal.remove();
040 }
041
042 public static void setAsyncBroker(
043 AsyncBroker<Long, Serializable> asyncBroker) {
044
045 _asyncBrokerThreadLocal.set(asyncBroker);
046 }
047
048 private static final ThreadLocal<AsyncBroker<Long, Serializable>>
049 _asyncBrokerThreadLocal = new CentralizedThreadLocal<>(false);
050
051 }