1 16 17 package org.apache.commons.latka.jelly; 18 19 import java.util.Map ; 20 21 import org.apache.commons.jelly.JellyTagException; 22 import org.apache.commons.jelly.TagSupport; 23 import org.apache.commons.jelly.XMLOutput; 24 25 import org.apache.commons.latka.http.Session; 26 import org.apache.commons.latka.http.SessionImpl; 27 28 32 public class SessionTag extends TagSupport { 33 34 protected String _sessionId = null; 35 protected String _label = null; 36 protected Session _session = null; 37 38 44 public void doTag(XMLOutput xmlOutput) throws JellyTagException { 45 _session = findSession(_sessionId); 46 invokeBody(xmlOutput); 47 } 48 49 public Session getSession() { 50 return _session; 51 } 52 53 protected Session findSession(String sessionId) { 54 if (sessionId == null) { 55 return new SessionImpl(); 56 } 57 58 SuiteTag tag = (SuiteTag) findAncestorWithClass(SuiteTag.class); 59 Map sessionCache = tag.getSessionCache(); 60 Session cachedSession = (Session) sessionCache.get(sessionId); 61 if (cachedSession == null) { 62 Session session = new SessionImpl(); 63 sessionCache.put(sessionId,session); 64 return session; 65 } else { 66 return cachedSession; 67 } 68 } 69 70 78 public void setSessionId(String sessionId) { 79 _sessionId = sessionId; 80 } 81 82 87 public void setLabel(String label) { 88 _label = label; 89 } 90 } 91 | Popular Tags |