public static void remoteAppSession(String id) { ApplicationSession appSession = getInstance().applicationMap.remove(id); if (appSession != null) { appSession.clearApplicationSession(); } }
public static ApplicationSession getAppSession(String id) {
ApplicationSession appSession = getInstance().applicationMap.get(id); if (appSession == null) { logger.info(id + ":cache space has not been inited or been removed"); appSession = new ApplicationSession(); WebContextCache.createAppSession(id, appSession); }
return appSession; } }
Java代码 public class ApplicationSession { /** * 默认的map初始化大小 */ private static final int DEFAULT_MAP_SIZE = 100;
private final Map cache = new HashMap(DEFAULT_MAP_SIZE); public Object getFromCache(Object key) { synchronized (cache) { return cache.get(key); } }