1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package org.apache.struts2.impl;
24
25 import java.lang.reflect.Method;
26 import java.util.ArrayList;
27 import java.util.List;
28
29 import org.apache.struts2.spi.ActionContext;
30 import org.apache.struts2.spi.Result;
31
32 import com.opensymphony.xwork2.ActionInvocation;
33
34 public class ActionContextImpl implements ActionContext {
35
36 final ActionInvocation invocation;
37
38 public ActionContextImpl(ActionInvocation invocation) {
39 this.invocation = invocation;
40 }
41
42 public Object getAction() {
43 return invocation.getAction();
44 }
45
46 public Method getMethod() {
47 String methodName = invocation.getProxy().getMethod();
48 try {
49 return getAction().getClass().getMethod(methodName);
50 } catch (NoSuchMethodException e) {
51 throw new RuntimeException(e);
52 }
53 }
54
55 public String getActionName() {
56 return invocation.getProxy().getActionName();
57 }
58
59 public String getNamespacePath() {
60 return invocation.getProxy().getNamespace();
61 }
62
63
64 List<Result> resultInterceptors = new ArrayList<Result>();
65
66 public void addResultInterceptor(Result interceptor) {
67 resultInterceptors.add(interceptor);
68 }
69
70 public Result getResult() {
71
72 throw new UnsupportedOperationException();
73 }
74
75 public ActionContext getPrevious() {
76
77 throw new UnsupportedOperationException();
78 }
79
80 public ActionContext getNext() {
81
82 throw new UnsupportedOperationException();
83 }
84 }