Struts 2 components
Action Handler, Result Handler, Custom Tags
Interceptor : bring custom code into call stack
- Timer Interceptor
- Prepare (able) – If the Action implements Preparable, calls its prepare method.
value stack : stack of objects that expression language can pull from
- Action instance pushed onto stack
Request Lifecycle in Struts 2 applications
- User Sends request: User sends a request to the server for some resource.
- FilterDispatcher determines the appropriate action: The FilterDispatcher looks at the request and then determines the appropriate Action.
- Interceptors are applied: Interceptors configured for applying the common functionalities such as workflow, validation, file upload etc. are automatically applied to the request.
- Execution of Action: Then the action method is executed to perform the database related operations like storing or retrieving the data from database.
- Output rendering: Then the Result render the output.
- Return of Request: Then the request returns through the interceptors in the reverse order. The returning request allows us to perform the clean-up or additional processing.
Display the result to user: Finally the control is returned to the servlet container, which sends the output to the user browser.
Struts 2 Big Picture
The diagram depicts the architecture of Struts 2 Framework. It shows the the initial request goes to the Servlet container, which is then passed through a standard filer chain.
- ActionContextCleanUp filter: The ActionContextCleanUp filter is optional. It is useful when integrating other technologies such as SiteMesh Plugin.
- FilterDispatcher: the required FilterDispatcher is called, which in turn consults the ActionMapper to determine if the request should invoke an action. If the ActionMapper determines that an Action should be invoked, the FilterDispatcher delegates control to the ActionProxy.
- ActionProxy: The ActionProxy consults the Configuration Files manager, which is initialized via the struts.xml file. Then the ActionProxy creates an ActionInvocation, which implements the command pattern. The ActionInvocation process invokes the Interceptors (if configured) and then invokes the action.
- Once the Action returns, the ActionInvocation is responsible for looking up the proper result associated with the Action result code mapped in struts.xml. The result is then executed, which often (but not always, as is the case for Action Chaining) involves a template written in JSP or FreeMarker to be rendered. While rendering, the templates can use the Struts Tags provided by the framework. Some of those components will work with the ActionMapper to render proper URLs for additional requests.
- Then the Interceptors are executed again in reverse order. Finally the response returns through the filters configured in web.xml file.
- If the ActionContextCleanUp filter is configured, the FilterDispatcher does not clean the ThreadLocal ActionContext. If the ActionContextCleanUp filter is not present then the FilterDispatcher will cleanup all the ThreadLocals present.
Th version I have of the application mentions: “For more about the MailReader, including alternate implementations and a set of formal Use Cases, please visit the Struts University MailReader site” .
- MailReader Database Worksheet (Struts University)
- MailReader Object Model (Struts University)
- MailReader Tour (Struts University)
- MailReader Use Cases (Struts University)