diff --git a/redisson-tomcat/redisson-tomcat-6/src/main/java/org/redisson/tomcat/RedissonSession.java b/redisson-tomcat/redisson-tomcat-6/src/main/java/org/redisson/tomcat/RedissonSession.java index 13e6f9661..c5bfbe37e 100644 --- a/redisson-tomcat/redisson-tomcat-6/src/main/java/org/redisson/tomcat/RedissonSession.java +++ b/redisson-tomcat/redisson-tomcat-6/src/main/java/org/redisson/tomcat/RedissonSession.java @@ -18,6 +18,8 @@ package org.redisson.tomcat; import java.io.IOException; import java.lang.reflect.Field; import java.util.Arrays; +import java.util.Collections; +import java.util.Enumeration; import java.util.HashMap; import java.util.HashSet; import java.util.Map; @@ -76,13 +78,52 @@ public class RedissonSession extends StandardSession { @Override public Object getAttribute(String name) { if (readMode == ReadMode.REDIS) { + if (!isValidInternal()) { + throw new IllegalStateException(sm.getString("standardSession.getAttribute.ise")); + } + + if (name == null) { + return null; + } + return map.get(name); } return super.getAttribute(name); } + @Override + public Enumeration getAttributeNames() { + if (readMode == ReadMode.REDIS) { + if (!isValidInternal()) { + throw new IllegalStateException + (sm.getString("standardSession.getAttributeNames.ise")); + } + return Collections.enumeration(map.readAllKeySet()); + } + + return super.getAttributeNames(); + } + + @Override + public String[] getValueNames() { + if (readMode == ReadMode.REDIS) { + if (!isValidInternal()) { + throw new IllegalStateException + (sm.getString("standardSession.getAttributeNames.ise")); + } + Set keys = map.readAllKeySet(); + return keys.toArray(new String[keys.size()]); + } + + return super.getValueNames(); + } + public void delete() { + if (map == null) { + map = redissonManager.getMap(id); + } + map.delete(); if (readMode == ReadMode.MEMORY) { topic.publish(new AttributesClearMessage(redissonManager.getNodeId(), getId())); diff --git a/redisson-tomcat/redisson-tomcat-7/src/main/java/org/redisson/tomcat/RedissonSession.java b/redisson-tomcat/redisson-tomcat-7/src/main/java/org/redisson/tomcat/RedissonSession.java index 7175503b2..ffa57bf25 100644 --- a/redisson-tomcat/redisson-tomcat-7/src/main/java/org/redisson/tomcat/RedissonSession.java +++ b/redisson-tomcat/redisson-tomcat-7/src/main/java/org/redisson/tomcat/RedissonSession.java @@ -18,6 +18,8 @@ package org.redisson.tomcat; import java.io.IOException; import java.lang.reflect.Field; import java.util.Arrays; +import java.util.Collections; +import java.util.Enumeration; import java.util.HashMap; import java.util.HashSet; import java.util.Map; @@ -76,13 +78,52 @@ public class RedissonSession extends StandardSession { @Override public Object getAttribute(String name) { if (readMode == ReadMode.REDIS) { + if (!isValidInternal()) { + throw new IllegalStateException(sm.getString("standardSession.getAttribute.ise")); + } + + if (name == null) { + return null; + } + return map.get(name); } return super.getAttribute(name); } + @Override + public Enumeration getAttributeNames() { + if (readMode == ReadMode.REDIS) { + if (!isValidInternal()) { + throw new IllegalStateException + (sm.getString("standardSession.getAttributeNames.ise")); + } + return Collections.enumeration(map.readAllKeySet()); + } + + return super.getAttributeNames(); + } + + @Override + public String[] getValueNames() { + if (readMode == ReadMode.REDIS) { + if (!isValidInternal()) { + throw new IllegalStateException + (sm.getString("standardSession.getAttributeNames.ise")); + } + Set keys = map.readAllKeySet(); + return keys.toArray(new String[keys.size()]); + } + + return super.getValueNames(); + } + public void delete() { + if (map == null) { + map = redissonManager.getMap(id); + } + map.delete(); if (readMode == ReadMode.MEMORY) { topic.publish(new AttributesClearMessage(redissonManager.getNodeId(), getId())); diff --git a/redisson-tomcat/redisson-tomcat-8/src/main/java/org/redisson/tomcat/RedissonSession.java b/redisson-tomcat/redisson-tomcat-8/src/main/java/org/redisson/tomcat/RedissonSession.java index 6fcfae715..23c4c55a9 100644 --- a/redisson-tomcat/redisson-tomcat-8/src/main/java/org/redisson/tomcat/RedissonSession.java +++ b/redisson-tomcat/redisson-tomcat-8/src/main/java/org/redisson/tomcat/RedissonSession.java @@ -18,6 +18,8 @@ package org.redisson.tomcat; import java.io.IOException; import java.lang.reflect.Field; import java.util.Arrays; +import java.util.Collections; +import java.util.Enumeration; import java.util.HashMap; import java.util.HashSet; import java.util.Map; @@ -76,13 +78,52 @@ public class RedissonSession extends StandardSession { @Override public Object getAttribute(String name) { if (readMode == ReadMode.REDIS) { + if (!isValidInternal()) { + throw new IllegalStateException(sm.getString("standardSession.getAttribute.ise")); + } + + if (name == null) { + return null; + } + return map.get(name); } return super.getAttribute(name); } + @Override + public Enumeration getAttributeNames() { + if (readMode == ReadMode.REDIS) { + if (!isValidInternal()) { + throw new IllegalStateException + (sm.getString("standardSession.getAttributeNames.ise")); + } + return Collections.enumeration(map.readAllKeySet()); + } + + return super.getAttributeNames(); + } + + @Override + public String[] getValueNames() { + if (readMode == ReadMode.REDIS) { + if (!isValidInternal()) { + throw new IllegalStateException + (sm.getString("standardSession.getAttributeNames.ise")); + } + Set keys = map.readAllKeySet(); + return keys.toArray(new String[keys.size()]); + } + + return super.getValueNames(); + } + public void delete() { + if (map == null) { + map = redissonManager.getMap(id); + } + map.delete(); if (readMode == ReadMode.MEMORY) { topic.publish(new AttributesClearMessage(redissonManager.getNodeId(), getId())); diff --git a/redisson-tomcat/redisson-tomcat-9/src/main/java/org/redisson/tomcat/RedissonSession.java b/redisson-tomcat/redisson-tomcat-9/src/main/java/org/redisson/tomcat/RedissonSession.java index 4d49eaedf..ee9b0a2e2 100644 --- a/redisson-tomcat/redisson-tomcat-9/src/main/java/org/redisson/tomcat/RedissonSession.java +++ b/redisson-tomcat/redisson-tomcat-9/src/main/java/org/redisson/tomcat/RedissonSession.java @@ -18,6 +18,8 @@ package org.redisson.tomcat; import java.io.IOException; import java.lang.reflect.Field; import java.util.Arrays; +import java.util.Collections; +import java.util.Enumeration; import java.util.HashMap; import java.util.HashSet; import java.util.Map; @@ -76,13 +78,52 @@ public class RedissonSession extends StandardSession { @Override public Object getAttribute(String name) { if (readMode == ReadMode.REDIS) { + if (!isValidInternal()) { + throw new IllegalStateException(sm.getString("standardSession.getAttribute.ise")); + } + + if (name == null) { + return null; + } + return map.get(name); } return super.getAttribute(name); } + @Override + public Enumeration getAttributeNames() { + if (readMode == ReadMode.REDIS) { + if (!isValidInternal()) { + throw new IllegalStateException + (sm.getString("standardSession.getAttributeNames.ise")); + } + return Collections.enumeration(map.readAllKeySet()); + } + + return super.getAttributeNames(); + } + + @Override + public String[] getValueNames() { + if (readMode == ReadMode.REDIS) { + if (!isValidInternal()) { + throw new IllegalStateException + (sm.getString("standardSession.getAttributeNames.ise")); + } + Set keys = map.readAllKeySet(); + return keys.toArray(new String[keys.size()]); + } + + return super.getValueNames(); + } + public void delete() { + if (map == null) { + map = redissonManager.getMap(id); + } + map.delete(); if (readMode == ReadMode.MEMORY) { topic.publish(new AttributesClearMessage(redissonManager.getNodeId(), getId()));