--- /dev/null
+/*\r
+ * ============LICENSE_START========================================================================\r
+ * ONAP : tr-069-adapter\r
+ * =================================================================================================\r
+ * Copyright (C) 2020 CommScope Inc Intellectual Property.\r
+ * =================================================================================================\r
+ * This tr-069-adapter software file is distributed by CommScope Inc under the Apache License,\r
+ * Version 2.0 (the "License"); you may not use this file except in compliance with the License. You\r
+ * may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,\r
+ * either express or implied. See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ===============LICENSE_END=======================================================================\r
+ */\r
+\r
+\r
+package org.commscope.tr069adapter.acs.requestprocessor.util;\r
+\r
+import org.commscope.tr069adapter.acs.requestprocessor.dto.TR069RequestProcessorData;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+import org.springframework.stereotype.Component;\r
+import org.springframework.transaction.support.TransactionSynchronization;\r
+\r
+@Component\r
+public class TR069RequestProcessorCacheUtil implements TransactionSynchronization {\r
+\r
+ private static final Logger logger =\r
+ LoggerFactory.getLogger(TR069RequestProcessorCacheUtil.class);\r
+\r
+ private static ThreadLocal<TR069RequestProcessorData> threadLocalCache = new ThreadLocal<>();\r
+\r
+ public void put(TR069RequestProcessorData tR069RequestProcessorData) {\r
+\r
+ try {\r
+ logger.debug("Entering put");\r
+ threadLocalCache.set(tR069RequestProcessorData);\r
+ } catch (Exception e) {\r
+ throw new IllegalStateException(e.getMessage());\r
+ }\r
+ }\r
+\r
+ public static TR069RequestProcessorData get() {\r
+ return threadLocalCache.get();\r
+ }\r
+\r
+ @Override\r
+ public void beforeCompletion() {\r
+ logger.debug("Entering beforeCompletion");\r
+ threadLocalCache.remove();\r
+ }\r
+\r
+ @Override\r
+ public void afterCompletion(int status) {\r
+ throw new UnsupportedOperationException();\r
+ }\r
+\r
+ @Override\r
+ public void afterCommit() {\r
+ throw new UnsupportedOperationException();\r
+ }\r
+\r
+ @Override\r
+ public void beforeCommit(boolean arg0) {\r
+ throw new UnsupportedOperationException();\r
+ }\r
+\r
+ @Override\r
+ public void flush() {\r
+ throw new UnsupportedOperationException();\r
+ }\r
+\r
+ @Override\r
+ public void resume() {\r
+ throw new UnsupportedOperationException();\r
+ }\r
+\r
+ @Override\r
+ public void suspend() {\r
+ throw new UnsupportedOperationException();\r
+ }\r
+}\r