tiles-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apetre...@apache.org
Subject svn commit: r935400 [2/2] - in /tiles/sandbox/trunk/tiles-request: tiles-request-api/src/main/java/org/apache/tiles/request/collection/ tiles-request-api/src/main/java/org/apache/tiles/request/collection/extractor/ tiles-request-api/src/main/java/org/a...
Date Sun, 18 Apr 2010 20:18:26 GMT
Added: tiles/sandbox/trunk/tiles-request/tiles-request-servlet/src/main/java/org/apache/tiles/request/servlet/extractor/SessionScopeExtractor.java
URL: http://svn.apache.org/viewvc/tiles/sandbox/trunk/tiles-request/tiles-request-servlet/src/main/java/org/apache/tiles/request/servlet/extractor/SessionScopeExtractor.java?rev=935400&view=auto
==============================================================================
--- tiles/sandbox/trunk/tiles-request/tiles-request-servlet/src/main/java/org/apache/tiles/request/servlet/extractor/SessionScopeExtractor.java
(added)
+++ tiles/sandbox/trunk/tiles-request/tiles-request-servlet/src/main/java/org/apache/tiles/request/servlet/extractor/SessionScopeExtractor.java
Sun Apr 18 20:18:25 2010
@@ -0,0 +1,49 @@
+package org.apache.tiles.request.servlet.extractor;
+
+import java.util.Enumeration;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+
+import org.apache.tiles.request.collection.extractor.AttributeExtractor;
+
+public class SessionScopeExtractor implements AttributeExtractor {
+
+    private HttpServletRequest request;
+
+    public SessionScopeExtractor(HttpServletRequest request) {
+        this.request = request;
+    }
+
+    @Override
+    public void setValue(String name, Object value) {
+        request.getSession().setAttribute(name, value);
+    }
+
+    @Override
+    public void removeValue(String name) {
+        HttpSession session = request.getSession(false);
+        if (session != null) {
+            session.removeAttribute(name);
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    @Override
+    public Enumeration<String> getKeys() {
+        HttpSession session = request.getSession(false);
+        if (session != null) {
+            return session.getAttributeNames();
+        }
+        return null;
+    }
+
+    @Override
+    public Object getValue(String key) {
+        HttpSession session = request.getSession(false);
+        if (session != null) {
+            return session.getAttribute(key);
+        }
+        return null;
+    }
+}

Propchange: tiles/sandbox/trunk/tiles-request/tiles-request-servlet/src/main/java/org/apache/tiles/request/servlet/extractor/SessionScopeExtractor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tiles/sandbox/trunk/tiles-request/tiles-request-servlet/src/main/java/org/apache/tiles/request/servlet/extractor/SessionScopeExtractor.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL



Mime
View raw message