02.egovframe training book_overview_supplement_en.pdf

Upload: banana567

Post on 03-Jun-2018

216 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/12/2019 02.eGovFrame Training Book_Overview_Supplement_EN.pdf

    1/11

    eGovFrame Training ook II

    eGovFrame Center2013

  • 8/12/2019 02.eGovFrame Training Book_Overview_Supplement_EN.pdf

    2/11

    Table of contents

    DI(Dependency Injection), IoC(Inversion of Control)

    AOP (Aspect Oriented Programming)

    MVC (Model, View, Controller) pattern concept

    Architecture based on eGovFrame

    Page l 2

    I

    II

    III

    IV

  • 8/12/2019 02.eGovFrame Training Book_Overview_Supplement_EN.pdf

    3/11

    Page l 3

    DI (Dependency Injection), IoC (Inversion of Control)

    public class MovieLister{ public void list() {

    MovieFinder finder = new MovieFinderImpl();}

    }

    public class MovieLister{ public void list() {

    MovieFinder finder = Assember.getBean("movieFinder");

    }}

    Change the flow of control between classes and reducing dependence(Ease

    of maintainability)

    When change Impl class, need to change Lister as well

    Assembler manages dependency

    Composition of eGovFrame

  • 8/12/2019 02.eGovFrame Training Book_Overview_Supplement_EN.pdf

    4/11

    Page l 4

    AOP (Aspect Oriented Programming)(1/2)

    AOP is a programming paradigm which aims to increase

    modularity by allowing the separation of cross-cutting concerns.

    Separate add-on services (ex: logging, security, exception, etc)that are repeated in a number of biz logic code in an information

    system as Aspect. Make that a separate module and maintain a program with configuration files.

    When changes occur in additional functions(add-ons), simply bychanging Aspect, the change can be reflected to the biz logic codeand the maintenance of the code will be much easier.

    Improve readability as removing duplicated code in business logic.

    Composition of eGovFrame

  • 8/12/2019 02.eGovFrame Training Book_Overview_Supplement_EN.pdf

    5/11

    Page l 5

    AOP (Aspect Oriented Programming)(2/2) Composition of eGovFrame

    [ Separating Aspect] [ Weaving]

    Aspect : A modularization of a concern that cuts across multiple objects

    Join point : A point during the execution of a program, such as the execution of a method or the

    handling of an exceptionAdvice : Action taken by an aspect at a particular join point

    Pointcut : A predicate that matches join points. Advice is associated with a pointcut expression andruns at any join point matched by the pointcut (for example, the execution of a method with acertain name)

    Weaving : Linking aspects with other application types or objects to create an advised object

    CreditTransfer

    DepositWithdraw

    Calculatinginterest

    Logging

    Security

    Transaction

    Core Concerns

    CrosscuttingConcerns

    Core ConcernsModule

    Calculatinginterest

    Deposit

    Withdraw

    CreditTransfer

    CrosscuttingConcerns Module

    Logging

    SecurityWeaving

  • 8/12/2019 02.eGovFrame Training Book_Overview_Supplement_EN.pdf

    6/11

    Page l 6

    Object Relational Mapping(ORM)

    Features General Development ORM based

    Apply Mapping Need direct mapping java classes to the tablecolumns

    Developers can be processed directly in terms of object-oriented

    FlexibilityWhen SQL changes, directly modify source code

    and deployCan be applied only with modifications of the mapping

    information

    Standard Pattern No patternMapping information, XML, etc can be applied in the form

    of template

    DB Control Directly control DB In case of Mapping, direct control can be difficult

    Technology in use SQL Persistence framework (Hibernate, iBatis)

    Composition of eGovFrame

    SQL

    Java-Mapping

    Business LogicBusiness Logic

    DB Column Java ClassMapping

    JDBC

    DataBase

    JDBC

    DataBaseBusiness Logic SQL MAP(Process SQL in

    the form of XML)

    Full ORM (Hibernate)

    Partial ORM (iBatis)

    ORM does not use SQL in source code, instead, directly maps java classes to thecolumns of the table or runs and handles SQL in the form of XML

  • 8/12/2019 02.eGovFrame Training Book_Overview_Supplement_EN.pdf

    7/11Page l 7

    SQL Map Implementation Code Example

    Separate SQL from business logic

    Provide simple transaction control (Provide declarative transaction) Provide a familiar SQL-based ORM model

    Statement st = null;ResultSet rs = null;try {

    st = con.createStatement();StringBuffer query = new StringBuffer();

    query.append("\n SELECT A.CHKLST_NO, ");query.append("\n A.EVALFL_CD, ");query.append("\n FROM PR_EVALIT_MB A ");query.append("\n WHERE A.CHKLST_NO = '"

    + sChklstNo + "' ");query.append("\n ORDER BY EVALIT_NOrs = st.executeQuery(st.toString());while(rs.next) {

    ...}

    } finally {try {rs.close();} catch (Exception e) {}try {st.close();} catch (Exception e) {}

    }

    // ComponentList result =

    ISqlManagement.getList (sql.id,value)

    // SqlMap.xml

    SELECT A.CHKLST_NO, A.EVALFL_CD FROM

    PR_EVALIT_MB A WHERE A.CHKLST_NO = #value#ORDER BY EVALIT_NO

    Separation of business

    logic and SQL

    Enhance productivity,maintainability,and reusability,

    Composition of eGovFrame

  • 8/12/2019 02.eGovFrame Training Book_Overview_Supplement_EN.pdf

    8/11Page l 8

    MVC (Model, View, Controller) pattern concept

    MVC is a software architecture, considered an architectural pattern used in softwareengineering.

    The MVC pattern isolates domain logic(the application logic for the user - model ) fromuser interface (input and presentation - view ), then the c ontroller handles the input eventfrom the user interface to process the request through the domain logic.It permits independent development, testing and maintenance of each.Especially, Spring MVC provides DispatcherServlet (*FrontController) that is designed

    to implement Presentation layer easier in MVC architecture

    Composition of eGovFrame

    DispatcherServlet Controller

    Http Request

    Http Response

    ModelView

    [ Conceptual Sequence of MVC pattern with DispatcherServlet ]

  • 8/12/2019 02.eGovFrame Training Book_Overview_Supplement_EN.pdf

    9/11Page l 9

    Spring MVC Architecture Composition of eGovFrame

    View(JSP)

    Controller

    Model(BizLogic)

    Dispatcher Servlet(Front Controller)

    DB

    Model andView

    HandlerMapping

    ViewResolver

    Request

    Response

    Request ContollerRequest

    View NameView Response

    Model andView

    Model andView

    Spring's Web MVC framework is designed around a DispatcherServlet thatdispatches requests to handlers, with configurable handler mappings, view

    resolution.

  • 8/12/2019 02.eGovFrame Training Book_Overview_Supplement_EN.pdf

    10/11Page l 10

    Architecture based on eGovFrame

    Presentation Layer Business Layer Data Access Layer

    View(JSP)

    Dispatcher

    Servlet

    Controller

    Service Interface

    ServiceImpl

    DAO

    DataBase

    Request

    SQL(XML)

    Development Configuration

    HandlerMapping

    ViewResolver

    Spring Config(transaction)

    Spring Config(datasource)

    Spring Config.

    (ORM)

    Data Value Object Value Object

    Programming Procedure

    Spring Module

  • 8/12/2019 02.eGovFrame Training Book_Overview_Supplement_EN.pdf

    11/11Page l 11

    mailto:[email protected]