findCookiesForName(String name);
+
+ /**
+ * Gets locale.
+ */
+ Locale getLocale();
+
+ /**
+ * Sets locale. Stores the locale in the session for future requests.
+ */
+ void setLocale(Locale locale);
+
+ /**
+ * Gets messages.
+ */
+ Messages getMessages();
+
+ /**
+ * Gets error messages.
+ */
+ Messages getErrors();
+
+ /**
+ * Gets the servlet request.
+ */
+ HttpServletRequest getServletRequest();
+
+ /**
+ * Gets the servlet response.
+ */
+ HttpServletResponse getServletResponse();
+
+ /**
+ * Gets the servlet context.
+ */
+ ServletContext getServletContext();
+
+ /**
+ * Gets the value stack.
+ */
+ ValueStack getValueStack();
+
+ /**
+ * Invokes the next interceptor or the action method if no more interceptors remain.
+ *
+ * @return result name
+ * @throws IllegalStateException if already invoked or called from the action
+ */
+ String proceed() throws Exception;
+}
diff --git a/action-api/src/main/java/org/apache/struts/action2/spi/RequestContextAware.java b/action-api/src/main/java/org/apache/struts/action2/spi/RequestContextAware.java
new file mode 100644
index 000000000..d192c5ca5
--- /dev/null
+++ b/action-api/src/main/java/org/apache/struts/action2/spi/RequestContextAware.java
@@ -0,0 +1,17 @@
+package org.apache.struts.action2.spi;
+
+/**
+ * Implemented by actions that need access to the current {@link org.apache.struts.action2.spi.RequestContext}. Use
+ * judiciously.
+ *
+ * @author crazybob@google.com (Bob Lee)
+ */
+public interface RequestContextAware {
+
+ /**
+ * Sets {@link org.apache.struts.action2.spi.RequestContext}.
+ *
+ * @param requestContext
+ */
+ void setRequestContext(RequestContext requestContext);
+}
diff --git a/action-api/src/main/java/org/apache/struts/action2/spi/Result.java b/action-api/src/main/java/org/apache/struts/action2/spi/Result.java
index 4273495a4..08021fa01 100644
--- a/action-api/src/main/java/org/apache/struts/action2/spi/Result.java
+++ b/action-api/src/main/java/org/apache/struts/action2/spi/Result.java
@@ -10,7 +10,7 @@ public interface Result {
/**
* Executes result.
*
- * @param request
+ * @param requestContext
*/
- void execute(Request request) throws Exception;
+ void execute(RequestContext requestContext) throws Exception;
}
diff --git a/action-api/src/main/java/org/apache/struts/action2/spi/ThreadLocalRequest.java b/action-api/src/main/java/org/apache/struts/action2/spi/ThreadLocalRequest.java
index d979efce4..e69de29bb 100644
--- a/action-api/src/main/java/org/apache/struts/action2/spi/ThreadLocalRequest.java
+++ b/action-api/src/main/java/org/apache/struts/action2/spi/ThreadLocalRequest.java
@@ -1,54 +0,0 @@
-package org.apache.struts.action2.spi;
-
-import java.util.concurrent.Callable;
-
-/**
- * Provides a reference to the current {@link Request} for this thread.
- *
- * Actions which spawn additional threads are responsible for setting this value if access to Struts from the
- * additional thread is needed.
- *
- * @author crazybob@google.com (Bob Lee)
- */
-public final class ThreadLocalRequest {
-
- static ThreadLocal threadLocalRequest = new ThreadLocal();
-
- private ThreadLocalRequest() {}
-
- /**
- * Sets {@link Request} for the current thread and invokes the provided {@link Callable}. Restores previous {@code
- * Request} (if any) when finished.
- *
- * @param request for current thread
- * @param callable
- * @return result of {@code callable}
- * @throws Exception from {@code callable}
- */
- public static T setAndCall(Request request, Callable callable) throws Exception {
- Request old = threadLocalRequest.get();
- try {
- threadLocalRequest.set(request);
- return callable.call();
- } finally {
- if (old == null)
- threadLocalRequest.remove();
- else
- threadLocalRequest.set(old);
- }
- }
-
- /**
- * Gets the {@link Request} for the current thread.
- *
- * @return request for current thread
- * @throws IllegalStateException if no request has been set
- */
- public static Request get() {
- Request request = threadLocalRequest.get();
- if (request == null) {
- throw new IllegalStateException(ThreadLocalRequest.class.getName() + " has not been set.");
- }
- return request;
- }
-}
diff --git a/action-api/src/main/java/org/apache/struts/action2/spi/ThreadLocalRequestContext.java b/action-api/src/main/java/org/apache/struts/action2/spi/ThreadLocalRequestContext.java
new file mode 100644
index 000000000..4bc32074e
--- /dev/null
+++ b/action-api/src/main/java/org/apache/struts/action2/spi/ThreadLocalRequestContext.java
@@ -0,0 +1,54 @@
+package org.apache.struts.action2.spi;
+
+import java.util.concurrent.Callable;
+
+/**
+ * Provides a reference to the current {@link RequestContext} for this thread.
+ *
+ * Actions which spawn additional threads are responsible for setting this value if access to Struts from the
+ * additional thread is needed.
+ *
+ * @author crazybob@google.com (Bob Lee)
+ */
+public final class ThreadLocalRequestContext {
+
+ static ThreadLocal threadLocalRequestContext = new ThreadLocal();
+
+ private ThreadLocalRequestContext() {}
+
+ /**
+ * Sets {@link RequestContext} for the current thread and invokes the provided {@link Callable}. Restores previous
+ * {@code RequestContext} (if any) when finished.
+ *
+ * @param requestContext for current thread
+ * @param callable
+ * @return result of {@code callable}
+ * @throws Exception from {@code callable}
+ */
+ public static T setAndCall(RequestContext requestContext, Callable callable) throws Exception {
+ RequestContext old = threadLocalRequestContext.get();
+ try {
+ threadLocalRequestContext.set(requestContext);
+ return callable.call();
+ } finally {
+ if (old == null)
+ threadLocalRequestContext.remove();
+ else
+ threadLocalRequestContext.set(old);
+ }
+ }
+
+ /**
+ * Gets the {@link RequestContext} for the current thread.
+ *
+ * @return request for current thread
+ * @throws IllegalStateException if no request has been set
+ */
+ public static RequestContext get() {
+ RequestContext requestContext = threadLocalRequestContext.get();
+ if (requestContext == null) {
+ throw new IllegalStateException(ThreadLocalRequestContext.class.getName() + " has not been set.");
+ }
+ return requestContext;
+ }
+}
diff --git a/action-api/src/main/java/org/apache/struts/action2/spi/package-info.java b/action-api/src/main/java/org/apache/struts/action2/spi/package-info.java
index c8c35b618..58c4a632b 100644
--- a/action-api/src/main/java/org/apache/struts/action2/spi/package-info.java
+++ b/action-api/src/main/java/org/apache/struts/action2/spi/package-info.java
@@ -1,4 +1,4 @@
/**
- * Struts Action 2.0 service provider API.
+ * Struts Action 2.0 service provider API
*/
package org.apache.struts.action2.spi;
\ No newline at end of file
diff --git a/action-api/src/test/java/org/apache/struts/action2/spi/ThreadLocalRequestTest.java b/action-api/src/test/java/org/apache/struts/action2/spi/ThreadLocalRequestTest.java
index e0f7691fa..2e425ec5d 100644
--- a/action-api/src/test/java/org/apache/struts/action2/spi/ThreadLocalRequestTest.java
+++ b/action-api/src/test/java/org/apache/struts/action2/spi/ThreadLocalRequestTest.java
@@ -11,21 +11,21 @@ import java.util.concurrent.Callable;
public class ThreadLocalRequestTest extends TestCase {
public void testSetAndCall() throws Exception {
- final Request r1 = createMock(Request.class);
- final Request r2 = createMock(Request.class);
+ final RequestContext r1 = createMock(RequestContext.class);
+ final RequestContext r2 = createMock(RequestContext.class);
ensureNotSet();
- String result = ThreadLocalRequest.setAndCall(r1, new Callable() {
+ String result = ThreadLocalRequestContext.setAndCall(r1, new Callable() {
public String call() throws Exception {
- assertSame(r1, ThreadLocalRequest.get());
- String result = ThreadLocalRequest.setAndCall(r2, new Callable() {
+ assertSame(r1, ThreadLocalRequestContext.get());
+ String result = ThreadLocalRequestContext.setAndCall(r2, new Callable() {
public String call() throws Exception {
- assertSame(r2, ThreadLocalRequest.get());
+ assertSame(r2, ThreadLocalRequestContext.get());
return "foo";
}
});
- assertSame(r1, ThreadLocalRequest.get());
+ assertSame(r1, ThreadLocalRequestContext.get());
return result;
}
});
@@ -37,7 +37,7 @@ public class ThreadLocalRequestTest extends TestCase {
private void ensureNotSet() {
try {
- ThreadLocalRequest.get();
+ ThreadLocalRequestContext.get();
fail();
}
catch (IllegalStateException e) { /* ignore */ }