001
014
015 package com.liferay.portal.servlet;
016
017 import java.io.Serializable;
018
019 import java.util.Map;
020 import java.util.concurrent.ConcurrentHashMap;
021
022 import javax.servlet.http.HttpSession;
023
024
028 @Deprecated
029 public class SharedSessionAttributeCache implements Serializable {
030
031 public static SharedSessionAttributeCache getInstance(HttpSession session) {
032 synchronized (session) {
033 SharedSessionAttributeCache cache =
034 (SharedSessionAttributeCache)session.getAttribute(_SESSION_KEY);
035
036 if (cache == null) {
037 cache = new SharedSessionAttributeCache();
038
039 session.setAttribute(_SESSION_KEY, cache);
040 }
041
042 return cache;
043 }
044 }
045
046 public boolean contains(String name) {
047 return _attributes.containsKey(name);
048 }
049
050 public Map<String, Object> getValues() {
051 return _attributes;
052 }
053
054 public void removeAttribute(String key) {
055 _attributes.remove(key);
056 }
057
058 public void setAttribute(String key, Object value) {
059 _attributes.put(key, value);
060 }
061
062 private SharedSessionAttributeCache() {
063 _attributes = new ConcurrentHashMap<>();
064 }
065
066 private static final String _SESSION_KEY =
067 SharedSessionAttributeCache.class.getName();
068
069 private final Map<String, Object> _attributes;
070
071 }