1 22 package org.jboss.web.tomcat.tc6.session; 23 24 import java.io.IOException ; 25 import java.io.ObjectInput ; 26 import java.io.ObjectOutput ; 27 import java.util.Map ; 28 29 30 51 class SessionBasedClusteredSession 52 extends JBossCacheClusteredSession 53 { 54 static final long serialVersionUID = 3200976125245487256L; 55 56 59 protected static final String info = "SessionBasedClusteredSession/1.0"; 60 61 public SessionBasedClusteredSession(JBossCacheManager manager) 62 { 63 super(manager); 64 } 65 66 68 71 public String toString() 72 { 73 StringBuffer sb = new StringBuffer (); 74 sb.append("SessionBasedClusteredSession["); 75 sb.append(super.toString()); 76 sb.append("]"); 77 return (sb.toString()); 78 79 } 80 81 public void removeMyself() 82 { 83 proxy_.removeSession(realId); 84 } 85 86 public void removeMyselfLocal() 87 { 88 proxy_.removeSessionLocal(realId); 89 } 90 91 93 96 protected void populateAttributes() 97 { 98 } 100 101 protected Object getJBossInternalAttribute(String name) 102 { 103 Object result = attributes.get(name); 104 105 if (isGetDirty(result)) 108 { 109 sessionAttributesDirty(); 110 } 111 112 return result; 113 114 } 115 116 protected Object removeJBossInternalAttribute(String name, 117 boolean localCall, 118 boolean localOnly) 119 { 120 if (localCall) 121 sessionAttributesDirty(); 122 return attributes.remove(name); 123 } 124 125 protected Map getJBossInternalAttributes() 126 { 127 return attributes; 128 } 129 130 protected Object setJBossInternalAttribute(String name, Object value) 131 { 132 sessionAttributesDirty(); 133 return attributes.put(name, value); 134 } 135 136 148 public void readExternal(ObjectInput in) throws IOException , ClassNotFoundException 149 { 150 synchronized (this) 151 { 152 super.readExternal(in); 154 155 attributes = (Map ) in.readObject(); 156 } 157 } 158 159 166 public void writeExternal(ObjectOutput out) throws IOException 167 { 168 synchronized (this) 169 { 170 super.writeExternal(out); 172 173 Map excluded = removeExcludedAttributes(attributes); 175 176 out.writeObject(attributes); 177 178 if (excluded != null) 180 attributes.putAll(excluded); 181 } 182 183 } 184 185 protected void update(ClusteredSession replicated) 186 { 187 SessionBasedClusteredSession other = (SessionBasedClusteredSession) replicated; 188 189 super.update(other); 190 191 attributes = other.attributes; 192 } 193 194 195 199 public boolean getReplicateSessionBody() 200 { 201 return isSessionDirty() || getExceedsMaxUnreplicatedInterval(); 202 } 203 204 } 205 | Popular Tags |