You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by lu...@apache.org on 2023/03/15 07:50:57 UTC
[struts] branch master updated: WW-5251 remove deprecated interfaces related to ServletConfigInterceptor
This is an automated email from the ASF dual-hosted git repository.
lukaszlenart pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/struts.git
The following commit(s) were added to refs/heads/master by this push:
new 95a6dff1f WW-5251 remove deprecated interfaces related to ServletConfigInterceptor
new bad445ba3 Merge pull request #670 from sdutry/issue/WW-5251
95a6dff1f is described below
commit 95a6dff1f570cfa6d4c0775567a72a9b630abc6d
Author: Stefaan Dutry <st...@gmail.com>
AuthorDate: Tue Mar 14 00:04:32 2023 +0100
WW-5251 remove deprecated interfaces related to ServletConfigInterceptor
---
.../struts2/showcase/chat/ChatLoginAction.java | 13 +-
.../struts2/showcase/chat/ChatLogoutAction.java | 13 +-
.../struts2/showcase/chat/EnterRoomAction.java | 14 +-
.../struts2/showcase/chat/ExitRoomAction.java | 13 +-
.../showcase/chat/SendMessageToRoomAction.java | 12 +-
.../showcase/hangman/GetUpdatedHangmanAction.java | 14 +-
.../showcase/hangman/GuessCharacterAction.java | 14 +-
.../showcase/hangman/StartHangmanAction.java | 13 +-
.../apache/struts2/showcase/xslt/JVMAction.java | 13 +-
.../apache/struts2/dispatcher/HttpParameters.java | 7 -
.../struts2/interceptor/ApplicationAware.java | 45 -----
.../struts2/interceptor/HttpParametersAware.java | 49 ------
.../apache/struts2/interceptor/ParameterAware.java | 50 ------
.../apache/struts2/interceptor/PrincipalAware.java | 38 ----
.../apache/struts2/interceptor/RequestAware.java | 46 -----
.../interceptor/ServletConfigInterceptor.java | 85 ++-------
.../struts2/interceptor/ServletRequestAware.java | 49 ------
.../struts2/interceptor/ServletResponseAware.java | 47 -----
.../apache/struts2/interceptor/SessionAware.java | 47 -----
.../apache/struts2/util/ServletContextAware.java | 36 ----
.../interceptor/ServletConfigInterceptorTest.java | 192 ++-------------------
.../dispatcher/DirectRenderFromEventAction.java | 10 +-
.../interceptor/PortletAwareInterceptor.java | 50 ++----
.../portlet/interceptor/PortletContextAware.java | 34 ----
.../interceptor/PortletPreferencesAware.java | 42 -----
.../portlet/interceptor/PortletRequestAware.java | 35 ----
.../portlet/interceptor/PortletResponseAware.java | 35 ----
.../interceptor/PortletAwareInterceptorTest.java | 31 +---
.../interceptor/PortletStateInterceptorTest.java | 6 +-
29 files changed, 118 insertions(+), 935 deletions(-)
diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/ChatLoginAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/ChatLoginAction.java
index a5fc15e73..0dcfd8943 100644
--- a/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/ChatLoginAction.java
+++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/ChatLoginAction.java
@@ -21,16 +21,17 @@
package org.apache.struts2.showcase.chat;
import com.opensymphony.xwork2.ActionSupport;
-import org.apache.struts2.interceptor.SessionAware;
import java.util.Map;
+import org.apache.struts2.action.SessionAware;
+
public class ChatLoginAction extends ActionSupport implements SessionAware {
private static final long serialVersionUID = 1L;
private ChatService chatService;
- private Map session;
+ private Map<String, Object> session;
private String name;
@@ -60,8 +61,8 @@ public class ChatLoginAction extends ActionSupport implements SessionAware {
}
- // === SessionAware ===
- public void setSession(Map session) {
- this.session = session;
- }
+ @Override
+ public void withSession(Map<String, Object> session) {
+ this.session = session;
+ }
}
diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/ChatLogoutAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/ChatLogoutAction.java
index d0c3e6ba6..452ce0d08 100644
--- a/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/ChatLogoutAction.java
+++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/ChatLogoutAction.java
@@ -21,17 +21,18 @@
package org.apache.struts2.showcase.chat;
import com.opensymphony.xwork2.ActionSupport;
-import org.apache.struts2.interceptor.SessionAware;
import java.util.Map;
+import org.apache.struts2.action.SessionAware;
+
public class ChatLogoutAction extends ActionSupport implements SessionAware {
private static final long serialVersionUID = 1L;
private ChatService chatService;
- private Map session;
+ private Map<String, Object> session;
public ChatLogoutAction(ChatService chatService) {
@@ -50,8 +51,8 @@ public class ChatLogoutAction extends ActionSupport implements SessionAware {
}
- // === SessionAware ===
- public void setSession(Map session) {
- this.session = session;
- }
+ @Override
+ public void withSession(Map<String, Object> session) {
+ this.session = session;
+ }
}
diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/EnterRoomAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/EnterRoomAction.java
index 24a54531a..4b3939b0d 100644
--- a/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/EnterRoomAction.java
+++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/EnterRoomAction.java
@@ -21,16 +21,17 @@
package org.apache.struts2.showcase.chat;
import com.opensymphony.xwork2.ActionSupport;
-import org.apache.struts2.interceptor.SessionAware;
import java.util.Map;
+import org.apache.struts2.action.SessionAware;
+
public class EnterRoomAction extends ActionSupport implements SessionAware {
private static final long serialVersionUID = 1L;
private ChatService chatService;
- private Map session;
+ private Map<String, Object> session;
private String roomName;
public String getRoomName() {
@@ -56,10 +57,9 @@ public class EnterRoomAction extends ActionSupport implements SessionAware {
return SUCCESS;
}
-
- // === SessionAware ===
- public void setSession(Map session) {
- this.session = session;
- }
+ @Override
+ public void withSession(Map<String, Object> session) {
+ this.session = session;
+ }
}
diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/ExitRoomAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/ExitRoomAction.java
index 592f2d07f..7dc14be1d 100644
--- a/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/ExitRoomAction.java
+++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/ExitRoomAction.java
@@ -21,17 +21,18 @@
package org.apache.struts2.showcase.chat;
import com.opensymphony.xwork2.ActionSupport;
-import org.apache.struts2.interceptor.SessionAware;
import java.util.Map;
+import org.apache.struts2.action.SessionAware;
+
public class ExitRoomAction extends ActionSupport implements SessionAware {
private static final long serialVersionUID = 1L;
private String roomName;
- private Map session;
+ private Map<String, Object> session;
public String getRoomName() {
return roomName;
@@ -54,9 +55,9 @@ public class ExitRoomAction extends ActionSupport implements SessionAware {
return SUCCESS;
}
- // === SessionAware ===
- public void setSession(Map session) {
- this.session = session;
- }
+ @Override
+ public void withSession(Map<String, Object> session) {
+ this.session = session;
+ }
}
diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/SendMessageToRoomAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/SendMessageToRoomAction.java
index 69a66609c..96bfe75c2 100644
--- a/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/SendMessageToRoomAction.java
+++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/chat/SendMessageToRoomAction.java
@@ -21,10 +21,11 @@
package org.apache.struts2.showcase.chat;
import com.opensymphony.xwork2.ActionSupport;
-import org.apache.struts2.interceptor.SessionAware;
import java.util.Map;
+import org.apache.struts2.action.SessionAware;
+
public class SendMessageToRoomAction extends ActionSupport implements SessionAware {
private static final long serialVersionUID = 1L;
@@ -33,7 +34,7 @@ public class SendMessageToRoomAction extends ActionSupport implements SessionAwa
private String roomName;
private String message;
- private Map session;
+ private Map<String, Object> session;
public SendMessageToRoomAction(ChatService chatService) {
@@ -67,9 +68,10 @@ public class SendMessageToRoomAction extends ActionSupport implements SessionAwa
return SUCCESS;
}
- public void setSession(Map session) {
- this.session = session;
- }
+ @Override
+ public void withSession(Map<String, Object> session) {
+ this.session = session;
+ }
}
diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/hangman/GetUpdatedHangmanAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/hangman/GetUpdatedHangmanAction.java
index 24b777355..660c5e9e8 100644
--- a/apps/showcase/src/main/java/org/apache/struts2/showcase/hangman/GetUpdatedHangmanAction.java
+++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/hangman/GetUpdatedHangmanAction.java
@@ -21,15 +21,16 @@
package org.apache.struts2.showcase.hangman;
import com.opensymphony.xwork2.ActionSupport;
-import org.apache.struts2.interceptor.SessionAware;
import java.util.Map;
+import org.apache.struts2.action.SessionAware;
+
public class GetUpdatedHangmanAction extends ActionSupport implements SessionAware {
private static final long serialVersionUID = 5506025785406043027L;
- private Map session;
+ private Map<String, Object> session;
private Hangman hangman;
@@ -45,10 +46,6 @@ public class GetUpdatedHangmanAction extends ActionSupport implements SessionAwa
return SUCCESS;
}
- public void setSession(Map session) {
- this.session = session;
- }
-
public Hangman getHangman() {
return hangman;
}
@@ -56,4 +53,9 @@ public class GetUpdatedHangmanAction extends ActionSupport implements SessionAwa
public void setHangman(Hangman hangman) {
this.hangman = hangman;
}
+
+ @Override
+ public void withSession(Map<String, Object> session) {
+ this.session = session;
+ }
}
diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/hangman/GuessCharacterAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/hangman/GuessCharacterAction.java
index 40ab60fe4..67ea15099 100644
--- a/apps/showcase/src/main/java/org/apache/struts2/showcase/hangman/GuessCharacterAction.java
+++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/hangman/GuessCharacterAction.java
@@ -21,15 +21,16 @@
package org.apache.struts2.showcase.hangman;
import com.opensymphony.xwork2.ActionSupport;
-import org.apache.struts2.interceptor.SessionAware;
import java.util.Map;
+import org.apache.struts2.action.SessionAware;
+
public class GuessCharacterAction extends ActionSupport implements SessionAware {
private static final long serialVersionUID = 9050915577007590674L;
- private Map session;
+ private Map<String, Object> session;
private Character character;
private Hangman hangman;
@@ -44,10 +45,6 @@ public class GuessCharacterAction extends ActionSupport implements SessionAware
return hangman;
}
- public void setSession(Map session) {
- this.session = session;
- }
-
public void setCharacter(Character character) {
this.character = character;
}
@@ -55,4 +52,9 @@ public class GuessCharacterAction extends ActionSupport implements SessionAware
public Character getCharacter() {
return this.character;
}
+
+ @Override
+ public void withSession(Map<String, Object> session) {
+ this.session = session;
+ }
}
diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/hangman/StartHangmanAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/hangman/StartHangmanAction.java
index a38b10954..bc4138a23 100644
--- a/apps/showcase/src/main/java/org/apache/struts2/showcase/hangman/StartHangmanAction.java
+++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/hangman/StartHangmanAction.java
@@ -21,10 +21,11 @@
package org.apache.struts2.showcase.hangman;
import com.opensymphony.xwork2.ActionSupport;
-import org.apache.struts2.interceptor.SessionAware;
import java.util.Map;
+import org.apache.struts2.action.SessionAware;
+
import static org.apache.struts2.showcase.hangman.HangmanConstants.HANGMAN_SESSION_KEY;
public class StartHangmanAction extends ActionSupport implements SessionAware {
@@ -33,7 +34,7 @@ public class StartHangmanAction extends ActionSupport implements SessionAware {
private HangmanService service;
private Hangman hangman;
- private Map session;
+ private Map<String, Object> session;
public StartHangmanAction(HangmanService service) {
@@ -53,8 +54,8 @@ public class StartHangmanAction extends ActionSupport implements SessionAware {
}
- // === SessionAware ===
- public void setSession(Map session) {
- this.session = session;
- }
+ @Override
+ public void withSession(Map<String, Object> session) {
+ this.session = session;
+ }
}
diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/xslt/JVMAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/xslt/JVMAction.java
index 059b300af..6472adf62 100644
--- a/apps/showcase/src/main/java/org/apache/struts2/showcase/xslt/JVMAction.java
+++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/xslt/JVMAction.java
@@ -21,9 +21,11 @@
package org.apache.struts2.showcase.xslt;
import com.opensymphony.xwork2.ActionSupport;
-import org.apache.struts2.interceptor.ServletRequestAware;
import javax.servlet.http.HttpServletRequest;
+
+import org.apache.struts2.action.ServletRequestAware;
+
import java.util.Map;
import java.util.Properties;
@@ -53,10 +55,6 @@ public class JVMAction implements ServletRequestAware {
return servletRequest;
}
- public void setServletRequest(HttpServletRequest servletRequest) {
- this.servletRequest = servletRequest;
- }
-
public Map<String, String> getEnvironment() {
return environment;
}
@@ -100,4 +98,9 @@ public class JVMAction implements ServletRequestAware {
this.systemProperties = systemProperties;
}
}
+
+ @Override
+ public void withServletRequest(HttpServletRequest request) {
+ this.servletRequest = request;
+ }
}
diff --git a/core/src/main/java/org/apache/struts2/dispatcher/HttpParameters.java b/core/src/main/java/org/apache/struts2/dispatcher/HttpParameters.java
index 695d641d2..b0ab784ab 100644
--- a/core/src/main/java/org/apache/struts2/dispatcher/HttpParameters.java
+++ b/core/src/main/java/org/apache/struts2/dispatcher/HttpParameters.java
@@ -18,15 +18,12 @@
*/
package org.apache.struts2.dispatcher;
-import org.apache.struts2.interceptor.ParameterAware;
-
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
-import java.util.Objects;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
@@ -81,10 +78,6 @@ public class HttpParameters implements Map<String, Parameter>, Cloneable {
return this;
}
- public void applyParameters(ParameterAware parameterAware) {
- parameterAware.setParameters(toMap());
- }
-
@Override
public int size() {
return parameters.size();
diff --git a/core/src/main/java/org/apache/struts2/interceptor/ApplicationAware.java b/core/src/main/java/org/apache/struts2/interceptor/ApplicationAware.java
deleted file mode 100644
index c240fa8cb..000000000
--- a/core/src/main/java/org/apache/struts2/interceptor/ApplicationAware.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.struts2.interceptor;
-
-import java.util.Map;
-
-/**
- * <p>
- * Actions that want to be aware of the application Map object should implement this interface.
- * This will give them access to a Map where they can put objects that should be available
- * to other parts of the application.
- * </p>
- * <p>
- * Typical uses are configuration objects and caches.
- * </p>
- * @deprecated please use {@link org.apache.struts2.action.ApplicationAware} instead
- */
-@Deprecated
-public interface ApplicationAware {
-
- /**
- * Sets the map of application properties in the implementing class.
- *
- * @param application a Map of application properties.
- * @deprecated please use {@link org.apache.struts2.action.ApplicationAware#withApplication(Map)} instead
- */
- @Deprecated
- public void setApplication(Map<String,Object> application);
-}
diff --git a/core/src/main/java/org/apache/struts2/interceptor/HttpParametersAware.java b/core/src/main/java/org/apache/struts2/interceptor/HttpParametersAware.java
deleted file mode 100644
index c27a05694..000000000
--- a/core/src/main/java/org/apache/struts2/interceptor/HttpParametersAware.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.struts2.interceptor;
-
-import org.apache.struts2.dispatcher.HttpParameters;
-
-/**
- * <p>
- * This interface gives actions an alternative way of receiving input parameters. The parameters will
- * contain all input parameters as implementation of {@link org.apache.struts2.dispatcher.Parameter}.
- * Actions that need this should simply implement it.
- * </p>
- *
- * <p>
- * One common use for this is to have the action propagate parameters to internally instantiated data
- * objects.
- * </p>
- *
- * @deprecated please use {@link org.apache.struts2.action.ParametersAware} instead
- */
-@Deprecated
-public interface HttpParametersAware {
-
- /**
- * Sets the HTTP parameters in the implementing class.
- *
- * @param parameters an instance of {@link HttpParameters}.
- *
- * @deprecated please use {@link org.apache.struts2.action.ParametersAware#withParameters(HttpParameters)} instead
- */
- @Deprecated
- void setParameters(HttpParameters parameters);
-}
diff --git a/core/src/main/java/org/apache/struts2/interceptor/ParameterAware.java b/core/src/main/java/org/apache/struts2/interceptor/ParameterAware.java
deleted file mode 100644
index 9689e36b9..000000000
--- a/core/src/main/java/org/apache/struts2/interceptor/ParameterAware.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.struts2.interceptor;
-
-import java.util.Map;
-
-/**
- * <p>
- * This interface gives actions an alternative way of receiving input parameters. The map will
- * contain all input parameters as name/value entries. Actions that need this should simply implement it.
- * </p>
- *
- * <p>
- * One common use for this is to have the action propagate parameters to internally instantiated data
- * objects.
- * </p>
- *
- * <p>
- * Note that all parameter values for a given name will be returned, so the type of the objects in
- * the map is <tt>java.lang.String[]</tt>.
- * </p>
- *
- * @deprecated please use {@link org.apache.struts2.action.ParametersAware} instead
- */
-@Deprecated
-public interface ParameterAware {
-
- /**
- * Sets the map of input parameters in the implementing class.
- *
- * @param parameters a Map of parameters (name/value Strings).
- */
- public void setParameters(Map<String, String[]> parameters);
-}
diff --git a/core/src/main/java/org/apache/struts2/interceptor/PrincipalAware.java b/core/src/main/java/org/apache/struts2/interceptor/PrincipalAware.java
deleted file mode 100644
index ac1e3296b..000000000
--- a/core/src/main/java/org/apache/struts2/interceptor/PrincipalAware.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.struts2.interceptor;
-
-/**
- * Actions that want access to the Principal information from HttpServletRequest object
- * should implement this interface.
- *
- * <p>This interface is only relevant if the Action is used in a servlet environment.
- * By using this interface you will not become tied to servlet environment.</p>
- *
- * @deprecated please use {@link org.apache.struts2.action.PrincipalAware} instead
- */
-@Deprecated
-public interface PrincipalAware {
-
- /**
- * @deprecated please use {@link org.apache.struts2.action.PrincipalAware#withPrincipalProxy(PrincipalProxy)} instead
- */
- @Deprecated
- void setPrincipalProxy(PrincipalProxy principalProxy);
-}
diff --git a/core/src/main/java/org/apache/struts2/interceptor/RequestAware.java b/core/src/main/java/org/apache/struts2/interceptor/RequestAware.java
deleted file mode 100644
index e8e73eee5..000000000
--- a/core/src/main/java/org/apache/struts2/interceptor/RequestAware.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.struts2.interceptor;
-
-import org.apache.struts2.dispatcher.HttpParameters;
-
-import java.util.Map;
-
-/**
- * <p>
- * Actions that want access to the current servlet request attributes should implement this interface.
- * </p>
- *
- * <p>
- * This interface is only relevant if the Action is used in a servlet environment.
- * </p>
- * @deprecated please use {@link org.apache.struts2.action.ParametersAware} instead
- */
-@Deprecated
-public interface RequestAware {
-
- /**
- * Sets the Map of request attributes in the implementing class.
- *
- * @param request a Map of HTTP request attribute name/value pairs.
- * @deprecated please use {@link org.apache.struts2.action.ParametersAware#withParameters(HttpParameters)} instead
- */
- @Deprecated
- public void setRequest(Map<String,Object> request);
-}
diff --git a/core/src/main/java/org/apache/struts2/interceptor/ServletConfigInterceptor.java b/core/src/main/java/org/apache/struts2/interceptor/ServletConfigInterceptor.java
index 634240085..f54c5e35f 100644
--- a/core/src/main/java/org/apache/struts2/interceptor/ServletConfigInterceptor.java
+++ b/core/src/main/java/org/apache/struts2/interceptor/ServletConfigInterceptor.java
@@ -18,16 +18,19 @@
*/
package org.apache.struts2.interceptor;
-import java.util.Map;
-
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts2.StrutsStatics;
+import org.apache.struts2.action.ApplicationAware;
import org.apache.struts2.action.ParametersAware;
+import org.apache.struts2.action.PrincipalAware;
+import org.apache.struts2.action.ServletContextAware;
+import org.apache.struts2.action.ServletRequestAware;
+import org.apache.struts2.action.ServletResponseAware;
+import org.apache.struts2.action.SessionAware;
import org.apache.struts2.interceptor.servlet.ServletPrincipalProxy;
-import org.apache.struts2.util.ServletContextAware;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
@@ -46,22 +49,13 @@ import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
*
* <ul>
* <li>{@link ServletContextAware}</li>
- * <li>{@link org.apache.struts2.action.ServletContextAware}</li>
* <li>{@link ServletRequestAware}</li>
- * <li>{@link org.apache.struts2.action.ServletRequestAware}</li>
* <li>{@link ServletResponseAware}</li>
- * <li>{@link org.apache.struts2.action.ServletResponseAware}</li>
- * <li>{@link ParameterAware} - deprecated since 2.5.4, please use {@link HttpParametersAware}</li>
- * <li>{@link HttpParametersAware}</li>
- * <li>{@link org.apache.struts2.action.ParametersAware}</li>
- * <li>{@link RequestAware}</li>
- * <li>{@link org.apache.struts2.action.ServletRequestAware}</li>
+ * <li>{@link ParametersAware}</li>
+ * <li>{@link ServletRequestAware}</li>
* <li>{@link SessionAware}</li>
- * <li>{@link org.apache.struts2.action.SessionAware}</li>
* <li>{@link ApplicationAware}</li>
- * <li>{@link org.apache.struts2.action.ApplicationAware}</li>
* <li>{@link PrincipalAware}</li>
- * <li>{@link org.apache.struts2.action.PrincipalAware}</li>
* </ul>
*
* <!-- END SNIPPET: description -->
@@ -101,17 +95,11 @@ import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
* @see ServletContextAware
* @see org.apache.struts2.action.ServletContextAware
* @see ServletRequestAware
- * @see org.apache.struts2.action.ServletRequestAware
* @see ServletResponseAware
- * @see org.apache.struts2.action.ServletResponseAware
- * @see ParameterAware
- * @see org.apache.struts2.action.ParametersAware
+ * @see ParametersAware
* @see SessionAware
- * @see org.apache.struts2.action.SessionAware
* @see ApplicationAware
- * @see org.apache.struts2.action.ApplicationAware
* @see PrincipalAware
- * @see org.apache.struts2.action.PrincipalAware
*/
public class ServletConfigInterceptor extends AbstractInterceptor implements StrutsStatics {
@@ -130,30 +118,12 @@ public class ServletConfigInterceptor extends AbstractInterceptor implements Str
if (action instanceof ServletRequestAware) {
HttpServletRequest request = context.getServletRequest();
- ((ServletRequestAware) action).setServletRequest(request);
- }
-
- if (action instanceof org.apache.struts2.action.ServletRequestAware) {
- HttpServletRequest request = context.getServletRequest();
- ((org.apache.struts2.action.ServletRequestAware) action).withServletRequest(request);
+ ((ServletRequestAware) action).withServletRequest(request);
}
if (action instanceof ServletResponseAware) {
HttpServletResponse response = context.getServletResponse();
- ((ServletResponseAware) action).setServletResponse(response);
- }
-
- if (action instanceof org.apache.struts2.action.ServletResponseAware) {
- HttpServletResponse response = context.getServletResponse();
- ((org.apache.struts2.action.ServletResponseAware) action).withServletResponse(response);
- }
-
- if (action instanceof ParameterAware) {
- context.getParameters().applyParameters((ParameterAware) action);
- }
-
- if (action instanceof HttpParametersAware) {
- ((HttpParametersAware) action).setParameters(context.getParameters());
+ ((ServletResponseAware) action).withServletResponse(response);
}
if (action instanceof ParametersAware) {
@@ -161,49 +131,24 @@ public class ServletConfigInterceptor extends AbstractInterceptor implements Str
}
if (action instanceof ApplicationAware) {
- ((ApplicationAware) action).setApplication(context.getApplication());
- }
-
- if (action instanceof org.apache.struts2.action.ApplicationAware) {
- ((org.apache.struts2.action.ApplicationAware) action).withApplication(context.getApplication());
+ ((ApplicationAware) action).withApplication(context.getApplication());
}
if (action instanceof SessionAware) {
- ((SessionAware) action).setSession(context.getSession());
- }
-
- if (action instanceof org.apache.struts2.action.SessionAware) {
- ((org.apache.struts2.action.SessionAware) action).withSession(context.getSession());
- }
-
- if (action instanceof RequestAware) {
- ((RequestAware) action).setRequest((Map) context.get("request"));
+ ((SessionAware) action).withSession(context.getSession());
}
if (action instanceof PrincipalAware) {
HttpServletRequest request = context.getServletRequest();
if(request != null) {
// We are in servlet environment, so principal information resides in HttpServletRequest
- ((PrincipalAware) action).setPrincipalProxy(new ServletPrincipalProxy(request));
- }
- }
-
- if (action instanceof org.apache.struts2.action.PrincipalAware) {
- HttpServletRequest request = context.getServletRequest();
- if(request != null) {
- // We are in servlet environment, so principal information resides in HttpServletRequest
- ((org.apache.struts2.action.PrincipalAware) action).withPrincipalProxy(new ServletPrincipalProxy(request));
+ ((PrincipalAware) action).withPrincipalProxy(new ServletPrincipalProxy(request));
}
}
if (action instanceof ServletContextAware) {
ServletContext servletContext = context.getServletContext();
- ((ServletContextAware) action).setServletContext(servletContext);
- }
-
- if (action instanceof org.apache.struts2.action.ServletContextAware) {
- ServletContext servletContext = context.getServletContext();
- ((org.apache.struts2.action.ServletContextAware) action).withServletContext(servletContext);
+ ((ServletContextAware) action).withServletContext(servletContext);
}
return invocation.invoke();
diff --git a/core/src/main/java/org/apache/struts2/interceptor/ServletRequestAware.java b/core/src/main/java/org/apache/struts2/interceptor/ServletRequestAware.java
deleted file mode 100644
index 7c9da3032..000000000
--- a/core/src/main/java/org/apache/struts2/interceptor/ServletRequestAware.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.struts2.interceptor;
-
-import javax.servlet.http.HttpServletRequest;
-
-/**
- * <p>
- * All Actions that want to have access to the servlet request object must implement this interface.
- * </p>
- *
- * <p>
- * This interface is only relevant if the Action is used in a servlet environment.
- * </p>
- *
- * <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.
- * </p>
- * @deprecated please use {@link org.apache.struts2.action.ServletRequestAware} instead
- */
-@Deprecated
-public interface ServletRequestAware {
-
- /**
- * Sets the HTTP request object in implementing classes.
- *
- * @param request the HTTP request.
- * @deprecated please use {@link org.apache.struts2.action.ServletRequestAware#withServletRequest(HttpServletRequest)}
- */
- @Deprecated
- public void setServletRequest(HttpServletRequest request);
-}
diff --git a/core/src/main/java/org/apache/struts2/interceptor/ServletResponseAware.java b/core/src/main/java/org/apache/struts2/interceptor/ServletResponseAware.java
deleted file mode 100644
index 9043b4434..000000000
--- a/core/src/main/java/org/apache/struts2/interceptor/ServletResponseAware.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.struts2.interceptor;
-
-import javax.servlet.http.HttpServletResponse;
-
-/**
- * <p>
- * All Actions that want to have access to the servlet response object must implement this interface.
- * </p>
- * <p>
- * This interface is only relevant if the Action is used in a servlet environment.
- * </p>
- * <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.
- * </p>
- * @deprecated please use {@link org.apache.struts2.action.ServletResponseAware} instead
- */
-@Deprecated
-public interface ServletResponseAware {
-
- /**
- * Sets the HTTP response object in implementing classes.
- *
- * @param response the HTTP response.
- * @deprecated please use {@link org.apache.struts2.action.ServletResponseAware#withServletResponse(HttpServletResponse)} instead
- */
- @Deprecated
- public void setServletResponse(HttpServletResponse response);
-}
diff --git a/core/src/main/java/org/apache/struts2/interceptor/SessionAware.java b/core/src/main/java/org/apache/struts2/interceptor/SessionAware.java
deleted file mode 100644
index 0380c9702..000000000
--- a/core/src/main/java/org/apache/struts2/interceptor/SessionAware.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.struts2.interceptor;
-
-import java.util.Map;
-
-/**
- * <p>
- * Actions that want access to the user's HTTP session attributes should implement this interface.
- * </p>
- * <p>
- * This will give them access to a Map where they can put objects that can be made available
- * to subsequent requests.
- * </p>
- * <p>
- * Typical uses may be cached user data such as name, or a shopping cart.
- * </p>
- * @deprecated use {@link org.apache.struts2.action.SessionAware}
- */
-@Deprecated
-public interface SessionAware {
-
- /**
- * Sets the Map of session attributes in the implementing class.
- *
- * @param session a Map of HTTP session attribute name/value pairs.
- * @deprecated please use {@link org.apache.struts2.action.SessionAware#withSession(Map)}
- */
- @Deprecated
- public void setSession(Map<String,Object> session);
-}
diff --git a/core/src/main/java/org/apache/struts2/util/ServletContextAware.java b/core/src/main/java/org/apache/struts2/util/ServletContextAware.java
deleted file mode 100644
index 13a717cc7..000000000
--- a/core/src/main/java/org/apache/struts2/util/ServletContextAware.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.struts2.util;
-
-import javax.servlet.ServletContext;
-
-/**
- * For components that have a dependence on the Servlet context.
- *
- * @deprecated please use {@link org.apache.struts2.action.ServletContextAware} instead
- */
-@Deprecated
-public interface ServletContextAware {
-
- /**
- * @deprecated please use {@link org.apache.struts2.action.ServletContextAware#withServletContext(ServletContext)} instead
- */
- @Deprecated
- public void setServletContext(ServletContext context);
-}
diff --git a/core/src/test/java/org/apache/struts2/interceptor/ServletConfigInterceptorTest.java b/core/src/test/java/org/apache/struts2/interceptor/ServletConfigInterceptorTest.java
index 7829f2623..c95e2c685 100644
--- a/core/src/test/java/org/apache/struts2/interceptor/ServletConfigInterceptorTest.java
+++ b/core/src/test/java/org/apache/struts2/interceptor/ServletConfigInterceptorTest.java
@@ -23,17 +23,18 @@ import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.mock.MockActionInvocation;
import org.apache.struts2.StrutsInternalTestCase;
import org.apache.struts2.StrutsStatics;
+import org.apache.struts2.action.ApplicationAware;
import org.apache.struts2.action.ParametersAware;
+import org.apache.struts2.action.PrincipalAware;
+import org.apache.struts2.action.ServletRequestAware;
+import org.apache.struts2.action.ServletResponseAware;
+import org.apache.struts2.action.SessionAware;
import org.apache.struts2.dispatcher.HttpParameters;
import org.apache.struts2.interceptor.servlet.ServletPrincipalProxy;
-import org.apache.struts2.util.ServletContextAware;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.mock.web.MockServletContext;
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;
@@ -51,23 +52,7 @@ public class ServletConfigInterceptorTest extends StrutsInternalTestCase {
private ServletConfigInterceptor interceptor;
public void testServletRequestAware() throws Exception {
- ServletRequestAware mock = (ServletRequestAware) createMock(ServletRequestAware.class);
-
- MockHttpServletRequest req = new MockHttpServletRequest();
-
- MockActionInvocation mai = createActionInvocation(mock);
- mai.getInvocationContext().put(StrutsStatics.HTTP_REQUEST, req);
-
- mock.setServletRequest((HttpServletRequest) req);
- expectLastCall();
-
- replay(mock);
- interceptor.intercept(mai);
- verify(mock);
- }
-
- public void testActionServletRequestAware() throws Exception {
- org.apache.struts2.action.ServletRequestAware mock = createMock(org.apache.struts2.action.ServletRequestAware.class);
+ ServletRequestAware mock = createMock(ServletRequestAware.class);
MockHttpServletRequest req = new MockHttpServletRequest();
@@ -83,23 +68,7 @@ public class ServletConfigInterceptorTest extends StrutsInternalTestCase {
}
public void testServletResponseAware() throws Exception {
- ServletResponseAware mock = (ServletResponseAware) createMock(ServletResponseAware.class);
-
- MockHttpServletResponse res = new MockHttpServletResponse();
-
- MockActionInvocation mai = createActionInvocation(mock);
- mai.getInvocationContext().put(StrutsStatics.HTTP_RESPONSE, res);
-
- mock.setServletResponse((HttpServletResponse) res);
- expectLastCall().times(1);
-
- replay(mock);
- interceptor.intercept(mai);
- verify(mock);
- }
-
- public void testActionServletResponseAware() throws Exception {
- org.apache.struts2.action.ServletResponseAware mock = createMock(org.apache.struts2.action.ServletResponseAware.class);
+ ServletResponseAware mock = createMock(ServletResponseAware.class);
MockHttpServletResponse res = new MockHttpServletResponse();
@@ -114,39 +83,7 @@ public class ServletConfigInterceptorTest extends StrutsInternalTestCase {
verify(mock);
}
- public void testParameterAware() throws Exception {
- ParameterAware mock = createMock(ParameterAware.class);
-
- MockActionInvocation mai = createActionInvocation(mock);
-
- HttpParameters param = HttpParameters.create().build();
- mai.getInvocationContext().setParameters(param);
-
- param.applyParameters(mock);
- expectLastCall().times(1);
-
- replay(mock);
- interceptor.intercept(mai);
- verify(mock);
- }
-
- public void testHttpParametersAware() throws Exception {
- HttpParametersAware mock = createMock(HttpParametersAware.class);
-
- MockActionInvocation mai = createActionInvocation(mock);
-
- HttpParameters param = HttpParameters.create().build();
- mai.getInvocationContext().setParameters(param);
-
- mock.setParameters(param);
- expectLastCall().times(1);
-
- replay(mock);
- interceptor.intercept(mai);
- verify(mock);
- }
-
- public void testActionParametersAware() throws Exception {
+ public void testParametersAware() throws Exception {
ParametersAware mock = createMock(ParametersAware.class);
MockActionInvocation mai = createActionInvocation(mock);
@@ -163,23 +100,7 @@ public class ServletConfigInterceptorTest extends StrutsInternalTestCase {
}
public void testSessionAware() throws Exception {
- SessionAware mock = (SessionAware) createMock(SessionAware.class);
-
- MockActionInvocation mai = createActionInvocation(mock);
-
- Map<String, Object> session = new HashMap<String, Object>();
- mai.getInvocationContext().setSession(session);
-
- mock.setSession(session);
- expectLastCall().times(1);
-
- replay(mock);
- interceptor.intercept(mai);
- verify(mock);
- }
-
- public void testActionSessionAware() throws Exception {
- org.apache.struts2.action.SessionAware mock = createMock(org.apache.struts2.action.SessionAware.class);
+ SessionAware mock = createMock(SessionAware.class);
MockActionInvocation mai = createActionInvocation(mock);
@@ -199,22 +120,6 @@ public class ServletConfigInterceptorTest extends StrutsInternalTestCase {
MockActionInvocation mai = createActionInvocation(mock);
- Map<String, Object> app = new HashMap<String, Object>();
- mai.getInvocationContext().withApplication(app);
-
- mock.setApplication(app);
- expectLastCall().times(1);
-
- replay(mock);
- interceptor.intercept(mai);
- verify(mock);
- }
-
- public void testActionApplicationAware() throws Exception {
- org.apache.struts2.action.ApplicationAware mock = createMock(org.apache.struts2.action.ApplicationAware.class);
-
- MockActionInvocation mai = createActionInvocation(mock);
-
Map<String, Object> app = new HashMap<>();
mai.getInvocationContext().withApplication(app);
@@ -230,27 +135,7 @@ public class ServletConfigInterceptorTest extends StrutsInternalTestCase {
MockHttpServletRequest req = new MockHttpServletRequest();
req.setUserPrincipal(null);
req.setRemoteUser("Santa");
- PrincipalAware mock = (PrincipalAware) createMock(PrincipalAware.class);
-
- MockActionInvocation mai = createActionInvocation(mock);
- mai.getInvocationContext().put(StrutsStatics.HTTP_REQUEST, req);
-
- MockServletContext ctx = new MockServletContext();
- mai.getInvocationContext().put(StrutsStatics.SERVLET_CONTEXT, ctx);
-
- mock.setPrincipalProxy(anyObject(ServletPrincipalProxy.class)); // less strick match is needed for this unit test to be conducted using mocks
- expectLastCall().times(1);
-
- replay(mock);
- interceptor.intercept(mai);
- verify(mock);
- }
-
- public void testActionPrincipalAware() throws Exception {
- MockHttpServletRequest req = new MockHttpServletRequest();
- req.setUserPrincipal(null);
- req.setRemoteUser("Santa");
- org.apache.struts2.action.PrincipalAware mock = createMock(org.apache.struts2.action.PrincipalAware.class);
+ PrincipalAware mock = createMock(PrincipalAware.class);
MockActionInvocation mai = createActionInvocation(mock);
mai.getInvocationContext().put(StrutsStatics.HTTP_REQUEST, req);
@@ -266,35 +151,13 @@ public class ServletConfigInterceptorTest extends StrutsInternalTestCase {
verify(mock);
}
- public void testPrincipalProxy() throws Exception {
- // uni test that does not use mock, but an Action so we also get code coverage for the PrincipalProxy class
- MockHttpServletRequest req = new MockHttpServletRequest();
- req.setUserPrincipal(null);
- req.setRemoteUser("Santa");
-
- MyPrincipalAction action = new MyPrincipalAction();
- MockActionInvocation mai = createActionInvocation(action);
- mai.getInvocationContext().put(StrutsStatics.HTTP_REQUEST, req);
-
- assertNull(action.getProxy());
- interceptor.intercept(mai);
- assertNotNull(action.getProxy());
-
- PrincipalProxy proxy = action.getProxy();
- assertNull(proxy.getUserPrincipal());
- assertTrue(!proxy.isRequestSecure());
- assertTrue(!proxy.isUserInRole("no.role"));
- assertEquals("Santa", proxy.getRemoteUser());
-
- }
-
public void testActionPrincipalProxy() throws Exception {
// unit test that does not use mock, but an Action so we also get code coverage for the PrincipalProxy class
MockHttpServletRequest req = new MockHttpServletRequest();
req.setUserPrincipal(null);
req.setRemoteUser("Santa");
- MyNewPrincipalAction action = new MyNewPrincipalAction();
+ MyPrincipalAction action = new MyPrincipalAction();
MockActionInvocation mai = createActionInvocation(action);
mai.getInvocationContext().put(StrutsStatics.HTTP_REQUEST, req);
@@ -310,22 +173,6 @@ public class ServletConfigInterceptorTest extends StrutsInternalTestCase {
}
- public void testServletContextAware() throws Exception {
- ServletContextAware mock = (ServletContextAware) createMock(ServletContextAware.class);
-
- MockActionInvocation mai = createActionInvocation(mock);
-
- MockServletContext ctx = new MockServletContext();
- mai.getInvocationContext().put(StrutsStatics.SERVLET_CONTEXT, ctx);
-
- mock.setServletContext((ServletContext) ctx);
- expectLastCall().times(1);
-
- replay(mock);
- interceptor.intercept(mai);
- verify(mock);
- }
-
public void testActionServletContextAware() throws Exception {
org.apache.struts2.action.ServletContextAware mock = createMock(org.apache.struts2.action.ServletContextAware.class);
@@ -371,23 +218,6 @@ public class ServletConfigInterceptorTest extends StrutsInternalTestCase {
return SUCCESS;
}
- public void setPrincipalProxy(PrincipalProxy proxy) {
- this.proxy = proxy;
- }
-
- public PrincipalProxy getProxy() {
- return proxy;
- }
- }
-
- private class MyNewPrincipalAction implements Action, org.apache.struts2.action.PrincipalAware {
-
- private PrincipalProxy proxy;
-
- public String execute() throws Exception {
- return SUCCESS;
- }
-
public void withPrincipalProxy(PrincipalProxy proxy) {
this.proxy = proxy;
}
diff --git a/plugins/portlet/src/main/java/org/apache/struts2/portlet/dispatcher/DirectRenderFromEventAction.java b/plugins/portlet/src/main/java/org/apache/struts2/portlet/dispatcher/DirectRenderFromEventAction.java
index 355630cc1..628404fb0 100644
--- a/plugins/portlet/src/main/java/org/apache/struts2/portlet/dispatcher/DirectRenderFromEventAction.java
+++ b/plugins/portlet/src/main/java/org/apache/struts2/portlet/dispatcher/DirectRenderFromEventAction.java
@@ -19,7 +19,8 @@
package org.apache.struts2.portlet.dispatcher;
import com.opensymphony.xwork2.Action;
-import org.apache.struts2.interceptor.SessionAware;
+
+import org.apache.struts2.action.SessionAware;
import org.apache.struts2.portlet.PortletConstants;
import java.io.Serializable;
@@ -67,7 +68,8 @@ public class DirectRenderFromEventAction implements SessionAware, Action, Serial
return SUCCESS;
}
- public void setSession(Map session) {
- location = (String)session.get(PortletConstants.RENDER_DIRECT_LOCATION);
- }
+ @Override
+ public void withSession(Map<String, Object> session) {
+ location = (String)session.get(PortletConstants.RENDER_DIRECT_LOCATION);
+ }
}
diff --git a/plugins/portlet/src/main/java/org/apache/struts2/portlet/interceptor/PortletAwareInterceptor.java b/plugins/portlet/src/main/java/org/apache/struts2/portlet/interceptor/PortletAwareInterceptor.java
index 420042e1d..ca41bb7f7 100644
--- a/plugins/portlet/src/main/java/org/apache/struts2/portlet/interceptor/PortletAwareInterceptor.java
+++ b/plugins/portlet/src/main/java/org/apache/struts2/portlet/interceptor/PortletAwareInterceptor.java
@@ -24,8 +24,12 @@ import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.struts2.StrutsStatics;
-import org.apache.struts2.interceptor.PrincipalAware;
+import org.apache.struts2.action.PrincipalAware;
import org.apache.struts2.portlet.PortletConstants;
+import org.apache.struts2.portlet.action.PortletContextAware;
+import org.apache.struts2.portlet.action.PortletPreferencesAware;
+import org.apache.struts2.portlet.action.PortletRequestAware;
+import org.apache.struts2.portlet.action.PortletResponseAware;
import javax.portlet.PortletContext;
import javax.portlet.PortletRequest;
@@ -50,42 +54,22 @@ public class PortletAwareInterceptor extends AbstractInterceptor implements Stru
if (action instanceof PortletRequestAware) {
PortletRequest request = (PortletRequest) context.get(PortletConstants.REQUEST);
- ((PortletRequestAware) action).setPortletRequest(request);
- }
-
- if (action instanceof org.apache.struts2.portlet.action.PortletRequestAware) {
- PortletRequest request = (PortletRequest) context.get(PortletConstants.REQUEST);
- ((org.apache.struts2.portlet.action.PortletRequestAware) action).withPortletRequest(request);
+ ((PortletRequestAware) action).withPortletRequest(request);
}
if (action instanceof PortletResponseAware) {
PortletResponse response = (PortletResponse) context.get(PortletConstants.RESPONSE);
- ((PortletResponseAware) action).setPortletResponse(response);
- }
-
- if (action instanceof org.apache.struts2.portlet.action.PortletResponseAware) {
- PortletResponse response = (PortletResponse) context.get(PortletConstants.RESPONSE);
- ((org.apache.struts2.portlet.action.PortletResponseAware) action).withPortletResponse(response);
+ ((PortletResponseAware) action).withPortletResponse(response);
}
if (action instanceof PrincipalAware) {
PortletRequest request = (PortletRequest) context.get(PortletConstants.REQUEST);
- ((PrincipalAware) action).setPrincipalProxy(new PortletPrincipalProxy(request));
- }
-
- if (action instanceof org.apache.struts2.action.PrincipalAware) {
- PortletRequest request = (PortletRequest) context.get(PortletConstants.REQUEST);
- ((org.apache.struts2.action.PrincipalAware) action).withPrincipalProxy(new PortletPrincipalProxy(request));
+ ((PrincipalAware) action).withPrincipalProxy(new PortletPrincipalProxy(request));
}
if (action instanceof PortletContextAware) {
PortletContext portletContext = (PortletContext) context.get(StrutsStatics.STRUTS_PORTLET_CONTEXT);
- ((PortletContextAware) action).setPortletContext(portletContext);
- }
-
- if (action instanceof org.apache.struts2.portlet.action.PortletContextAware) {
- PortletContext portletContext = (PortletContext) context.get(StrutsStatics.STRUTS_PORTLET_CONTEXT);
- ((org.apache.struts2.portlet.action.PortletContextAware) action).withPortletContext(portletContext);
+ ((PortletContextAware) action).withPortletContext(portletContext);
}
if (action instanceof PortletPreferencesAware) {
@@ -94,21 +78,9 @@ public class PortletAwareInterceptor extends AbstractInterceptor implements Stru
// Check if running in a servlet environment
if (request == null) {
LOG.warn("This portlet preferences implementation should only be used during development");
- ((PortletPreferencesAware) action).setPortletPreferences(new ServletPortletPreferences(ActionContext.getContext().getSession()));
- } else {
- ((PortletPreferencesAware) action).setPortletPreferences(request.getPreferences());
- }
- }
-
- if (action instanceof org.apache.struts2.portlet.action.PortletPreferencesAware) {
- PortletRequest request = (PortletRequest) context.get(PortletConstants.REQUEST);
-
- // Check if running in a servlet environment
- if (request == null) {
- LOG.warn("This portlet preferences implementation should only be used during development");
- ((org.apache.struts2.portlet.action.PortletPreferencesAware) action).withPortletPreferences(new ServletPortletPreferences(ActionContext.getContext().getSession()));
+ ((PortletPreferencesAware) action).withPortletPreferences(new ServletPortletPreferences(ActionContext.getContext().getSession()));
} else {
- ((org.apache.struts2.portlet.action.PortletPreferencesAware) action).withPortletPreferences(request.getPreferences());
+ ((PortletPreferencesAware) action).withPortletPreferences(request.getPreferences());
}
}
diff --git a/plugins/portlet/src/main/java/org/apache/struts2/portlet/interceptor/PortletContextAware.java b/plugins/portlet/src/main/java/org/apache/struts2/portlet/interceptor/PortletContextAware.java
deleted file mode 100644
index 5ea01856a..000000000
--- a/plugins/portlet/src/main/java/org/apache/struts2/portlet/interceptor/PortletContextAware.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.struts2.portlet.interceptor;
-
-import javax.portlet.PortletContext;
-
-/**
- * @deprecated please use {@link org.apache.struts2.portlet.action.PortletContextAware} instead
- */
-@Deprecated
-public interface PortletContextAware {
-
- /**
- * @deprecated please use {@link org.apache.struts2.portlet.action.PortletContextAware#withPortletContext(PortletContext)} instead
- */
- void setPortletContext(PortletContext portletContext);
-
-}
diff --git a/plugins/portlet/src/main/java/org/apache/struts2/portlet/interceptor/PortletPreferencesAware.java b/plugins/portlet/src/main/java/org/apache/struts2/portlet/interceptor/PortletPreferencesAware.java
deleted file mode 100644
index de39b25eb..000000000
--- a/plugins/portlet/src/main/java/org/apache/struts2/portlet/interceptor/PortletPreferencesAware.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.struts2.portlet.interceptor;
-
-import javax.portlet.PortletPreferences;
-
-
-/**
- * All Actions that want to have access to the portlet preferences should
- * implement this interface. If running in a servlet environment, an
- * appropriate testing implementation will be provided.
- *
- * @deprecated please use {@link org.apache.struts2.portlet.action.PortletPreferencesAware} instead
- */
-@Deprecated
-public interface PortletPreferencesAware {
-
- /**
- * Sets the HTTP request object in implementing classes.
- *
- * @param prefs the portlet preferences.
- * @deprecated please use {@link org.apache.struts2.portlet.action.PortletPreferencesAware#withPortletPreferences(PortletPreferences)} instead
- */
- @Deprecated
- void setPortletPreferences(PortletPreferences prefs);
-}
diff --git a/plugins/portlet/src/main/java/org/apache/struts2/portlet/interceptor/PortletRequestAware.java b/plugins/portlet/src/main/java/org/apache/struts2/portlet/interceptor/PortletRequestAware.java
deleted file mode 100644
index 8903d9f45..000000000
--- a/plugins/portlet/src/main/java/org/apache/struts2/portlet/interceptor/PortletRequestAware.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.struts2.portlet.interceptor;
-
-import javax.portlet.PortletRequest;
-
-/**
- * @deprecated please use {@link org.apache.struts2.portlet.action.PortletRequestAware} instead
- */
-@Deprecated
-public interface PortletRequestAware {
-
- /**
- * @deprecated please use {@link org.apache.struts2.portlet.action.PortletRequestAware#withPortletRequest(PortletRequest)} instead
- */
- @Deprecated
- void setPortletRequest(PortletRequest request);
-
-}
diff --git a/plugins/portlet/src/main/java/org/apache/struts2/portlet/interceptor/PortletResponseAware.java b/plugins/portlet/src/main/java/org/apache/struts2/portlet/interceptor/PortletResponseAware.java
deleted file mode 100644
index dc4f71b93..000000000
--- a/plugins/portlet/src/main/java/org/apache/struts2/portlet/interceptor/PortletResponseAware.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.struts2.portlet.interceptor;
-
-import javax.portlet.PortletResponse;
-
-/**
- * @deprecated please use {@link org.apache.struts2.portlet.action.PortletResponseAware} instead
- */
-@Deprecated
-public interface PortletResponseAware {
-
- /**
- * @deprecated please use {@link org.apache.struts2.portlet.action.PortletResponseAware#withPortletResponse(PortletResponse)} instead
- */
- @Deprecated
- void setPortletResponse(PortletResponse response);
-
-}
diff --git a/plugins/portlet/src/test/java/org/apache/struts2/portlet/interceptor/PortletAwareInterceptorTest.java b/plugins/portlet/src/test/java/org/apache/struts2/portlet/interceptor/PortletAwareInterceptorTest.java
index 8c400a1ea..4e798bcc2 100644
--- a/plugins/portlet/src/test/java/org/apache/struts2/portlet/interceptor/PortletAwareInterceptorTest.java
+++ b/plugins/portlet/src/test/java/org/apache/struts2/portlet/interceptor/PortletAwareInterceptorTest.java
@@ -22,6 +22,8 @@ import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import junit.framework.TestCase;
import org.apache.struts2.portlet.PortletConstants;
+import org.apache.struts2.portlet.action.PortletRequestAware;
+import org.apache.struts2.portlet.action.PortletResponseAware;
import org.easymock.EasyMock;
import javax.portlet.PortletRequest;
@@ -42,33 +44,12 @@ public class PortletAwareInterceptorTest extends TestCase {
super.tearDown();
}
- public void testPortletRequestIsSet() throws Exception {
- PortletRequest request = EasyMock.createMock(PortletRequest.class);
- Map<String, Object> ctx = new HashMap<>();
- ctx.put(PortletConstants.REQUEST, request);
- ActionContext actionContext = ActionContext.of(ctx).bind();
-
- PortletRequestAware action = EasyMock.createMock(PortletRequestAware.class);
- action.setPortletRequest(request);
-
- ActionInvocation invocation = EasyMock.createNiceMock(ActionInvocation.class);
- EasyMock.expect(invocation.getInvocationContext()).andReturn(actionContext);
- EasyMock.expect(invocation.getAction()).andReturn(action);
-
- EasyMock.replay(action);
- EasyMock.replay(invocation);
-
- interceptor.intercept(invocation);
-
- EasyMock.verify(action);
- }
-
- public void testActionPortletRequestAware() throws Exception {
+ public void testPortletRequestAware() throws Exception {
PortletRequest request = EasyMock.createMock(PortletRequest.class);
Map<String, Object> ctx = new HashMap<>();
ActionContext actionContext = ActionContext.of(ctx).bind();
ctx.put(PortletConstants.REQUEST, request);
- org.apache.struts2.portlet.action.PortletRequestAware action = EasyMock.createMock(org.apache.struts2.portlet.action.PortletRequestAware.class);
+ PortletRequestAware action = EasyMock.createMock(PortletRequestAware.class);
action.withPortletRequest(request);
ActionInvocation invocation = EasyMock.createNiceMock(ActionInvocation.class);
@@ -83,12 +64,12 @@ public class PortletAwareInterceptorTest extends TestCase {
EasyMock.verify(action);
}
- public void testActionPortletResponseAware() throws Exception {
+ public void testPortletResponseAware() throws Exception {
PortletResponse response = EasyMock.createMock(PortletResponse.class);
Map<String, Object> ctx = new HashMap<>();
ctx.put(PortletConstants.RESPONSE, response);
ActionContext actionContext = ActionContext.of(ctx).bind();
- org.apache.struts2.portlet.action.PortletResponseAware action = EasyMock.createMock(org.apache.struts2.portlet.action.PortletResponseAware.class);
+ PortletResponseAware action = EasyMock.createMock(PortletResponseAware.class);
action.withPortletResponse(response);
ActionInvocation invocation = EasyMock.createNiceMock(ActionInvocation.class);
diff --git a/plugins/portlet/src/test/java/org/apache/struts2/portlet/interceptor/PortletStateInterceptorTest.java b/plugins/portlet/src/test/java/org/apache/struts2/portlet/interceptor/PortletStateInterceptorTest.java
index f324cf225..d60b866e4 100644
--- a/plugins/portlet/src/test/java/org/apache/struts2/portlet/interceptor/PortletStateInterceptorTest.java
+++ b/plugins/portlet/src/test/java/org/apache/struts2/portlet/interceptor/PortletStateInterceptorTest.java
@@ -58,7 +58,7 @@ public class PortletStateInterceptorTest extends StrutsTestCasePortletTests {
Map<String, Object> session = new HashMap<>();
ActionContext ctx = ActionContext.of(ctxMap).bind();
- ctx.setSession(session);
+ ctx.withSession(session);
EasyMock.expect(invocation.getInvocationContext()).andStubReturn(ctx);
actionResponse.setRenderParameter(EVENT_ACTION, "true");
@@ -97,7 +97,7 @@ public class PortletStateInterceptorTest extends StrutsTestCasePortletTests {
ctxMap.put(REQUEST, renderRequest);
ActionContext ctx = ActionContext.of(ctxMap).bind();
- ctx.setSession(session);
+ ctx.withSession(session);
EasyMock.expect(invocation.getInvocationContext()).andStubReturn(ctx);
EasyMock.expect(invocation.getStack()).andStubReturn(currentStack);
@@ -138,7 +138,7 @@ public class PortletStateInterceptorTest extends StrutsTestCasePortletTests {
ctxMap.put(REQUEST, renderRequest);
ActionContext ctx = ActionContext.of(ctxMap).bind();
- ctx.setSession(session);
+ ctx.withSession(session);
EasyMock.expect(invocation.getInvocationContext()).andStubReturn(ctx);
EasyMock.expect(invocation.getStack()).andStubReturn(currentStack);