|
22 | 22 | import com.opensymphony.xwork2.util.ValueStack;
|
23 | 23 |
|
24 | 24 | /**
|
25 |
| - * An {@link ActionInvocation} represents the execution state of an {@link Action}. It holds the Interceptors and the Action instance. |
26 |
| - * By repeated re-entrant execution of the <code>invoke()</code> method, initially by the {@link ActionProxy}, then by the Interceptors, the |
27 |
| - * Interceptors are all executed, and then the {@link Action} and the {@link Result}. |
| 25 | + * {@inheritDoc} |
28 | 26 | *
|
29 |
| - * @author Jason Carreira |
30 |
| - * @see com.opensymphony.xwork2.ActionProxy |
| 27 | + * @deprecated since 6.7.0, use {@link org.apache.struts2.ActionInvocation} instead. |
31 | 28 | */
|
32 |
| -public interface ActionInvocation { |
33 |
| - |
34 |
| - /** |
35 |
| - * Get the Action associated with this ActionInvocation. |
36 |
| - * |
37 |
| - * @return the Action |
38 |
| - */ |
39 |
| - Object getAction(); |
40 |
| - |
41 |
| - /** |
42 |
| - * Gets whether this ActionInvocation has executed before. |
43 |
| - * This will be set after the Action and the Result have executed. |
44 |
| - * |
45 |
| - * @return <tt>true</tt> if this ActionInvocation has executed before. |
46 |
| - */ |
47 |
| - boolean isExecuted(); |
48 |
| - |
49 |
| - /** |
50 |
| - * Gets the ActionContext associated with this ActionInvocation. The ActionProxy is |
51 |
| - * responsible for setting this ActionContext onto the ThreadLocal before invoking |
52 |
| - * the ActionInvocation and resetting the old ActionContext afterwards. |
53 |
| - * |
54 |
| - * @return the ActionContext. |
55 |
| - */ |
| 29 | +@Deprecated |
| 30 | +public interface ActionInvocation extends org.apache.struts2.ActionInvocation { |
| 31 | + |
| 32 | + @Override |
56 | 33 | ActionContext getInvocationContext();
|
57 | 34 |
|
58 |
| - /** |
59 |
| - * Get the ActionProxy holding this ActionInvocation. |
60 |
| - * |
61 |
| - * @return the ActionProxy. |
62 |
| - */ |
63 |
| - ActionProxy getProxy(); |
64 |
| - |
65 |
| - /** |
66 |
| - * If the ActionInvocation has been executed before and the Result is an instance of {@link ActionChainResult}, this method |
67 |
| - * will walk down the chain of <code>ActionChainResult</code>s until it finds a non-chain result, which will be returned. If the |
68 |
| - * ActionInvocation's result has not been executed before, the Result instance will be created and populated with |
69 |
| - * the result params. |
70 |
| - * |
71 |
| - * @return the result. |
72 |
| - * @throws Exception can be thrown. |
73 |
| - */ |
| 35 | + @Override |
74 | 36 | Result getResult() throws Exception;
|
75 | 37 |
|
76 |
| - /** |
77 |
| - * Gets the result code returned from this ActionInvocation. |
78 |
| - * |
79 |
| - * @return the result code |
80 |
| - */ |
81 |
| - String getResultCode(); |
82 |
| - |
83 |
| - /** |
84 |
| - * Sets the result code, possibly overriding the one returned by the |
85 |
| - * action. |
86 |
| - * |
87 |
| - * <p> |
88 |
| - * The "intended" purpose of this method is to allow PreResultListeners to |
89 |
| - * override the result code returned by the Action. |
90 |
| - * </p> |
91 |
| - * |
92 |
| - * <p> |
93 |
| - * If this method is used before the Action executes, the Action's returned |
94 |
| - * result code will override what was set. However the Action could (if |
95 |
| - * specifically coded to do so) inspect the ActionInvocation to see that |
96 |
| - * someone "upstream" (e.g. an Interceptor) had suggested a value as the |
97 |
| - * result, and it could therefore return the same value itself. |
98 |
| - * </p> |
99 |
| - * |
100 |
| - * <p> |
101 |
| - * If this method is called between the Action execution and the Result |
102 |
| - * execution, then the value set here will override the result code the |
103 |
| - * action had returned. Creating an Interceptor that implements |
104 |
| - * {@link PreResultListener} will give you this opportunity. |
105 |
| - * </p> |
106 |
| - * |
107 |
| - * <p> |
108 |
| - * If this method is called after the Result has been executed, it will |
109 |
| - * have the effect of raising an IllegalStateException. |
110 |
| - * </p> |
111 |
| - * |
112 |
| - * @param resultCode the result code. |
113 |
| - * @throws IllegalStateException if called after the Result has been executed. |
114 |
| - * @see #isExecuted() |
115 |
| - */ |
116 |
| - void setResultCode(String resultCode); |
117 |
| - |
118 |
| - /** |
119 |
| - * Gets the ValueStack associated with this ActionInvocation. |
120 |
| - * |
121 |
| - * @return the ValueStack |
122 |
| - */ |
123 |
| - ValueStack getStack(); |
124 |
| - |
125 |
| - /** |
126 |
| - * Register a {@link PreResultListener} to be notified after the Action is executed and |
127 |
| - * before the Result is executed. |
128 |
| - * |
129 |
| - * <p> |
130 |
| - * The ActionInvocation implementation must guarantee that listeners will be called in |
131 |
| - * the order in which they are registered. |
132 |
| - * </p> |
133 |
| - * |
134 |
| - * <p> |
135 |
| - * Listener registration and execution does not need to be thread-safe. |
136 |
| - * </p> |
137 |
| - * |
138 |
| - * @param listener the listener to add. |
139 |
| - */ |
140 |
| - void addPreResultListener(PreResultListener listener); |
141 |
| - |
142 |
| - /** |
143 |
| - * Invokes the next step in processing this ActionInvocation. |
144 |
| - * |
145 |
| - * <p> |
146 |
| - * If there are more Interceptors, this will call the next one. If Interceptors choose not to short-circuit |
147 |
| - * ActionInvocation processing and return their own return code, they will call invoke() to allow the next Interceptor |
148 |
| - * to execute. If there are no more Interceptors to be applied, the Action is executed. |
149 |
| - * If the {@link ActionProxy#getExecuteResult()} method returns <tt>true</tt>, the Result is also executed. |
150 |
| - * </p> |
151 |
| - * |
152 |
| - * @throws Exception can be thrown. |
153 |
| - * @return the return code. |
154 |
| - */ |
155 |
| - String invoke() throws Exception; |
156 |
| - |
157 |
| - /** |
158 |
| - * Invokes only the Action (not Interceptors or Results). |
159 |
| - * |
160 |
| - * <p> |
161 |
| - * This is useful in rare situations where advanced usage with the interceptor/action/result workflow is |
162 |
| - * being manipulated for certain functionality. |
163 |
| - * </p> |
164 |
| - * |
165 |
| - * @return the return code. |
166 |
| - * @throws Exception can be thrown. |
167 |
| - */ |
168 |
| - String invokeActionOnly() throws Exception; |
169 |
| - |
170 |
| - /** |
171 |
| - * Sets the action event listener to respond to key action events. |
172 |
| - * |
173 |
| - * @param listener the listener. |
174 |
| - */ |
175 |
| - void setActionEventListener(ActionEventListener listener); |
176 |
| - |
177 |
| - void init(ActionProxy proxy) ; |
| 38 | + static ActionInvocation adapt(org.apache.struts2.ActionInvocation actualInvocation) { |
| 39 | + return actualInvocation != null ? new LegacyAdapter(actualInvocation) : null; |
| 40 | + } |
| 41 | + |
| 42 | + class LegacyAdapter implements ActionInvocation { |
| 43 | + |
| 44 | + private final org.apache.struts2.ActionInvocation adaptee; |
| 45 | + |
| 46 | + private LegacyAdapter(org.apache.struts2.ActionInvocation adaptee) { |
| 47 | + this.adaptee = adaptee; |
| 48 | + } |
| 49 | + |
| 50 | + @Override |
| 51 | + public Object getAction() { |
| 52 | + return adaptee.getAction(); |
| 53 | + } |
| 54 | + |
| 55 | + @Override |
| 56 | + public boolean isExecuted() { |
| 57 | + return adaptee.isExecuted(); |
| 58 | + } |
| 59 | + |
| 60 | + @Override |
| 61 | + public ActionContext getInvocationContext() { |
| 62 | + return ActionContext.adapt(adaptee.getInvocationContext()); |
| 63 | + } |
| 64 | + |
| 65 | + @Override |
| 66 | + public ActionProxy getProxy() { |
| 67 | + return adaptee.getProxy(); |
| 68 | + } |
| 69 | + |
| 70 | + @Override |
| 71 | + public Result getResult() throws Exception { |
| 72 | + return Result.adapt(adaptee.getResult()); |
| 73 | + } |
| 74 | + |
| 75 | + @Override |
| 76 | + public String getResultCode() { |
| 77 | + return adaptee.getResultCode(); |
| 78 | + } |
| 79 | + |
| 80 | + @Override |
| 81 | + public void setResultCode(String resultCode) { |
| 82 | + adaptee.setResultCode(resultCode); |
| 83 | + } |
| 84 | + |
| 85 | + @Override |
| 86 | + public ValueStack getStack() { |
| 87 | + return adaptee.getStack(); |
| 88 | + } |
| 89 | + |
| 90 | + @Override |
| 91 | + public void addPreResultListener(PreResultListener listener) { |
| 92 | + adaptee.addPreResultListener(listener); |
| 93 | + } |
| 94 | + |
| 95 | + @Override |
| 96 | + public String invoke() throws Exception { |
| 97 | + return adaptee.invoke(); |
| 98 | + } |
| 99 | + |
| 100 | + @Override |
| 101 | + public String invokeActionOnly() throws Exception { |
| 102 | + return adaptee.invokeActionOnly(); |
| 103 | + } |
| 104 | + |
| 105 | + @Override |
| 106 | + public void setActionEventListener(ActionEventListener listener) { |
| 107 | + adaptee.setActionEventListener(listener); |
| 108 | + } |
| 109 | + |
| 110 | + @Override |
| 111 | + public void init(ActionProxy proxy) { |
| 112 | + adaptee.init(proxy); |
| 113 | + } |
| 114 | + } |
178 | 115 |
|
179 | 116 | }
|
0 commit comments