2. Table of contents
I DI(Dependency Injection), IoC(Inversion of Control)
II AOP (Aspect Oriented Programming)
III MVC (Model, View, Controller) pattern concept
IV Programming Procedure based on eGovFrame
V Common component concept
Page l 2
3. 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 3
4. 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 4
5. AOP (Aspect Oriented Programming)(2/2) Composition of eGovFrame
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 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 Crosscutting
Module Concerns Module
Credit Deposit Calculating Credit
Transfer Weaving Security
Transfer Withdraw interest
Logging
Deposit
Cross Withdraw
cutting Security Logging
Concerns Calculating
Transaction interest
[ Separating Aspect] [ Weaving]
Page l 5
6. 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)
DB Column –
Business Logic
Business Logic Java Class
Mapping
JDBC
JDBC SQL
SQL MAP
Business Logic (Process SQL in
the form of XML) DataBase
DataBase Java-Mapping
Partial ORM (iBatis)
Features General Development ORM based
Need direct mapping java classes to the table Developers can be processed directly in terms of object-
Apply Mapping
columns oriented
When SQL changes, directly modify source code Can be applied only with modifications of the mapping
Flexibility
and deploy information
Mapping information, XML, etc can be applied in the form
Standard Pattern No pattern
of template
DB Control Directly control DB In case of Mapping, direct control can be difficult
Technology in use SQL Persistence framework (Hibernate, iBatis)
Page l 6
7. Composition of eGovFrame
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();
// Component
StringBuffer query = new StringBuffer();
Separation of List result =
business ISqlManagement.getList(“sql.id”,”value”)
query.append("n SELECT A.CHKLST_NO, ");
query.append("n A.EVALFL_CD, "); logic and S
query.append("n FROM PR_EVALIT_MB A "); QL
query.append("n WHERE A.CHKLST_NO = '"
+ sChklstNo + "' ");
query.append("n ORDER BY EVALIT_NO enhance // SqlMap.xml
productivity, <select id=“id” resultclass =“hmap”>
rs = st.executeQuery(st.toString());
SELECT A.CHKLST_NO, A.EVALFL_CD FROM
while(rs.next) { maintainabilit
PR_EVALIT_MB A WHERE A.CHKLST_NO = #value#
... y, and ORDER BY EVALIT_NO
}
reusability, </select>
} finally {
try {rs.close();} catch (Exception e) {}
try {st.close();} catch (Exception e) {}
}
Page l 7
8. 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 Controller
Http Response
View Model
[ Conceptual Sequence of MVC pattern with DispatcherServlet ]
Page l 8
9. 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
Controller
Request Model
Request Contoller
(Biz
Model and Model and
View Logic)
View
Request
Dispatcher Servlet
(Front Controller)
Response Model and
View
View View Name Response
DB
View
View
Resolver (JSP)
Page l 9
10. Programming Procedure based on eGovFrame (1/8) Programming Procedure
Presentation Layer Business Layer Data Access Layer
HandlerMapping Controller
DAO
Service Interface Spring Config.
Request Dispatcher
(ORM)
Servlet
SQL(XML)
View ServiceImpl
ViewResolver
(JSP)
Spring Config Spring Config DataBase
(transaction) (datasource)
Data Value Object Value Object
Development Configuration
Spring Module
Page l 10
11. Programming Procedure based on eGovFrame (2/8) Programming Procedure
Output Screen
Page l 11
12. Programming Procedure based on eGovFrame (3/8) Programming Procedure
Controller : Receive a request and call a service(biz logic)
Implement features such as data binding, forms processing, and muti-action, etc
@Controller JSP Controller Service DAO
@SessionAttributes(types=SampleVO.class)
public class EgovSampleController {
VO SQL
/** SampleService */
@Resource(name = "sampleService")
private EgovSampleService sampleService;
/**
* Inquire post list. (pageing)
* @param searchVO - SampleDefaultVO
* @param model
* @return "/sample/egovSampleList"
* @exception Exception
*/
@RequestMapping(value="/sample/egovSampleList.do")
public String selectSampleList(@ModelAttribute("searchVO") SampleDefaultVO searchVO,
ModelMap model) throws Exception {
List sampleList = sampleService.selectSampleList(searchVO);
model.addAttribute("resultList", sampleList);
return "/sample/egovSampleList";
}
}
Page l 12
13. Programming Procedure based on eGovFrame (4/8) Programming Procedure
Service : Interface that declares methods for business functions
Service
JSP Controller ServiceImpl DAO
public interface EgovSampleService {
VO SQL
/**
* Inquire post list.
* @param searchVO – VO including search information
* @return post list
* @exception Exception
*/
List selectSampleList(SampleDefaultVO searchVO) throws Exception;
}
Page l 13
14. Programming Procedure based on eGovFrame (5/8) Programming Procedure
ServiceImpl : Implementation class that implements methods that defined in a
service
Service
JSP Controller ServiceImpl DAO
@Service("sampleService")
public class EgovSampleServiceImpl extends AbstractServiceImpl implements VO SQL
EgovSampleService {
/** SampleDAO */
@Resource(name="sampleDAO")
private SampleDAO sampleDAO;
/**
* Inquire post list.
* @param searchVO - VO including search information
* @return post list
* @exception Exception
*/
public List selectSampleList(SampleDefaultVO searchVO) throws Exception {
return sampleDAO.selectSampleList(searchVO);
}
}
※ Tip : In case of a ServiceImpl, AbstractServiceImpl must be extended
Page l 14
15. Programming Procedure based on eGovFrame (6/8) Programming Procedure
DAO : Process data transaction (support iBatis connection)
JSP Controller Service DAO
@Repository("sampleDAO")
public class SampleDAO extends EgovAbstractDAO { VO SQL
/**
* Inquire post list.
* @param searchVO - VO including search information Call EgovAbstractDAO’s list method to run iBatis
* @return post list Query ID
* @exception Exception
*/
public list<SampleVO> selectSampleList(SampleVO vo) throws Exception {
return list("sampleDAO.selectSampleList_D", vo);
}
※ Tip : In case of a DAO, EgovAbsractDAO must be extended.
Method Summary
int delete(java.lang.String queryId, java.lang.Object parameterObject) : Execute delete SQL mapping.
java.lang.Object insert(java.lang.String queryId, java.lang.Object parameterObject) : Execute Insert SQL mapping
java.util.List list(java.lang.String queryId, java.lang.Object parameterObject) : Execute list SQL mapping
listWithPaging(java.lang.String queryId, java.lang.Object parameterObject, int pageIndex, int pageSize) : Execute sub range
java.util.List
list SQL mapping
java.lang.Object selectByPk(java.lang.String queryId, java.lang.Object parameterObject) : select one result by PK
setSuperSqlMapClient(com.ibatis.sqlmap.client.SqlMapClient sqlMapClient) Execute configuration as receiving sqlMapClient
void
in the form of Annotation and calling setSqlMapClient method of super(SqlMapClientDaoSupport)
int update(java.lang.String queryId, java.lang.Object parameterObject) : Execute update SQL mapping
Page l 15
16. Programming Procedure based on eGovFrame (7/8) Programming Procedure
iBatis SQL Map : Define SQL execution query
JSP Controller Service DAO
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN" "http://www.ibatis.com/dtd/sql-map-2.dtd"> VO SQL
<sqlMap namespace="Sample">
<typeAlias alias="egovMap" type="egovframework.rte.psl.dataaccess.util.EgovMap"/>
<typeAlias alias="searchVO" type="egovframework.rte.sample.service.SampleDefaultVO"/>
<resultMap id="sample" class="egovframework.rte.sample.service.SampleVO">
<result property="id" column="id"/>
<result property="name" column="name"/>
<result property="description" column="description"/>
<result property="useYn" column="use_yn"/>
<result property="regUser" column="reg_user"/>
</resultMap>
<select id="sampleDAO.selectSampleList_D" parameterClass="searchVO" resultClass="egovMap“>
SELECT
ID, NAME, DESCRIPTION, USE_YN, REG_USER
FROM SAMPLE
WHERE 1=1
<isEqual prepend="AND" property="searchCondition" compareValue="0">
ID = #searchKeyword#
</isEqual>
<isEqual prepend="AND" property="searchCondition" compareValue="1">
NAME LIKE '%' || #searchKeyword# || '%'
</isEqual>
ORDER BY ID DESC
LIMIT #recordCountPerPage# OFFSET #firstIndex#
</select>
</sqlMap>
Page l 16
17. Programming Procedure based on eGovFrame (8/8) Programming Procedure
VO : The object used for the purpose of data transfer between objects
JSP Controller Service DAO
public class SampleVO extends SampleDefaultVO {
private static final long serialVersionUID = 1753729060514530707L;
VO SQL
/** ID */
private String id;
/** Name */
private String name;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
Page l 17
18. Common Components
Common component concept
A collection of reusable common modules in developing
applications for e-Government projects
An software unit that can run itself
Example
- Notice board, log-in, string validation check, etc
Page l 18