Click here to load reader

SOEN 6011 Software Engineering Processes

  • View
    48

  • Download
    1

Embed Size (px)

DESCRIPTION

SOEN 6011 Software Engineering Processes. Section SS Fall 2007 Dr Greg Butler http://www.cs.concordia.ca/~gregb/home/soen6011-f2007.html. Week 6. Servlets and JSP Larman Controller Principle Fowler Front Controller GoF Command pattern Java reflection to instantiate Command. - PowerPoint PPT Presentation

Text of SOEN 6011 Software Engineering Processes

  • SOEN 6011Software Engineering ProcessesSection SS Fall 2007Dr Greg Butlerhttp://www.cs.concordia.ca/~gregb/home/soen6011-f2007.html

  • Week 6Servlets and JSPLarman Controller PrincipleFowler Front ControllerGoF Command patternJava reflection to instantiate Command

  • Servlets, The General IdeaApplet as a client side Java application.Servlet as a server side technology for implementing part of the functionality of an application.

    HTTP (URL) requests cause a servlet to be:Instantiated (if it did not exist).Run.The servlet builds a response which is then sent back to the client (usually in the form of HTML).

  • Servlet: HelloWebpublic class HelloWebServlet extends HttpServlet {protected void doGet(HttpServletRequest request,HttpServletResponse response)throws ServletException, IOException {ServletOutputStream out = response.getOutputStream();out.println("Hello Web!");}}

  • Java Server PageServlet:Embed HTML inside code.

    JSPEmbed code inside HTML.

  • HelloWeb.jsp

    Hello Web!

  • Hello.jsp

    Hello

  • Java Server PageImplemented as a (special kind of) servlet.

  • Controller Illustration: Web-based EA

  • Server

    :Tut06ControllerServlet

    HTTP Get

    doGet(req,resp)

    g:Greeting

    req:

    setAttribute("Greeting",g)

    forward(".../Greeting.jsp")

    Greeting.jsp

    ...

    getAttribute(...)

    g

    getGreeting()

  • PATTERN: ControllerWhat object in the domain (or application coordination layer) receives requests for work from the UI layer?

  • PATTERN: Controller (Larman 17.13)Problem: What object in the domain (or application coordination layer) receives requests for work from the UI layer?

    System operations (see SSD): major input events to the system

    The controller is the first object beyond the UI layer that is responsible for receiving or handling a system operations message.

    Note that UI objects delegate system operation request to a controller.

  • PATTERN: Controller (Larman 17.13)Solution: Assign the responsibility to a class representing one of the following choices:A faade controller, which representsthe overall systemA root objectA device that the software is running within, orA major subsystemA use case or session controller which represents a use case scenario in which the system operation occurs

  • Fig. 17.21

    ClassName

    attributes

    operations

    xxx

    id:Class

    1: msg()

    1: msg()

    Note

    Cashier

    actionPerformed( actionEvent )

    Which class of object should be responsible for receiving this system event message?

    It is sometimes called the controller or coordinator. It does not normally do the work, but delegates it to other objects.

    The controller is a kind of "facade" onto the domain layer from the interface layer.

    : ???

    : Cashier

    :SaleJFrame

    presses button

    enterItem(itemID, qty)

    UI Layer

    Domain Layer

    system operation message

  • Fowlers EA PatternsDomainData SourceTransaction ScriptDomain ModelData MapperRow Data GatewayFront ControllerTemplate ViewTransform ViewPage ControllerPresentationActive RecordTable ModuleTable Data Gateway

  • Front ControllerFowler: A controller that handles all requests for a web site.

    The Front Controller consolidates all request handling by channeling requests through a single handler object. This object can carry out common behaviour which can be modified at runtime with decorators. This handler then dispatches to command objects for behaviour particular to a request.

  • Front ControllerGoF design pattern: CommandUse a Command object to encapsulate the steps that are executed by a command.Command::doIt() executes commandAllows Command::unDoIt() etc

    GoF design pattern: DecoratorDecorator::m() adds additional behaviour, but delegates to real Object::m() for real behaviourEg, logging command execution before/after executing command

  • Page vs Front Controller Differences in URL

    Page Controllers for A1 http:/stu.cs/343A1/ViewTaskListhttp:/stu.cs/343A1/AddTaskhttp:/stu.cs/343A1/RemoveAllTasksFront Controller for A1Base URL: http:/stu.cs/343A1/frontController/frontController ?command=ViewTaskList/frontController ?command=AddTaskGrade&title=abc&

  • Front Controller

  • Front Controller

  • Front Controller: Sequence Diagram

  • Front Controller: ProcessRequest

  • Front Controller (contd)

Search related