Sie sind auf Seite 1von 11

eGovFrame Training Book II

eGovFrame Center 2013

Table of contents
I II III IV

DI(Dependency Injection), IoC(Inversion of Control) AOP (Aspect Oriented Programming) MVC (Model, View, Controller) pattern concept Architecture based on eGovFrame

Page l

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

Composition of eGovFrame

Change the flow of control between classes and reducing dependence(Ease of maintainability)
public class MovieLister{ public void list() { MovieFinder finder = new MovieFinderImpl(); } When change Impl class, need to change Lister as well }

public class MovieLister{ public void list() {


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

} } Assembler manages dependency

Page l

AOP (Aspect Oriented Programming)(1/2)

Composition of eGovFrame

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 by changing Aspect, the change can be reflected to the biz logic code and the maintenance of the code will be much easier. Improve readability as removing duplicated code in business logic.

Page l

AOP (Aspect Oriented Programming)(2/2)


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

Composition of eGovFrame

Join point: A point during the execution of a program, such as the execution of a method or the handling of an exception Advice: Action taken by an aspect at a particular join point Pointcut: A predicate that matches join points. Advice is associated with a pointcut expression and runs at any join point matched by the pointcut (for example, the execution of a method with a certain name)

Weaving: Linking aspects with other application types or objects to create an advised object
Core Concerns
Core Concerns Module Calculating interest Credit Transfer Deposit Withdraw Logging Calculating interest Crosscutting Concerns Module

Credit Transfer Logging

Deposit Withdraw

Weaving

Security

Cross cutting Concerns

Security Transaction

[ Separating Aspect]

[ Weaving]

Page l

Object Relational Mapping(ORM)

Composition of eGovFrame

ORM does not use SQL in source code, instead, directly maps java classes to the columns of the table or runs and handles SQL in the form of XML
Full ORM (Hibernate) Business Logic Business Logic DB Column Java Class Mapping JDBC SQL MAP (Process SQL in the form of XML)

JDBC

SQL Business Logic

DataBase

Java-Mapping Partial ORM (iBatis)

DataBase

Features Apply Mapping Flexibility Standard Pattern DB Control

General Development Need direct mapping java classes to the table columns When SQL changes, directly modify source code and deploy No pattern Directly control DB

ORM based Developers can be processed directly in terms of objectoriented Can be applied only with modifications of the mapping information Mapping information, XML, etc can be applied in the form of template In case of Mapping, direct control can be difficult

Technology in use

SQL

Persistence framework (Hibernate, iBatis)

Page l

SQL Map Implementation Code Example

Composition of eGovFrame

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_NO rs = st.executeQuery(st.toString()); while(rs.next) { ... } } finally { try {rs.close();} catch (Exception e) {} try {st.close();} catch (Exception e) {} }

Separation of business logic and SQL Enhance productivity, maintainability, and reusability,

// Component List result = ISqlManagement.getList(sql.id,value)

// SqlMap.xml <select id=id resultclass =hmap> SELECT A.CHKLST_NO, A.EVALFL_CD FROM PR_EVALIT_MB A WHERE A.CHKLST_NO = #value# ORDER BY EVALIT_NO </select>

Page l

MVC

(Model, View, Controller)

pattern concept

Composition of eGovFrame

MVC is a software architecture, considered an architectural pattern used in software engineering. The MVC pattern isolates domain logic(the application logic for the user - model) from user interface (input and presentation - view), then the controller handles the input event from 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
Http Request DispatcherServlet Http Response Controller

View

Model

[ Conceptual Sequence of MVC pattern with DispatcherServlet ]


Page l

Spring MVC Architecture

Composition of eGovFrame

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

HandlerMapping Request Request Request Contoller

Controller Model
Model and View Model and View

(Biz Logic)

Dispatcher Servlet (Front Controller)


Model and View View View Name Response

Response

DB

View Resolver

View (JSP)

Page l

Architecture

based on eGovFrame

Programming Procedure

Presentation Layer

Business Layer

Data Access Layer

HandlerMapping

Controller DAO Service Interface Spring Config. (ORM) SQL(XML)

Request

Dispatcher
Servlet

View (JSP)

ViewResolver

ServiceImpl

Spring Config (transaction)

Spring Config (datasource)

DataBase

Data

Value Object Development Spring Module Configuration

Value Object

Page l

10

Page l

11

Das könnte Ihnen auch gefallen