Skip to content

Commit c91e032

Browse files
committed
WW-3714 Deprecate and migrate assorted Interceptors
1 parent a874416 commit c91e032

26 files changed

+2332
-45
lines changed

core/src/main/java/com/opensymphony/xwork2/conversion/impl/XWorkConverter.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,21 @@
1818
*/
1919
package com.opensymphony.xwork2.conversion.impl;
2020

21-
import com.opensymphony.xwork2.*;
22-
import com.opensymphony.xwork2.conversion.*;
21+
import com.opensymphony.xwork2.ActionContext;
22+
import com.opensymphony.xwork2.FileManager;
23+
import com.opensymphony.xwork2.FileManagerFactory;
24+
import com.opensymphony.xwork2.LocalizedTextProvider;
25+
import com.opensymphony.xwork2.conversion.ConversionAnnotationProcessor;
26+
import com.opensymphony.xwork2.conversion.ConversionFileProcessor;
27+
import com.opensymphony.xwork2.conversion.TypeConverter;
28+
import com.opensymphony.xwork2.conversion.TypeConverterHolder;
2329
import com.opensymphony.xwork2.conversion.annotations.Conversion;
2430
import com.opensymphony.xwork2.conversion.annotations.TypeConversion;
2531
import com.opensymphony.xwork2.inject.Inject;
26-
import com.opensymphony.xwork2.util.*;
32+
import com.opensymphony.xwork2.util.AnnotationUtils;
33+
import com.opensymphony.xwork2.util.ClassLoaderUtil;
34+
import com.opensymphony.xwork2.util.CompoundRoot;
35+
import com.opensymphony.xwork2.util.ValueStack;
2736
import com.opensymphony.xwork2.util.reflection.ReflectionContextState;
2837
import org.apache.commons.lang3.StringUtils;
2938
import org.apache.logging.log4j.LogManager;
@@ -220,6 +229,10 @@ public static String getConversionErrorMessage(String propertyName, Class toClas
220229
return message;
221230
}
222231

232+
public static String getConversionErrorMessage(String propertyName, Class toClass, org.apache.struts2.util.ValueStack stack) {
233+
return getConversionErrorMessage(propertyName, toClass, ValueStack.adapt(stack));
234+
}
235+
223236
private static String removeAllIndexesInPropertyName(String propertyName) {
224237
return propertyName.replaceAll(MESSAGE_INDEX_PATTERN, PERIOD);
225238
}

core/src/main/java/com/opensymphony/xwork2/interceptor/AliasInterceptor.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,10 @@
9191
* </pre>
9292
*
9393
* @author Matthew Payne
94+
*
95+
* @deprecated since 6.7.0, use {@link org.apache.struts2.interceptor.AliasInterceptor} instead.
9496
*/
97+
@Deprecated
9598
public class AliasInterceptor extends AbstractInterceptor {
9699

97100
private static final Logger LOG = LogManager.getLogger(AliasInterceptor.class);

core/src/main/java/com/opensymphony/xwork2/interceptor/ChainingInterceptor.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,10 @@
118118
* @author mrdon
119119
* @author tm_jee ( tm_jee(at)yahoo.co.uk )
120120
* @see com.opensymphony.xwork2.ActionChainResult
121+
*
122+
* @deprecated since 6.7.0, use {@link org.apache.struts2.interceptor.ChainingInterceptor} instead.
121123
*/
124+
@Deprecated
122125
public class ChainingInterceptor extends AbstractInterceptor {
123126

124127
private static final Logger LOG = LogManager.getLogger(ChainingInterceptor.class);

core/src/main/java/com/opensymphony/xwork2/interceptor/ConversionErrorInterceptor.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@
4242
* display the original string ("abc") again rather than the int value (likely 0, which would make very little sense to
4343
* the user).
4444
* </p>
45-
*
45+
*
4646
* <p>
4747
* <b>Note:</b> Since 2.5.2, this interceptor extends {@link MethodFilterInterceptor}, therefore being
4848
* able to deal with excludeMethods / includeMethods parameters. See [Workflow Interceptor]
4949
* (class {@link DefaultWorkflowInterceptor}) for documentation and examples on how to use this feature.
5050
* </p>
51-
*
51+
*
5252
* <!-- END SNIPPET: description -->
5353
*
5454
* <p><u>Interceptor parameters:</u></p>
@@ -85,7 +85,10 @@
8585
* </pre>
8686
*
8787
* @author Jason Carreira
88+
*
89+
* @deprecated since 6.7.0, use {@link org.apache.struts2.interceptor.ConversionErrorInterceptor} instead.
8890
*/
91+
@Deprecated
8992
public class ConversionErrorInterceptor extends MethodFilterInterceptor {
9093

9194
public static final String ORIGINAL_PROPERTY_OVERRIDE = "original.property.override";

core/src/main/java/com/opensymphony/xwork2/interceptor/DefaultWorkflowInterceptor.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
/**
3333
* <!-- START SNIPPET: description -->
3434
* <p>
35-
* An interceptor that makes sure there are not validation, conversion or action errors before allowing the interceptor chain to continue.
35+
* An interceptor that makes sure there are not validation, conversion or action errors before allowing the interceptor chain to continue.
3636
* If a single FieldError or ActionError (including the ones replicated by the Message Store Interceptor in a redirection) is found, the INPUT result will be triggered.
3737
* <b>This interceptor does not perform any validation</b>.
3838
* </p>
@@ -132,7 +132,10 @@
132132
* @author <a href='mailto:the_mindstorm[at]evolva[dot]ro'>Alexandru Popescu</a>
133133
* @author Philip Luppens
134134
* @author tm_jee
135+
*
136+
* @deprecated since 6.7.0, use {@link org.apache.struts2.interceptor.DefaultWorkflowInterceptor} instead.
135137
*/
138+
@Deprecated
136139
public class DefaultWorkflowInterceptor extends MethodFilterInterceptor {
137140

138141
private static final long serialVersionUID = 7563014655616490865L;

core/src/main/java/com/opensymphony/xwork2/interceptor/ExceptionMappingInterceptor.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020

2121
import com.opensymphony.xwork2.ActionInvocation;
2222
import com.opensymphony.xwork2.config.entities.ExceptionMappingConfig;
23-
import org.apache.logging.log4j.Logger;
2423
import org.apache.logging.log4j.LogManager;
24+
import org.apache.logging.log4j.Logger;
2525
import org.apache.struts2.dispatcher.HttpParameters;
2626

2727
import java.util.List;
@@ -153,7 +153,10 @@
153153
*
154154
* @author Matthew E. Porter (matthew dot porter at metissian dot com)
155155
* @author Claus Ibsen
156+
*
157+
* @deprecated since 6.7.0, use {@link org.apache.struts2.interceptor.ExceptionMappingInterceptor} instead.
156158
*/
159+
@Deprecated
157160
public class ExceptionMappingInterceptor extends AbstractInterceptor {
158161

159162
private static final Logger LOG = LogManager.getLogger(ExceptionMappingInterceptor.class);

core/src/main/java/com/opensymphony/xwork2/interceptor/LoggingInterceptor.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@
5959
* </pre>
6060
*
6161
* @author Jason Carreira
62+
*
63+
* @deprecated since 6.7.0, use {@link org.apache.struts2.interceptor.LoggingInterceptor} instead.
6264
*/
65+
@Deprecated
6366
public class LoggingInterceptor extends AbstractInterceptor {
6467
private static final Logger LOG = LogManager.getLogger(LoggingInterceptor.class);
6568
private static final String FINISH_MESSAGE = "Finishing execution stack for action ";

core/src/main/java/com/opensymphony/xwork2/interceptor/ModelDrivenInterceptor.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,13 @@
7171
* &lt;/action&gt;
7272
* <!-- END SNIPPET: example -->
7373
* </pre>
74-
*
74+
*
7575
* @author tm_jee
7676
* @version $Date$ $Id$
77+
*
78+
* @deprecated since 6.7.0, use {@link org.apache.struts2.interceptor.ModelDrivenInterceptor} instead.
7779
*/
80+
@Deprecated
7881
public class ModelDrivenInterceptor extends AbstractInterceptor {
7982

8083
protected boolean refreshModelBeforeResult = false;

core/src/main/java/com/opensymphony/xwork2/interceptor/ParameterRemoverInterceptor.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,10 @@
6666
* ...
6767
* &lt;/action&gt;
6868
* </pre>
69+
*
70+
* @deprecated since 6.7.0, use {@link org.apache.struts2.interceptor.ParameterRemoverInterceptor} instead.
6971
*/
72+
@Deprecated
7073
public class ParameterRemoverInterceptor extends AbstractInterceptor {
7174

7275
private static final Logger LOG = LogManager.getLogger(ParameterRemoverInterceptor.class);

core/src/main/java/com/opensymphony/xwork2/interceptor/PrefixMethodInvocationUtil.java

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@
1919
package com.opensymphony.xwork2.interceptor;
2020

2121
import com.opensymphony.xwork2.ActionInvocation;
22-
import org.apache.logging.log4j.Logger;
2322
import org.apache.logging.log4j.LogManager;
23+
import org.apache.logging.log4j.Logger;
2424

2525
import java.lang.reflect.InvocationTargetException;
2626
import java.lang.reflect.Method;
2727

2828
/**
2929
* <p>
3030
* A utility class for invoking prefixed methods in action class.
31-
*
31+
*
3232
* Interceptors that made use of this class are:
3333
* </p>
3434
* <ul>
@@ -37,35 +37,35 @@
3737
* </ul>
3838
* *
3939
* <!-- START SNIPPET: javadocDefaultWorkflowInterceptor -->
40-
*
40+
*
4141
* <b>In DefaultWorkflowInterceptor</b>
4242
* <p>applies only when action implements {@link com.opensymphony.xwork2.Validateable}</p>
4343
* <ol>
4444
* <li>if the action class have validate{MethodName}(), it will be invoked</li>
4545
* <li>else if the action class have validateDo{MethodName}(), it will be invoked</li>
4646
* <li>no matter if 1] or 2] is performed, if alwaysInvokeValidate property of the interceptor is "true" (which is by default "true"), validate() will be invoked.</li>
4747
* </ol>
48-
*
48+
*
4949
* <!-- END SNIPPET: javadocDefaultWorkflowInterceptor -->
50-
*
51-
*
50+
*
51+
*
5252
* <!-- START SNIPPET: javadocPrepareInterceptor -->
53-
*
53+
*
5454
* <b>In PrepareInterceptor</b>
5555
* <p>Applies only when action implements Preparable</p>
5656
* <ol>
5757
* <li>if the action class have prepare{MethodName}(), it will be invoked</li>
5858
* <li>else if the action class have prepareDo(MethodName()}(), it will be invoked</li>
5959
* <li>no matter if 1] or 2] is performed, if alwaysinvokePrepare property of the interceptor is "true" (which is by default "true"), prepare() will be invoked.</li>
6060
* </ol>
61-
*
61+
*
6262
* <!-- END SNIPPET: javadocPrepareInterceptor -->
63-
*
63+
*
6464
* @author Philip Luppens
6565
* @author tm_jee
6666
*/
6767
public class PrefixMethodInvocationUtil {
68-
68+
6969
private static final Logger LOG = LogManager.getLogger(PrefixMethodInvocationUtil.class);
7070

7171
private static final String DEFAULT_INVOCATION_METHODNAME = "execute";
@@ -76,7 +76,7 @@ public class PrefixMethodInvocationUtil {
7676
* <p>
7777
* This method will prefix <code>actionInvocation</code>'s <code>ActionProxy</code>'s
7878
* <code>method</code> with <code>prefixes</code> before invoking the prefixed method.
79-
* Order of the <code>prefixes</code> is important, as this method will return once
79+
* Order of the <code>prefixes</code> is important, as this method will return once
8080
* a prefixed method is found in the action class.
8181
* </p>
8282
*
@@ -89,7 +89,7 @@ public class PrefixMethodInvocationUtil {
8989
* </pre>
9090
*
9191
* <p>
92-
* Assuming <code>actionInvocation.getProxy(),getMethod()</code> returns "submit",
92+
* Assuming <code>actionInvocation.getProxy(),getMethod()</code> returns "submit",
9393
* the order of invocation would be as follows:-
9494
* </p>
9595
*
@@ -99,12 +99,12 @@ public class PrefixMethodInvocationUtil {
9999
* </ol>
100100
*
101101
* <p>
102-
* If <code>prepareSubmit()</code> exists, it will be invoked and this method
103-
* will return, <code>prepareDoSubmit()</code> will NOT be invoked.
102+
* If <code>prepareSubmit()</code> exists, it will be invoked and this method
103+
* will return, <code>prepareDoSubmit()</code> will NOT be invoked.
104104
* </p>
105105
*
106106
* <p>
107-
* On the other hand, if <code>prepareDoSubmit()</code> does not exists, and
107+
* On the other hand, if <code>prepareDoSubmit()</code> does not exists, and
108108
* <code>prepareDoSubmit()</code> exists, it will be invoked.
109109
* </p>
110110
*
@@ -119,29 +119,32 @@ public class PrefixMethodInvocationUtil {
119119
*/
120120
public static void invokePrefixMethod(ActionInvocation actionInvocation, String[] prefixes) throws InvocationTargetException, IllegalAccessException {
121121
Object action = actionInvocation.getAction();
122-
122+
123123
String methodName = actionInvocation.getProxy().getMethod();
124-
124+
125125
if (methodName == null) {
126-
// if null returns (possible according to the docs), use the default execute
126+
// if null returns (possible according to the docs), use the default execute
127127
methodName = DEFAULT_INVOCATION_METHODNAME;
128128
}
129-
129+
130130
Method method = getPrefixedMethod(prefixes, methodName, action);
131131
if (method != null) {
132132
method.invoke(action, new Object[0]);
133133
}
134134
}
135-
136-
135+
136+
public static void invokePrefixMethod(org.apache.struts2.ActionInvocation actionInvocation, String[] prefixes) throws InvocationTargetException, IllegalAccessException {
137+
invokePrefixMethod(ActionInvocation.adapt(actionInvocation), prefixes);
138+
}
139+
137140
/**
138-
* This method returns a {@link Method} in <code>action</code>. The method
141+
* This method returns a {@link Method} in <code>action</code>. The method
139142
* returned is found by searching for method in <code>action</code> whose method name
140143
* is equals to the result of appending each <code>prefixes</code>
141144
* to <code>methodName</code>. Only the first method found will be returned, hence
142145
* the order of <code>prefixes</code> is important. If none is found this method
143146
* will return null.
144-
*
147+
*
145148
* @param prefixes the prefixes to prefix the <code>methodName</code>
146149
* @param methodName the method name to be prefixed with <code>prefixes</code>
147150
* @param action the action class of which the prefixed method is to be search for.
@@ -162,7 +165,7 @@ public static Method getPrefixedMethod(String[] prefixes, String methodName, Obj
162165
}
163166
return null;
164167
}
165-
168+
166169
/**
167170
* <p>
168171
* This method capitalized the first character of <code>methodName</code>.

0 commit comments

Comments
 (0)