struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tm...@apache.org
Subject svn commit: r415148 - in /struts/action2/trunk/core/src/main/java/org/apache/struts/action2/interceptor: RequestAware.java ServletConfigInterceptor.java
Date Sun, 18 Jun 2006 15:23:21 GMT
Author: tmjee
Date: Sun Jun 18 08:23:20 2006
New Revision: 415148

URL: http://svn.apache.org/viewvc?rev=415148&view=rev
Log:
WW-1356
  - added RequestAware capability to action. 


Added:
    struts/action2/trunk/core/src/main/java/org/apache/struts/action2/interceptor/RequestAware.java
  (with props)
Modified:
    struts/action2/trunk/core/src/main/java/org/apache/struts/action2/interceptor/ServletConfigInterceptor.java

Added: struts/action2/trunk/core/src/main/java/org/apache/struts/action2/interceptor/RequestAware.java
URL: http://svn.apache.org/viewvc/struts/action2/trunk/core/src/main/java/org/apache/struts/action2/interceptor/RequestAware.java?rev=415148&view=auto
==============================================================================
--- struts/action2/trunk/core/src/main/java/org/apache/struts/action2/interceptor/RequestAware.java
(added)
+++ struts/action2/trunk/core/src/main/java/org/apache/struts/action2/interceptor/RequestAware.java
Sun Jun 18 08:23:20 2006
@@ -0,0 +1,38 @@
+/*
+ * $Id: SessionAware.java 394468 2006-04-16 12:16:03Z tmjee $
+ *
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.struts.action2.interceptor;
+
+import java.util.Map;
+
+/**
+ * Actions that want access to the current serlvet request attributes should implement this
interface.<p />
+ * 
+ * This interface is only relevant if the Action is used in a servlet environment.<p/>
+ * 
+ * Note that using this interface makes the Action tied to a servlet environment, so it should
be
+ * avoided if possible since things like unit testing will become more difficult.
+ */
+public interface RequestAware {
+
+	/**
+     * Sets the Map of request attributes in the implementing class.
+     *
+     * @param session a Map of HTTP request attribute name/value pairs.
+     */
+    public void setRequest(Map request);
+}

Propchange: struts/action2/trunk/core/src/main/java/org/apache/struts/action2/interceptor/RequestAware.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: struts/action2/trunk/core/src/main/java/org/apache/struts/action2/interceptor/ServletConfigInterceptor.java
URL: http://svn.apache.org/viewvc/struts/action2/trunk/core/src/main/java/org/apache/struts/action2/interceptor/ServletConfigInterceptor.java?rev=415148&r1=415147&r2=415148&view=diff
==============================================================================
--- struts/action2/trunk/core/src/main/java/org/apache/struts/action2/interceptor/ServletConfigInterceptor.java
(original)
+++ struts/action2/trunk/core/src/main/java/org/apache/struts/action2/interceptor/ServletConfigInterceptor.java
Sun Jun 18 08:23:20 2006
@@ -17,6 +17,8 @@
  */
 package org.apache.struts.action2.interceptor;
 
+import java.util.Map;
+
 import org.apache.struts.action2.StrutsStatics;
 import org.apache.struts.action2.util.ServletContextAware;
 import com.opensymphony.xwork.ActionContext;
@@ -129,6 +131,10 @@
 
         if (action instanceof ParameterAware) {
             ((ParameterAware) action).setParameters(context.getParameters());
+        }
+        
+        if (action instanceof RequestAware) {
+        	((RequestAware) action).setRequest((Map) context.get("request"));
         }
 
         if (action instanceof SessionAware) {



Mime
View raw message