| 1 | |
package org.webslinger.servlet; |
| 2 | |
|
| 3 | |
import java.util.Enumeration; |
| 4 | |
import java.util.HashSet; |
| 5 | |
import java.util.HashMap; |
| 6 | |
import java.util.Map; |
| 7 | |
import java.util.Set; |
| 8 | |
import javax.servlet.ServletContext; |
| 9 | |
import javax.servlet.http.HttpSession; |
| 10 | |
import javax.servlet.http.HttpSessionContext; |
| 11 | |
|
| 12 | |
import org.apache.commons.collections.iterators.IteratorEnumeration; |
| 13 | |
|
| 14 | |
public class HttpSessionImpl implements HttpSession { |
| 15 | |
protected final ServletContext servletContext; |
| 16 | |
protected final HttpSessionData data; |
| 17 | |
|
| 18 | 63 | public HttpSessionImpl(ServletContext servletContext, HttpSessionData data) { |
| 19 | 63 | this.servletContext = servletContext; |
| 20 | 63 | this.data = data; |
| 21 | 63 | } |
| 22 | |
|
| 23 | |
protected HttpSessionData getData() { |
| 24 | 0 | return data; |
| 25 | |
} |
| 26 | |
|
| 27 | |
public String getRemoteAddr() { |
| 28 | 0 | return data.getRemoteAddr(); |
| 29 | |
} |
| 30 | |
|
| 31 | |
|
| 32 | |
|
| 33 | |
public Object getAttribute(String name) { |
| 34 | 56 | return data.get(name); |
| 35 | |
} |
| 36 | |
|
| 37 | |
public Enumeration getAttributeNames() { |
| 38 | 0 | return new IteratorEnumeration(new HashSet<String>(data.getNameSet()).iterator()); |
| 39 | |
} |
| 40 | |
|
| 41 | |
public long getCreationTime() { |
| 42 | 0 | return data.getCreationTime(); |
| 43 | |
} |
| 44 | |
|
| 45 | |
public String getId() { |
| 46 | 0 | return data.getId(); |
| 47 | |
} |
| 48 | |
|
| 49 | |
public long getLastAccessedTime() { |
| 50 | 0 | throw new UnsupportedOperationException(); |
| 51 | |
} |
| 52 | |
|
| 53 | |
public int getMaxInactiveInterval() { |
| 54 | 0 | throw new UnsupportedOperationException(); |
| 55 | |
} |
| 56 | |
|
| 57 | |
public ServletContext getServletContext() { |
| 58 | 0 | return servletContext; |
| 59 | |
} |
| 60 | |
|
| 61 | |
|
| 62 | |
public HttpSessionContext getSessionContext() { |
| 63 | 0 | throw new UnsupportedOperationException(); |
| 64 | |
} |
| 65 | |
|
| 66 | |
|
| 67 | |
public Object getValue(String name) { |
| 68 | 0 | return data.get(name); |
| 69 | |
} |
| 70 | |
|
| 71 | |
|
| 72 | |
public String[] getValueNames() { |
| 73 | 0 | Set<String> names = data.getNameSet(); |
| 74 | 0 | return names.toArray(new String[names.size()]); |
| 75 | |
} |
| 76 | |
|
| 77 | |
public void invalidate() { |
| 78 | 6 | data.invalidate(); |
| 79 | 6 | } |
| 80 | |
|
| 81 | |
public boolean isNew() { |
| 82 | 0 | return data.isNew(); |
| 83 | |
} |
| 84 | |
|
| 85 | |
|
| 86 | |
public void putValue(String name, Object value) { |
| 87 | 0 | data.put(name, value); |
| 88 | 0 | } |
| 89 | |
|
| 90 | |
public void removeAttribute(String name) { |
| 91 | 0 | data.remove(name); |
| 92 | 0 | } |
| 93 | |
|
| 94 | |
|
| 95 | |
public void removeValue(String name) { |
| 96 | 0 | data.remove(name); |
| 97 | 0 | } |
| 98 | |
|
| 99 | |
public void setAttribute(String name, Object value) { |
| 100 | 18 | data.put(name, value); |
| 101 | 18 | } |
| 102 | |
|
| 103 | |
public void setMaxInactiveInterval(int seconds) { |
| 104 | 0 | throw new UnsupportedOperationException(); |
| 105 | |
} |
| 106 | |
} |