1 16 17 package org.apache.axis.transport.http; 18 19 import org.apache.axis.session.Session; 20 21 import javax.servlet.http.HttpServletRequest ; 22 import javax.servlet.http.HttpSession ; 23 import java.util.Enumeration ; 24 25 30 public class AxisHttpSession implements Session 31 { 32 public static final String AXIS_SESSION_MARKER = "axis.isAxisSession"; 33 34 private HttpSession rep; 35 private HttpServletRequest req; 36 37 public AxisHttpSession(HttpServletRequest realRequest) 38 { 39 req = realRequest; 40 } 41 42 public AxisHttpSession(HttpSession realSession) 43 { 44 if (realSession != null) 45 setRep(realSession); 46 } 47 48 50 public HttpSession getRep() 51 { 52 ensureSession(); 53 return rep; 54 } 55 56 60 private void setRep(HttpSession realSession) 61 { 62 rep = realSession; 63 rep.setAttribute(AXIS_SESSION_MARKER, Boolean.TRUE); 64 } 65 66 70 public Object get(String key) 71 { 72 ensureSession(); 73 return rep.getAttribute(key); 74 } 75 76 81 public void set(String key, Object value) 82 { 83 ensureSession(); 84 rep.setAttribute(key, value); 85 } 86 87 91 public void remove(String key) 92 { 93 ensureSession(); 94 rep.removeAttribute(key); 95 } 96 97 100 public Enumeration getKeys() { 101 ensureSession(); 102 return rep.getAttributeNames(); 103 } 104 105 111 public void setTimeout(int timeout) 112 { 113 ensureSession(); 114 rep.setMaxInactiveInterval(timeout); 115 } 116 117 122 public int getTimeout() { 123 ensureSession(); 124 return rep.getMaxInactiveInterval(); 125 } 126 127 130 public void touch() { 131 } 133 134 137 public void invalidate() { 138 rep.invalidate(); 139 } 140 141 protected void ensureSession() { 142 if (rep == null) { 143 setRep(req.getSession()); 144 } 145 } 146 147 155 public Object getLockObject() { 156 ensureSession(); 157 return rep; 158 } 159 } 160 | Popular Tags |