Thursday 14 February 2013

MVC2 architecture of Struts2

Java struts2.0 consist with MVC2 architecture


Model-
             In Model there is mapping of Pojo classes.
             Model represents enterprise information.
             Model is implemented by Action Component. 

View-
            In View there is mapping of Action classes.
            View represents application’s presentation.
            View in struts2
                 1)HTML/JSP
                 2)swing

Controller-
             In Controller there is mapping of Manager classes.
             Interaction between Model and View is controlled by Controller
.

                                               Fig.MVC2 Architecture for Struts2


The MVC architecture has the following benefits:

  • Multiple views using the same model: The separation of model and view allows multiple views to use the same enterprise model. Consequently, an enterprise application's model components are easier to implement, test, and maintain, since all access to the model goes through these components.
  • Easier support for new types of clients: To support a new type of client, you simply write a view and controller for it and wire them into the existing enterprise model. 
  • Clarity of design: By glancing at the model's public method list, it should be easy to understand how to control the model's behavior. When designing the application, this trait makes the entire program easier to implement and maintain.
  • Efficient modularity: of the design allows any of the components to be swapped in and out as the user or programmer desires - even the model! Changes to one aspect of the program aren't coupled to other aspects, eliminating many nasty debugging situations. Also, development of the various components can progress in parallel, once the interface between the components is clearly defined.
  • Ease of growth: Controllers and views can grow as the model grows; and older versions of the views and controllers can still be used as long as a common interface is maintained.
  • Distributable: With a couple of proxies one can easily distribute any MVC application by only altering the startup method of the application.
     

    Request life cycle:

    Based on the above diagram, one can explain the user's request life cycle in Struts 2 as follows:
    1. User sends a request to the server for requesting for some resource (i.e pages).
    2. The Filter Dispatcher looks at the request and then determines the appropriate Action.
    3. Configured interceptors functionality applies such as validation, file upload etc.
    4. Selected action is executed to perform the requested operation.
    5. Again, configured interceptors are applied to do any post-processing if required.


     

    9 comments :

    1. what is mean by collection? and which are the the interfaces used in collection?

      ReplyDelete
    2. Collection's works a bit like arrays, except their size can change dynamically, and they have more advanced behavior than arrays.
      there are Six types of interfaces used in Collection
      1)Collection
      2)Set
      3)List
      4)Queue
      5)Deque
      6)Map

      ReplyDelete
    3. will you please tell me about the connection between model view controller and struts and how the flow goes through..

      ReplyDelete
    4. Client browser create an HTTP request->Controller receive the request and make decision to send request->In Model, there is action class with Struts, it have actual business logic and send to JSP file->In View, there are JSP files to represents the Static or Dynamic information.

      ReplyDelete
    5. What is Mean By Pojo Classes.?

      ReplyDelete
    6. POJO classes are ordinary Java object which do not implement any interface or extends any other Java class.

      ReplyDelete

      Categories

      Text Widget

      Followers