Commits

Anonymous committed 065c2df

XW-502:
let ParametersInterceptor / PrepareInterceptor extend MethodFilterInterceptor

git-svn-id: http://svn.opensymphony.com/svn/xwork/branches/2.0@1397e221344d-f017-0410-9bd5-d282ab1896d7

Comments (0)

Files changed (5)

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

  *
  * </ol>
  *
- * <p/> Note: if the action doesn't implement either interface, this interceptor effectively does nothing. This
+ * <p/>
+ * <b>Note:</b> if the action doesn't implement either interface, this interceptor effectively does nothing. This
  * interceptor is often used with the <b>validation</b> interceptor. However, it does not have to be, especially if you
  * wish to write all your validation rules by hand in the validate() method rather than in XML files.
  *
  * <p/>
  *
- * <b>NOTE:</b> As this method extends off MethodFilterInterceptor, it is capable of
- * deciding if it is applicable only to selective methods in the action class. See
- * <code>MethodFilterInterceptor</code> for more info.
+ * <b>Note:</b> As this method extends off MethodFilterInterceptor, it is capable of
+ * deciding if it is applicable only to selective methods in the action class. This is done by adding param tags
+ * for the interceptor element, naming either a list of excluded method names and/or a list of included method
+ * names, whereby includeMethods overrides excludedMethods. A single * sign is interpreted as wildcard matching
+ * all methods for both parameters.
+ * See {@link MethodFilterInterceptor} for more info.
  * 
  * <p/><b>Update:</b> Added logic to execute a validate{MethodName} and then conditionally
  * followed than a general validate method, depending on the 'alwaysInvokeValidate' 
  *     &lt;result name="success"&gt;good_result.ftl&lt;/result&gt;
  * &lt;/action&gt;
  * 
- * &lt;-- In this case myMethod of the action class will not pass through 
- *        the workflow process --&gt;
+ * &lt;-- In this case myMethod as well as mySecondMethod of the action class
+ *        will not pass through the workflow process --&gt;
  * &lt;action name="someAction" class="com.examples.SomeAction"&gt;
  *     &lt;interceptor-ref name="params"/&gt;
  *     &lt;interceptor-ref name="validation"/&gt;
  *     &lt;interceptor-ref name="workflow"&gt;
- *         &lt;param name="excludeMethods"&gt;myMethod&lt;/param&gt;
+ *         &lt;param name="excludeMethods"&gt;myMethod,mySecondMethod&lt;/param&gt;
  *     &lt;/interceptor-ref name="workflow"&gt;
  *     &lt;result name="success"&gt;good_result.ftl&lt;/result&gt;
  * &lt;/action&gt;
  * 
  * &lt;-- In this case, the result named "error" will be used when 
  *        an action / field error is found --&gt;
+ * &lt;-- The Interceptor will only be applied for myWorkflowMethod method of action
+ *        classes, since this is the only included method while any others are excluded --&gt;
  * &lt;action name="someAction" class="com.examples.SomeAction"&gt;
  *     &lt;interceptor-ref name="params"/&gt;
  *     &lt;interceptor-ref name="validation"/&gt;
  *     &lt;interceptor-ref name="workflow"&gt;
  *        &lt;param name="inputResultName"&gt;error&lt;/param&gt;
+*         &lt;param name="excludeMethods"&gt;*&lt;/param&gt;
+*         &lt;param name="includeMethods"&gt;myWorkflowMethod&lt;/param&gt;
  *     &lt;/interceptor-ref&gt;
  *     &lt;result name="success"&gt;good_result.ftl&lt;/result&gt;
  * &lt;/action&gt;
  * @author <a href='mailto:the_mindstorm[at]evolva[dot]ro'>Alexandru Popescu</a>
  * @author Philip Luppens
  * @author tm_jee
- * 
+ *
  * @version $Date$ $Id$
  */
 public class DefaultWorkflowInterceptor extends MethodFilterInterceptor {

src/java/com/opensymphony/xwork2/interceptor/ParametersInterceptor.java

  * <p/> If you are looking for detailed logging information about your parameters, turn on DEBUG level logging for this
  * interceptor. A detailed log of all the parameter keys and values will be reported.
  *
+ * <p/>
+ * <b>Note:</b> Since XWork 2.0.2, this interceptor extends {@link MethodFilterInterceptor}, therefore being
+ * able to deal with excludeMethods / includeMethods parameters. See [Workflow Interceptor]
+ * (class {@link DefaultWorkflowInterceptor}) for documentation and examples on how to use this feature.
+ *
  * <!-- END SNIPPET: description -->
  *
  * <p/> <u>Interceptor parameters:</u>
  * </pre>
  *
  * @author Patrick Lightbody
+ * @author Rene Gielen
  */
-public class ParametersInterceptor extends AbstractInterceptor {
+public class ParametersInterceptor extends MethodFilterInterceptor {
 
     private static final Log LOG = LogFactory.getLog(ParametersInterceptor.class);
 
         };
     };
     
-    public String intercept(ActionInvocation invocation) throws Exception {
+    public String doIntercept(ActionInvocation invocation) throws Exception {
         Object action = invocation.getAction();
         if (!(action instanceof NoParameters)) {
             ActionContext ac = invocation.getInvocationContext();

src/java/com/opensymphony/xwork2/interceptor/PrepareInterceptor.java

  * the id property, and then when the second params interceptor is called the
  * parameter <i>user.name</i> will be set, as desired, on the actual object
  * loaded from the database. See the example for more info.
- * 
+ *
+ * <p/>
+ * <b>Note:</b> Since XWork 2.0.2, this interceptor extends {@link MethodFilterInterceptor}, therefore being
+ * able to deal with excludeMethods / includeMethods parameters. See [Workflow Interceptor]
+ * (class {@link DefaultWorkflowInterceptor}) for documentation and examples on how to use this feature.
+ *
  * <p/><b>Update</b>: Added logic to execute a prepare{MethodName} and conditionally
  * the a general prepare() Method, depending on the 'alwaysInvokePrepare' parameter/property
  * which is by default true. This allows us to run some logic based on the method 
  * @author Jason Carreira
  * @author Philip Luppens
  * @author tm_jee
+ * @author Rene Gielen
  * @see com.opensymphony.xwork2.Preparable
  */
-public class PrepareInterceptor extends AbstractInterceptor {
+public class PrepareInterceptor extends MethodFilterInterceptor {
 	
 	private static final long serialVersionUID = -5216969014510719786L;
 
 		this.alwaysInvokePrepare = Boolean.parseBoolean(alwaysInvokePrepare);
 	}
 	
-    public String intercept(ActionInvocation invocation) throws Exception {
+    public String doIntercept(ActionInvocation invocation) throws Exception {
         Object action = invocation.getAction();
 
         if (action instanceof Preparable) {

src/test/com/opensymphony/xwork2/interceptor/ParametersInterceptorTest.java

         Action action = new NoParametersAction();
         mai.setAction(action);
 
-        interceptor.intercept(mai);
+        interceptor.doIntercept(mai);
         interceptor.destroy();
     }
     

src/test/com/opensymphony/xwork2/interceptor/PrepareInterceptorTest.java

         MockActionInvocation mai = new MockActionInvocation();
         mai.setAction(new SimpleFooAction());
 
-        interceptor.intercept(mai);
+        interceptor.doIntercept(mai);
     }
     
     public void testPrefixInvocation1() throws Exception {