Home Page - Codebydev.com - For the devs by the devs - Demo
Ajax loader

Components in Architecture

Following are the various components available in struts 2 architecture.

1. FilterDispatcher

2. Interceptors.

3. Actions.

4. ActionContext.

5. ValueStack.

6. OGNL (Object Graph Navigation Language).

7. Results

         8. ActionInvocation.

       Following are the various components of struts 2 framework and their                 corresponding roles.


1. FilterDispatcher


The role of the controller is played by FilterDispatcher.


It creates an object of ActionInvocation which encapsulates the execution process of an action with its associated interceptors and results. It then delegates the request processing to ActionInvocation.


2. Interceptors.


Struts 2 uses interceptors to both separate and reuse crosscutting concerns from the core request processing.


There is a stack of interceptors in front of the action.


The invocation of the action must travel through this stack.


These interceptors are invoked both before and after the action.


3. Actions.


Action class contains both data and business logic and is always placed inside the ValueStack.


Action will always do three things.


1) It contains the logic to be executed for a particular request.


2) It stores and carries the data so that we can access the data from the request till the view.


3) It decides the view for a particular request.


The Action serves as a centralized data transfer object that can be used to make the application data available in all tiers of the framework.


The use of Actions as data transfer objects should probably ring some alarms in the minds of alert


Struts 1 developers. In Struts 1, the action classes were singletons i.e. there is only one instance of the Action class.


In a multi-threaded environment, such as a web application, it would be very problematic to store data as instance fields in the Action class.


But struts 2 solves this problem by creating a new instance of an action for each request that maps to it. This allows Struts 2 objects to exist as dedicated data transfer objects for each request.


Even if we are concerned about the performance issue because a new action object is created for every request, just consider the fact that even with a singleton action object we still would have to create some sort of data transfer object for the request. So, object instantiation is certainly not higher in Struts 2.


4. ActionContext.

The ActionContext holds all the important data objects related to a given action invocation and OGNL can target any of them.



Please share this page:

Related topics :

    For more details contact - info.codebydev@gmail.com

    © 2021 - codebydev.com