Commits

Anonymous committed f6dd49a

Update AnnotationWorkflowInterceptor documentation and add interceptor reference
in struts-default.xml

Issue Number: XW-526

git-svn-id: http://svn.opensymphony.com/svn/xwork/trunk@1639e221344d-f017-0410-9bd5-d282ab1896d7

  • Participants
  • Parent commits fe85c4f

Comments (0)

Files changed (3)

docs/wikidocs/AnnotationWorkflowInterceptor.html

 	    <table class="pagecontent" border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="#ffffff">
 		    <tr>
 			    <td valign="top" class="pagebody">
-				    <h1><a name="AnnotationWorkflowInterceptor-AnnotationWorkflowInterceptorInterceptor"></a>AnnotationWorkflowInterceptor Interceptor</h1>
-
-<p><p>Invokes any annotated methods on the action. Specifically, it supports the following
-annotations:
-<ul>
-<li> &#64;Before - will be invoked before the action method. If the returned value is not null, it is
-returned as the action result code</li>
-<li> &#64;BeforeResult - will be invoked after the action method but before the result execution</li>
-<li> &#64;After - will be invoked after the action method and result execution</li>
-</ul>
-</p>
-<p/>
-<p>There can be multiple methods marked with the same annotations, but the order of their execution
-is not guaranteed. However, the annotated methods on the superclass chain are guaranteed to be invoked before the
-annotated method in the current class in the case of a Before annotations and after, if the annotations is
-After.</p></p>
-
-<h2><a name="AnnotationWorkflowInterceptor-Examples"></a>Examples</h2>
-
-<div class="code"><div class="codeContent">
-<pre class="code-java"><span class="code-keyword">public</span> class BaseAnnotatedAction {
- 	<span class="code-keyword">protected</span> <span class="code-object">String</span> log = "";
-
- 	@Before
- 	<span class="code-keyword">public</span> <span class="code-object">String</span> baseBefore() {
- 		log = log + <span class="code-quote">"baseBefore-"</span>;
- 		<span class="code-keyword">return</span> <span class="code-keyword">null</span>;
- 	}
- }
-
- <span class="code-keyword">public</span> class AnnotatedAction <span class="code-keyword">extends</span> BaseAnnotatedAction {
- 	@Before
- 	<span class="code-keyword">public</span> <span class="code-object">String</span> before() {
- 		log = log + <span class="code-quote">"before"</span>;
- 		<span class="code-keyword">return</span> <span class="code-keyword">null</span>;
- 	}
-
- 	<span class="code-keyword">public</span> <span class="code-object">String</span> execute() {
- 		log = log + <span class="code-quote">"-execute"</span>;
- 		<span class="code-keyword">return</span> Action.SUCCESS;
- 	}
-
- 	@BeforeResult
- 	<span class="code-keyword">public</span> void beforeResult() <span class="code-keyword">throws</span> Exception {
- 		log = log +<span class="code-quote">"-beforeResult"</span>;
- 	}
-
- 	@After
- 	<span class="code-keyword">public</span> void after() {
- 		log = log + <span class="code-quote">"-after"</span>;
- 	}
- }</pre>
-</div></div>
-<p>Configure a stack in xwork.xml that replaces the PrepareInterceptor with the AnnotationWorkflowInterceptor:</p>
-<div class="code"><div class="codeContent">
-<pre class="code-xml"><span class="code-tag">&lt;interceptor-stack name=<span class="code-quote">"annotatedStack"</span>&gt;</span>
-<span class="code-tag">&lt;interceptor-ref name=<span class="code-quote">"static-params"</span>/&gt;</span>
-<span class="code-tag">&lt;interceptor-ref name=<span class="code-quote">"params"</span>/&gt;</span>
-<span class="code-tag">&lt;interceptor-ref name=<span class="code-quote">"conversionError"</span>/&gt;</span>
-<span class="code-tag">&lt;interceptor-ref name=<span class="code-quote">"annotationInterceptor"</span>/&gt;</span>
-<span class="code-tag">&lt;/interceptor-stack&gt;</span></pre>
-</div></div>
-<p>Given an Action, AnnotatedAction, add a reference to the AnnotationWorkflowInterceptor interceptor.</p>
-<div class="code"><div class="codeContent">
+				    <h1><a name="AnnotationWorkflowInterceptor-AnnotationWorkflowInterceptorInterceptor"></a>AnnotationWorkflowInterceptor Interceptor</h1>
+
+<p><p>Invokes any annotated methods on the action. Specifically, it supports the following
+annotations:
+<ul>
+<li> &#64;Before - will be invoked before the action method. If the returned value is not null, it is
+returned as the action result code</li>
+<li> &#64;BeforeResult - will be invoked after the action method but before the result execution</li>
+<li> &#64;After - will be invoked after the action method and result execution</li>
+</ul>
+</p>
+<p/>
+<p>There can be multiple methods marked with the same annotations, but the order of their execution
+is not guaranteed. However, the annotated methods on the superclass chain are guaranteed to be invoked before the
+annotated method in the current class in the case of a Before annotations and after, if the annotations is
+After.</p></p>
+
+<h2><a name="AnnotationWorkflowInterceptor-Examples"></a>Examples</h2>
+
+<div class="code"><div class="codeContent">
+<pre class="code-java"><span class="code-keyword">public</span> class BaseAnnotatedAction {
+ 	<span class="code-keyword">protected</span> <span class="code-object">String</span> log = "";
+
+ 	@Before
+ 	<span class="code-keyword">public</span> <span class="code-object">String</span> baseBefore() {
+ 		log = log + <span class="code-quote">"baseBefore-"</span>;
+ 		<span class="code-keyword">return</span> <span class="code-keyword">null</span>;
+ 	}
+ }
+
+ <span class="code-keyword">public</span> class AnnotatedAction <span class="code-keyword">extends</span> BaseAnnotatedAction {
+ 	@Before
+ 	<span class="code-keyword">public</span> <span class="code-object">String</span> before() {
+ 		log = log + <span class="code-quote">"before"</span>;
+ 		<span class="code-keyword">return</span> <span class="code-keyword">null</span>;
+ 	}
+
+ 	<span class="code-keyword">public</span> <span class="code-object">String</span> execute() {
+ 		log = log + <span class="code-quote">"-execute"</span>;
+ 		<span class="code-keyword">return</span> Action.SUCCESS;
+ 	}
+
+ 	@BeforeResult
+ 	<span class="code-keyword">public</span> void beforeResult() <span class="code-keyword">throws</span> Exception {
+ 		log = log +<span class="code-quote">"-beforeResult"</span>;
+ 	}
+
+ 	@After
+ 	<span class="code-keyword">public</span> void after() {
+ 		log = log + <span class="code-quote">"-after"</span>;
+ 	}
+ }</pre>
+</div></div>
+<p>Configure a stack in xwork.xml that replaces the PrepareInterceptor with the AnnotationWorkflowInterceptor:</p>
+<div class="code"><div class="codeContent">
+<pre class="code-xml"><span class="code-tag">&lt;interceptor-stack name=<span class="code-quote">"annotatedStack"</span>&gt;</span>
+<span class="code-tag">&lt;interceptor-ref name=<span class="code-quote">"static-params"</span>/&gt;</span>
+<span class="code-tag">&lt;interceptor-ref name=<span class="code-quote">"params"</span>/&gt;</span>
+<span class="code-tag">&lt;interceptor-ref name=<span class="code-quote">"conversionError"</span>/&gt;</span>
+<span class="code-tag">&lt;interceptor-ref name=<span class="code-quote">"annotationWorkflow"</span>/&gt;</span>
+<span class="code-tag">&lt;/interceptor-stack&gt;</span></pre>
+</div></div>
+<p>Given an Action, AnnotatedAction, add a reference to the AnnotationWorkflowInterceptor interceptor.</p>
+<div class="code"><div class="codeContent">
 <pre class="code-xml"><span class="code-tag">&lt;action name=<span class="code-quote">"AnnotatedAction"</span> class=<span class="code-quote">"com.examples.AnnotatedAction"</span>&gt;</span>
-   <span class="code-tag">&lt;interceptor-ref name=<span class="code-quote">"annotationInterceptor"</span>/&gt;</span>
+   <span class="code-tag">&lt;interceptor-ref name=<span class="code-quote">"annotationWorkflow"</span>/&gt;</span>
    <span class="code-tag">&lt;result name=<span class="code-quote">"success"</span> type=<span class="code-quote">"freemarker"</span>&gt;</span>good_result.ftl<span class="code-tag">&lt;/result&gt;</span>
-<span class="code-tag">&lt;/action&gt;</span></pre>
-</div></div>
-<p><p>With the interceptor applied and the action executed on <code>AnnotatedAction</code> the log
+<span class="code-tag">&lt;/action&gt;</span></pre>
+</div></div>
+<p><p>With the interceptor applied and the action executed on <code>AnnotatedAction</code> the log
 instance variable will contain <code>baseBefore-before-execute-beforeResult-after</code>.</p></p>
 
                     			    </td>

src/java/com/opensymphony/xwork2/interceptor/annotations/AnnotationWorkflowInterceptor.java

  * 	&lt;interceptor-ref name="static-params"/&gt;
  * 	&lt;interceptor-ref name="params"/&gt;
  * 	&lt;interceptor-ref name="conversionError"/&gt;
- * 	&lt;interceptor-ref name="annotationInterceptor"/&gt;
+ * 	&lt;interceptor-ref name="annotationWorkflow"/&gt;
  * &lt;/interceptor-stack&gt;
  *  <!-- END SNIPPET: stack -->
  * </pre>

src/test/com/opensymphony/xwork2/interceptor/annotations/AnnotationWorkflowInterceptorTest.java

 package com.opensymphony.xwork2.interceptor.annotations;
 
 import java.util.Arrays;
-import java.util.Properties;
-
-import junit.framework.TestCase;
 
 import com.opensymphony.xwork2.*;
 import com.opensymphony.xwork2.mock.MockResult;
-import com.opensymphony.xwork2.util.ValueStack;
-import com.opensymphony.xwork2.util.ValueStackFactory;
 import com.opensymphony.xwork2.util.location.LocatableProperties;
 import com.opensymphony.xwork2.inject.ContainerBuilder;
 import com.opensymphony.xwork2.config.Configuration;
 import com.opensymphony.xwork2.config.ConfigurationException;
-import com.opensymphony.xwork2.config.ConfigurationManager;
 import com.opensymphony.xwork2.config.ConfigurationProvider;
 import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider;
 import com.opensymphony.xwork2.config.entities.ActionConfig;
 public class AnnotationWorkflowInterceptorTest extends XWorkTestCase {
     private static final String ANNOTATED_ACTION = "annotatedAction";
     private static final String SHORTCIRCUITED_ACTION = "shortCircuitedAction";
-    private final AnnotationWorkflowInterceptor annotationInterceptor = new AnnotationWorkflowInterceptor();
+    private final AnnotationWorkflowInterceptor annotationWorkflow = new AnnotationWorkflowInterceptor();
 
     public void setUp() {
         loadConfigurationProviders(new XmlConfigurationProvider("xwork-default.xml"), new MockConfigurationProvider());
             config.addPackageConfig("default", packageConfig);
 
             ActionConfig actionConfig = new ActionConfig(null, AnnotatedAction.class, null, null,
-                    Arrays.asList(new InterceptorMapping[]{ new InterceptorMapping("annotationInterceptor", annotationInterceptor) }));
+                    Arrays.asList(new InterceptorMapping[]{ new InterceptorMapping("annotationWorkflow", annotationWorkflow) }));
             packageConfig.addActionConfig(ANNOTATED_ACTION, actionConfig);
             actionConfig.addResultConfig(new ResultConfig("success", MockResult.class.getName()));
             actionConfig = new ActionConfig(null, ShortcircuitedAction.class, null, null,
-                    Arrays.asList(new InterceptorMapping[]{ new InterceptorMapping("annotationInterceptor", annotationInterceptor) }));
+                    Arrays.asList(new InterceptorMapping[]{ new InterceptorMapping("annotationWorkflow", annotationWorkflow) }));
             packageConfig.addActionConfig(SHORTCIRCUITED_ACTION, actionConfig);
             actionConfig.addResultConfig(new ResultConfig("shortcircuit", MockResult.class.getName()));
             config.addPackageConfig("defaultPackage", packageConfig);