diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/source/ViewSourceAction.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/source/ViewSourceAction.java
index 3b71fa68e..56dbf9bfb 100644
--- a/apps/showcase/src/main/java/org/apache/struts2/showcase/source/ViewSourceAction.java
+++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/source/ViewSourceAction.java
@@ -23,7 +23,7 @@ package org.apache.struts2.showcase.source;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.util.ClassLoaderUtil;
import org.apache.struts2.ServletActionContext;
-import org.apache.struts2.util.ServletContextAware;
+import org.apache.struts2.action.ServletContextAware;
import javax.servlet.ServletContext;
import java.io.BufferedReader;
@@ -227,7 +227,7 @@ public class ViewSourceAction extends ActionSupport implements ServletContextAwa
return snippet;
}
- public void setServletContext(ServletContext arg0) {
+ public void withServletContext(ServletContext arg0) {
this.servletContext = arg0;
}
diff --git a/bundles/admin/src/main/java/org/apache/struts2/osgi/admin/actions/BundlesAction.java b/bundles/admin/src/main/java/org/apache/struts2/osgi/admin/actions/BundlesAction.java
index 5d81de896..cf6edb07f 100644
--- a/bundles/admin/src/main/java/org/apache/struts2/osgi/admin/actions/BundlesAction.java
+++ b/bundles/admin/src/main/java/org/apache/struts2/osgi/admin/actions/BundlesAction.java
@@ -28,7 +28,7 @@ import com.opensymphony.xwork2.inject.Inject;
import org.apache.struts2.osgi.BundleAccessor;
import org.apache.struts2.osgi.host.OsgiHost;
import org.apache.struts2.osgi.StrutsOsgiListener;
-import org.apache.struts2.util.ServletContextAware;
+import org.apache.struts2.action.ServletContextAware;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
@@ -197,7 +197,7 @@ public class BundlesAction extends ActionSupport implements ServletContextAware
this.bundleAccessor = bundleAccessor;
}
- public void setServletContext(ServletContext servletContext) {
+ public void withServletContext(ServletContext servletContext) {
osgiHost = (OsgiHost) servletContext.getAttribute(StrutsOsgiListener.OSGI_HOST);
}
}
diff --git a/bundles/demo/src/main/java/actions/osgi/BundlesAction.java b/bundles/demo/src/main/java/actions/osgi/BundlesAction.java
index eff79ccce..9c5464fcb 100644
--- a/bundles/demo/src/main/java/actions/osgi/BundlesAction.java
+++ b/bundles/demo/src/main/java/actions/osgi/BundlesAction.java
@@ -22,7 +22,7 @@ package actions.osgi;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.convention.annotation.ResultPath;
-import org.apache.struts2.osgi.interceptor.BundleContextAware;
+import org.apache.struts2.osgi.action.BundleContextAware;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
@@ -33,7 +33,7 @@ import org.osgi.framework.BundleContext;
public class BundlesAction extends ActionSupport implements BundleContextAware {
private BundleContext bundleContext;
- public void setBundleContext(BundleContext bundleContext) {
+ public void withBundleContext(BundleContext bundleContext) {
this.bundleContext = bundleContext;
}
diff --git a/core/src/main/java/org/apache/struts2/action/ApplicationAware.java b/core/src/main/java/org/apache/struts2/action/ApplicationAware.java
new file mode 100644
index 000000000..3748e60f2
--- /dev/null
+++ b/core/src/main/java/org/apache/struts2/action/ApplicationAware.java
@@ -0,0 +1,38 @@
+/*
+ * 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.action;
+
+import java.util.Map;
+
+/**
+ * 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.
+ *
+ * Typical uses are configuration objects and caches.
+ */
+public interface ApplicationAware {
+
+ /**
+ * Applies the map of application properties in the implementing class.
+ *
+ * @param application a Map of application properties.
+ */
+ void withApplication(Map application);
+}
diff --git a/core/src/main/java/org/apache/struts2/action/CookiesAware.java b/core/src/main/java/org/apache/struts2/action/CookiesAware.java
new file mode 100644
index 000000000..ba753869a
--- /dev/null
+++ b/core/src/main/java/org/apache/struts2/action/CookiesAware.java
@@ -0,0 +1,40 @@
+/*
+ * 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.action;
+
+import org.apache.struts2.interceptor.CookieInterceptor;
+
+import java.util.Map;
+
+/**
+ * Actions implementing the CookiesAware interface will receive
+ * a Map of filtered cookies via the setCookiesMap method.
+ *
+ * Please note that the {@link CookieInterceptor} needs to be
+ * activated to receive a cookies map.
+ *
+ * @since 2.6
+ */
+public interface CookiesAware {
+ /**
+ * Sets a map of filtered cookies.
+ * @param cookies the cookies
+ */
+ void withCookies(Map cookies);
+}
\ No newline at end of file
diff --git a/core/src/main/java/org/apache/struts2/action/ParametersAware.java b/core/src/main/java/org/apache/struts2/action/ParametersAware.java
new file mode 100644
index 000000000..475d603c0
--- /dev/null
+++ b/core/src/main/java/org/apache/struts2/action/ParametersAware.java
@@ -0,0 +1,41 @@
+/*
+ * 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.action;
+
+import org.apache.struts2.dispatcher.HttpParameters;
+
+/**
+ * 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.
+ *
+ * One common use for this is to have the action propagate parameters to internally instantiated data
+ * objects.
+ *
+ * @since 2.6
+ */
+public interface ParametersAware {
+
+ /**
+ * Sets the HTTP parameters in the implementing class.
+ *
+ * @param parameters an instance of {@link HttpParameters}.
+ */
+ void withParameters(HttpParameters parameters);
+}
diff --git a/core/src/main/java/org/apache/struts2/action/PrincipalAware.java b/core/src/main/java/org/apache/struts2/action/PrincipalAware.java
new file mode 100644
index 000000000..9bff42beb
--- /dev/null
+++ b/core/src/main/java/org/apache/struts2/action/PrincipalAware.java
@@ -0,0 +1,34 @@
+/*
+ * 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.action;
+
+import org.apache.struts2.interceptor.PrincipalProxy;
+
+/**
+ * Actions that want access to the Principal information from HttpServletRequest object
+ * should implement this interface.
+ *
+ * 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.
+ */
+public interface PrincipalAware {
+
+ void withPrincipalProxy(PrincipalProxy principalProxy);
+
+}
diff --git a/core/src/main/java/org/apache/struts2/action/ServletContextAware.java b/core/src/main/java/org/apache/struts2/action/ServletContextAware.java
new file mode 100644
index 000000000..09a99d081
--- /dev/null
+++ b/core/src/main/java/org/apache/struts2/action/ServletContextAware.java
@@ -0,0 +1,31 @@
+/*
+ * 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.action;
+
+import javax.servlet.ServletContext;
+
+/**
+ * For components that have a dependence on the Servlet context.
+ *
+ * @since 2.6
+ */
+public interface ServletContextAware {
+
+ void withServletContext(ServletContext context);
+}
diff --git a/core/src/main/java/org/apache/struts2/action/ServletRequestAware.java b/core/src/main/java/org/apache/struts2/action/ServletRequestAware.java
new file mode 100644
index 000000000..115bff35e
--- /dev/null
+++ b/core/src/main/java/org/apache/struts2/action/ServletRequestAware.java
@@ -0,0 +1,39 @@
+/*
+ * 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.action;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * All Actions that want to have access to the servlet request object must implement this interface.
+ *
+ * This interface is only relevant if the Action is used in a servlet environment.
+ *
+ * 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 ServletRequestAware {
+
+ /**
+ * Applies the HTTP request object in implementing classes.
+ *
+ * @param request the HTTP request.
+ */
+ void withServletRequest(HttpServletRequest request);
+}
diff --git a/core/src/main/java/org/apache/struts2/action/ServletResponseAware.java b/core/src/main/java/org/apache/struts2/action/ServletResponseAware.java
new file mode 100644
index 000000000..0403f1f9c
--- /dev/null
+++ b/core/src/main/java/org/apache/struts2/action/ServletResponseAware.java
@@ -0,0 +1,39 @@
+/*
+ * 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.action;
+
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * All Actions that want to have access to the servlet response object must implement this interface.
+ *
+ * This interface is only relevant if the Action is used in a servlet environment.
+ *
+ * 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 ServletResponseAware {
+
+ /**
+ * Applies the HTTP response object in implementing classes.
+ *
+ * @param response the HTTP response.
+ */
+ void withServletResponse(HttpServletResponse response);
+}
diff --git a/core/src/main/java/org/apache/struts2/action/SessionAware.java b/core/src/main/java/org/apache/struts2/action/SessionAware.java
new file mode 100644
index 000000000..039fcca00
--- /dev/null
+++ b/core/src/main/java/org/apache/struts2/action/SessionAware.java
@@ -0,0 +1,40 @@
+/*
+ * 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.action;
+
+import java.util.Map;
+
+/**
+ * Actions that want access to the user's HTTP session attributes should implement this interface.
+ *
+ * This will give them access to a Map where they can put objects that can be made available
+ * to subsequent requests.
+ *
+ * Typical uses may be cached user data such as name, or a shopping cart.
+ */
+public interface SessionAware {
+
+ /**
+ * Applies the Map of session attributes in the implementing class.
+ *
+ * @param session a Map of HTTP session attribute name/value pairs.
+ */
+ void withSession(Map session);
+
+}
diff --git a/core/src/main/java/org/apache/struts2/interceptor/ApplicationAware.java b/core/src/main/java/org/apache/struts2/interceptor/ApplicationAware.java
index 4cdd4785e..c240fa8cb 100644
--- a/core/src/main/java/org/apache/struts2/interceptor/ApplicationAware.java
+++ b/core/src/main/java/org/apache/struts2/interceptor/ApplicationAware.java
@@ -29,13 +29,17 @@ import java.util.Map;
*
* Typical uses are configuration objects and caches.
*
+ * @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 application);
}
diff --git a/core/src/main/java/org/apache/struts2/interceptor/CookieInterceptor.java b/core/src/main/java/org/apache/struts2/interceptor/CookieInterceptor.java
index 86578e77b..eb40c3a53 100644
--- a/core/src/main/java/org/apache/struts2/interceptor/CookieInterceptor.java
+++ b/core/src/main/java/org/apache/struts2/interceptor/CookieInterceptor.java
@@ -348,8 +348,8 @@ public class CookieInterceptor extends AbstractInterceptor {
}
/**
- * Hook that set the cookiesMap into action that implements
- * {@link CookiesAware}.
+ * Hook that set the cookiesMap into action that implements {@link CookiesAware}
+ * or {@link org.apache.struts2.action.CookiesAware}.
*
* @param action action object
* @param cookiesMap map of cookies
@@ -359,5 +359,9 @@ public class CookieInterceptor extends AbstractInterceptor {
LOG.debug("Action [{}] implements CookiesAware, injecting cookies map [{}]", action, cookiesMap);
((CookiesAware)action).setCookiesMap(cookiesMap);
}
+ if (action instanceof org.apache.struts2.action.CookiesAware) {
+ LOG.debug("Action [{}] implements CookiesAware, injecting cookies map [{}]", action, cookiesMap);
+ ((org.apache.struts2.action.CookiesAware)action).withCookies(cookiesMap);
+ }
}
}
diff --git a/core/src/main/java/org/apache/struts2/interceptor/CookiesAware.java b/core/src/main/java/org/apache/struts2/interceptor/CookiesAware.java
index 0632e8326..d3a0a02b1 100644
--- a/core/src/main/java/org/apache/struts2/interceptor/CookiesAware.java
+++ b/core/src/main/java/org/apache/struts2/interceptor/CookiesAware.java
@@ -26,11 +26,15 @@ import java.util.Map;
*
* Please note that the {@link CookieInterceptor} needs to be
* activated to receive a cookies map.
+ *
+ * @deprecated please use {@link org.apache.struts2.action.CookiesAware} instead
*/
+@Deprecated
public interface CookiesAware {
/**
* Sets a map of filtered cookies.
* @param cookies the cookies
+ * @deprecated please use {@link org.apache.struts2.action.CookiesAware#withCookies(Map)} instead
*/
void setCookiesMap(Map cookies);
}
\ No newline at end of file
diff --git a/core/src/main/java/org/apache/struts2/interceptor/HttpParametersAware.java b/core/src/main/java/org/apache/struts2/interceptor/HttpParametersAware.java
index 66f2a1d44..c27a05694 100644
--- a/core/src/main/java/org/apache/struts2/interceptor/HttpParametersAware.java
+++ b/core/src/main/java/org/apache/struts2/interceptor/HttpParametersAware.java
@@ -31,13 +31,19 @@ import org.apache.struts2.dispatcher.HttpParameters;
* One common use for this is to have the action propagate parameters to internally instantiated data
* objects.
*
+ *
+ * @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
index 28eb7491f..9689e36b9 100644
--- a/core/src/main/java/org/apache/struts2/interceptor/ParameterAware.java
+++ b/core/src/main/java/org/apache/struts2/interceptor/ParameterAware.java
@@ -36,7 +36,7 @@ import java.util.Map;
* the map is java.lang.String[].
*
*
- * @deprecated please use {@link HttpParametersAware} instead
+ * @deprecated please use {@link org.apache.struts2.action.ParametersAware} instead
*/
@Deprecated
public interface ParameterAware {
diff --git a/core/src/main/java/org/apache/struts2/interceptor/PrincipalAware.java b/core/src/main/java/org/apache/struts2/interceptor/PrincipalAware.java
index 7bf418ec9..ac1e3296b 100644
--- a/core/src/main/java/org/apache/struts2/interceptor/PrincipalAware.java
+++ b/core/src/main/java/org/apache/struts2/interceptor/PrincipalAware.java
@@ -25,7 +25,14 @@ package org.apache.struts2.interceptor;
*
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.