View Javadoc

1   // Copyright 2006 Google Inc. All Rights Reserved.
2   
3   package org.apache.struts2.impl;
4   
5   import java.lang.reflect.Method;
6   import java.util.ArrayList;
7   import java.util.List;
8   
9   import org.apache.struts2.spi.ActionContext;
10  import org.apache.struts2.spi.Result;
11  
12  import com.opensymphony.xwork2.ActionInvocation;
13  
14  public class ActionContextImpl implements ActionContext {
15  
16      final ActionInvocation invocation;
17  
18      public ActionContextImpl(ActionInvocation invocation) {
19          this.invocation = invocation;
20      }
21  
22      public Object getAction() {
23          return invocation.getAction();
24      }
25  
26      public Method getMethod() {
27          String methodName = invocation.getProxy().getMethod();
28          try {
29              return getAction().getClass().getMethod(methodName);
30          } catch (NoSuchMethodException e) {
31              throw new RuntimeException(e);
32          }
33      }
34  
35      public String getActionName() {
36          return invocation.getProxy().getActionName();
37      }
38  
39      public String getNamespacePath() {
40          return invocation.getProxy().getNamespace();
41      }
42  
43      // TODO: Do something with these.
44      List<Result> resultInterceptors = new ArrayList<Result>();
45  
46      public void addResultInterceptor(Result interceptor) {
47          resultInterceptors.add(interceptor);
48      }
49  
50      public Result getResult() {
51          // TODO
52          throw new UnsupportedOperationException();
53      }
54  
55      public ActionContext getPrevious() {
56          // TODO
57          throw new UnsupportedOperationException();
58      }
59  
60      public ActionContext getNext() {
61          // TODO
62          throw new UnsupportedOperationException();
63      }
64  }