Openframeworkdevguide(brief) - Spring Study Club

Download Report

Transcript Openframeworkdevguide(brief) - Spring Study Club

오픈 소스 기반
웹 어플리케이션 개발 가이드
Version 0.1
2008.11.02
This report is written by Sunny Kwak. ([email protected], sunnykwak.egloos.com)
Agenda
 Standard Annotations
 What is Good? What is better?
 Open Source Framework architecture
 WAS startup process
 Web Application configuration files
 Service flow overview
 Struts 2 & Spring 2 service flow
 How to make custom components
How to make AJAX call
 How to make struts actions
 Messaging service
 ORWrapper
 Build common modules
 Deploy to server
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
1
Standard Annotations
[ 서비스 분할 ]
업무 묶음 혹은 서버
[ 네트워크 및 서비스 흐름 ]
[ 컴포넌트 유형 ]
Component
新 컴포넌트
Component
Framework 컴포넌트
Component
솔루션 컴포넌트
네트워크 어댑터
Module
Module
Module
新 모듈
Framework 모듈
솔루션 모듈
데이터 통신
서비스 호출
업무 구분 (영역)
[ 서버 및 저장소 ]
소프트웨어 컴포넌트 블럭
Database or
Repository
서버
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
2
What is Good ?
What’s Good, What is Better
Solution?
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
3
What is Good? – 좋은 시스템의 요건
생산성
성능 및
신뢰성
안정성
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
4
What is Good? – 관습적 개발 방식의 문제점들
Copy & Paste !!!
- 소스 코드의 반복
- 모든 페이지에 반복적인 소스 코드 삽입
뉴스 게시판
공지사항 게시판
소스분량 및 작업시간 증가
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
유지보수의 어려움
5
What is Good? – 기존 개발 방식의 문제점들
개발자의 어쩔 수 없는 실수 유발
- 인간이기 때문에…
- 복사하면서 누락하거나, 개선된 사항을 과거의 코드에 반영하지 못하거나... 밤샘을 하던가…
코드 불일치
[ 잘못된 소스 ]
[ 정확한 소스 ]
코드 누락 시 문제 발생
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
System Down !!!
6
What is Good? – 기존 개발 방식의 문제점들
특정 환경에 종속적인 구조 설계
- 하지만, 서비스 플랫폼은 끓임 없이 변화하고
- 동일한 서비스 혹은 비즈니스인데도 불구하고 다시 개발하는 불상사 발생
기존 웹 프레임 워크(MVC)
WEB
Servlet, JSP
PDA
request
response
자동화기기
서비스 요청
타 채널 적용 불가
Web 종속
서비스 다양화를 위한 인력, 시간, 비용 증가
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
7
What is Good? – 기존 개발 방식의 문제점들
똑같은 작업의 무한 반복
- 프로젝트가 진행되고, 서비스가 성공할 수록 오히려 해야 할 일들은 증가…
-
생산성은 오히려 떨어지고 … 몇 년 후에는 아예 다시 설계하게 되고 …
그리고, 상사의 질책과 야근은 늘어가고… 엄마가 보고 싶을 뿐이고… (왜 낳으셨나요?)
회원 게시판
LINK 게시판
일반 게시판
•
코드의 증가로 인한 자원 낭비
•
개발자의 작업량 증가로 생산성 저하 및 개발 시간 연장
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
8
What is Good? – Open source framework
Framework 구성 요건
Reasonable Proof
오픈소스
Framework
플랫폼 독립적이고 Layer의 구분이
명확한 아키텍처
SI
상용
Framework
Framework
실제 프로젝트에서 생산성이 검증된
개발도구 지원
SI Framework
• 대형 SI 업체가 SI 프로젝트 시 사용할 목적으로 제작
• 기술 지원에 대한 의존성이 높고 범용성이 떨어짐
표준기술 준수로 각종 솔루션 및 업무
시스템과의 유연한 연계
상용
Framework
• 고가의 구매 비용
• 커스터마이징의 어려움
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
9
What is Good? – Struts 2
Simple view

vs
Detail View
Struts 2는 MVC(Model View Controller) 모델을 구현하는 프레임워크.
 내부적으로 WebWork 2 의 아키텍처를 수용하여 견고하고 확장성이 높은 구조로 설계되어 있다.
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
10
What is Good? – Struts 2
Interceptor 설정을 통해 기존의 반복된 소스 코드 작성을 대체한다.
Struts2 based Project
관습적인 MVC Project
서비스 전,후에 실행되므로
각 페이지에 반복된 소스 삽입 불필요
설정파일이
제공되므로,
설정파일이
제공되므로,
유지보수 및
개발의
유지보수 및 개발의 편의성 제공
편의성 제공
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
11
What is Good? – Spring 2

DAO
Spring JDBC
Transaction
management
- 적은 시스템 자원 소모 (1MB 정도의 적은 JAR 크기)
Web
- 무시해도 되는 수준의 성능 부하
ORM
Spring Web MVC
Hibernate
Framework Integration
JPA
WebWork
TopLink
JDO
OJB
iBatis
JEE
JMX
JMS
JCA
Remoting
EJBs
AOP
Email
- 어플리케이션이 프레임워크에 종속되지 않음.
(침입적이지 않은 아키텍쳐)
Tapestry

JSF
Rich View Support
JSPs
(loosely couple component) 구현
Velocity
FreeMarker

PDF
- 서비스 실행 시 필요한 부가 기능을 설정 파일로 추가.
(로그 생성, 프로파일링 기능 적용 용이)
Spring Portlet MVC
Core

The IoC container
AOP (Aspect Oriented Programming)
- 관점 지향 개발을 통해 비즈니스 로직 구현에 집중 가능
Excel
AspectJ integration
IoC (Inversion of Control)
- 제어 역행 기법을 통해 컴포넌트 간의 느슨한 결합
Jasfer Reports
Spring AOP
Lightweight
Container
- 객체의 생명 주기와 객체들 간의 관계를 제어
- XML 설정 파일을 통해 선언적으로 컴포넌트 구성
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
12
What is Good? – Spring 2
Spring Framework를 활용하여 타 채널(Mobile, PDA….)에서
재사용 가능한 컴포넌트 구현 가능
기존 웹 프레임 워크(MVC)
Servlet, JSP
request
Struts2 + Spring2 프레임워크
Presentation Layer System
WEB
Service
Action
Service
Handler
Struts
Framework
Spring
Framework
response
PDA
서비스 요청
Application Server
Mobile
가능
불가능
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
개발 시간 단축 및 개발 생산성, 효율성 제공
13
What is Good? – Struts 2 + Spring 2
동일한 패턴의 반복적인 코드들을 하나의 모듈로 통합
Struts2 + Spring2 Project
MVC Project
Interceptor(s)
Web Request
Action
(injected)
Result
자원 낭비 감소, 유지보수 편리성, 개발 작업량 감소
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
14
What is Good? – Struts 2 + Spring 2 + iBatis
왜 2가지 이상의 프레임워크를 함께 사용하는가?
Framework 설계 요건
Struts 2
Spring
Framework
Framework
프레임워크 설계 시에도
낮은 결합도 추구
iBatis
Framework
은 탄환(silver bullet)은 없다.
완벽한 프레임워크도 없다.
• 웹 어플리케이션을 위한 적절한 제어 구조
Struts 2
Framework
및 컴포넌트가 충분히 확보되어 있다. (인터셉터, 리절트)
• Tiles 등 UI 프레임워크와의 조합이 유연하다.
UI, business, repository 등
계층 별로 적절한 프레임워크 선정
• 단점은 웹 환경에 종속적이라는 것이다.
• 컴포넌트 생명 주기 및 관계 제어를 통한 결합도 하향
Spring 2
Framework
• 비즈니스 컴포넌트를 재활용할 수 있게 한다.
재사용성을 극대화하고,
가시성을 높일 수 있다.
• 선언적 프로그래밍 가능.
• 쿼리를 비즈니스 코드와 분리하여 선언/관리 가능
iBatis
Framework
설계 및 교육에 따르는 비용 증가
• 환경 설정 파일을 통한 직관적인 구성
지나치면 모자라는 것보다 못함
• 진정한 OR Wrapper는 아니지만,
쿼리 최적화가 필요한 환경에서는 보다 유리함.
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
15
What is Good? – Struts 2 + Spring 2
Struts2 + Spring2 Project
MVC Project
build components
(dependency injection)
2.Get Instance
1.request
Spring Container
JSP
JSP
JSP
Bean
3.request
5.response
JSP
4.1 Call function
Service
Component
Struts
dispatcher
4.2 query
Struts Action
DB
DB
MVC Project
Struts2 + Spring2 Project
유지보수
개발 패턴의 반복 삽입으로 인한 유지보수 어려움
Interceptor 설정을 통한 유지보수 편리
재사용성
타 채널에서 재사용 불가
타 채널에서 재사용 가능
개발 생산성
서비스 별 동일한 프로세스 생성으로 인한 개발 생산
성 감소
하나의 통합된 모듈을 구현함으로써 개발생산성
증대
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
16
System Architecture
Open Source Framework based
System Architecture
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
17
웹 어플리케이션 구성도
서비스
Legacy
웹 어플리케이션 시스템
클라이언트
Systems
비즈니스 컴포넌트 Pool
Request
XML
PC
Biz.
컴포넌트
XML Parser
RMI/IIOP
로그인
체크
Request
Data Object
TCP/IP
회원정보
조회
PDA
XML
Service
Dispatcher
서비스
실행
서비스 DB
Mobile
TV
Response XML
예외처리
XML
Service
Controller
다국어
로그
메시지
J2EE Framework 공통 컴포넌트
메신저
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
TCP/IP
18
JDBC
Routing
웹 어플리케이션 구성도 (RMI based system example)
IP : 192.17.10.49
IP : 19217.10.50
Dynamic Contents Delivery
Server
Dynamic Delivery Server
RMI,
Spring 2 & iBatis
Framework
Apache Tomcat Server
HTTP,
80 port
9004 port
Relay Server
Relay Server
(Web Application Server)
Billing Manager
(HTTP client)
Request Parser
(HTTP client)
Admin Center Server
Action
(RMI client)
Content Provider
(RMI server)
Admin Center
(Web Application Server)
RMI,
Query Handler
(DB client)
9001 port
Remote File Server
IP 192.17.10.51
RMI, 9003 port
Contents Provider Gateway
Contents Publisher
(RMI Client)
CP Gateway
(Web Application Server)
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
19
JDBC,
1521 port
Oracle Database
Contents & Profile
Database
Service flow overview
form submit
or Ajax call
사용자
방화벽
Web
Application
Server
Internet Explorer
or
Firefox
build components
(dependency injection)
Struts 2
Action
Value
Object
Service
Provider
Remote
Call
Spring Container
Struts
dispatcher
Business
Service
Component
Persistence
Layer
Legacy
Systems
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
20
Open Source Framework architecture
UI Layer
JSP 2.0 (EL)
JSTL 1.1
(Biz Components)
Security
Service (Biz.) Layer
Custom Tags
Ajax
POJO
Spring Bean
Message Handling
Constants & Configuration
Session Management
Utilities (String, Date)
Exception Handling
Logging
Web Common Framework
(Infrastructure)
Interceptors
Action
Dependency Injection
Result
Struts Tags
Bean Management
UI Framework
(Struts 2)
Service Framework
(Spring 2.0)
Web Application Server (JEUS, Web Logic, ETC)
J2EE 6
J2SE 6.0 (SUN JDK 1.6)
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
21
Struts 2 & Spring 2 service flow
Form submit or
Ajax call
Load Injected
Action & components
Struts 2
Dipatcher
Struts 2 default &
Custom interceptor
Interceptor(s)
Action
(injected)
Messaging
Service
Web Request
HTML, Excel or
JSON formatted data
struts.xml
Spring
Context Loader
Result
Execute
Dependency Injection
Render JSP or
JSON
ORWrapper
Execute
Query
Database
applicationContext.xml
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
22
All needed framework & libraries
Library Group
Jar File Name
Description
Apache Commons
(http://commons.a
pache.org/)
commons-lang-2.3.jar
Log4J
commons-logging-1.1.1.jar
commons-io-1.4.jar
commons-beanutils-1.7.0.jar
commons-dbcp-1.2.2.jar
commons-pool-1.3.jar
commons-fileupload-1.2.1.jar
commons-codec-1.3.jar
log4j-1.2.15.jar
자바 표준 JDK의 java.lang 패키지에 있는 기능을 확장하고 편리하게
만든 패키지.
다양한 로깅(logging) API 구현체에 대한 래퍼(wrapper)
I/O 처리를 간편하게 해주는 패키지
빈(bean) 접근을 간편하게 해주는 패키지
데이터베이스 커넥션 풀 관리 라이브러리
풀(pool) 관리 라이브러리
파일 업로드 라이브러리
CODEC 라이브러리
Log4J 로그 생성 라이브러
iBatis
ibatis-2.3.0.677.jar
iBatis 데이터베이스 쿼리 프레임워크
Oracle JDBC
driver
ojdbc14.jar
오라클 JDBC 드라이버
Struts 2
Framework
struts2-core-2.0.11.1.jar
xwork-2.0.4.jar
ognl-2.6.11.jar
freemarker-2.3.8.jar
xerces.jar
xercesImpl.jar
스트럿츠 2 프레임워크
Xerces
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
XML 파서(parser)
23
Framework library configuration – Log4j
<?xml version="1.0" encoding="UTF-8" ?>
{PROJECT-HOME}/src/log4j.xml
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="CONSOLEAPPENDER" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern"
value="[%d{yyyy-MM-dd HH:mm:ss}] %-5p %C.%M(%L) - %m%n" />
</layout>
</appender>
로그 파일 저장 경로 및 파일 명칭 지정
로그 파일 크기는 10MB로 지정하였으며, 변경 가능
<appender name="FILEAPPENDER"
class="org.apache.log4j.RollingFileAppender">
<param name="append" value="false" />
최대 백업 횟수는 10회
<param name="file" value="/tmp/contents-adm.log" />
<param name="maxFileSize" value="10MB" />
<param name="maxBackupIndex" value="10" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern"
value="[%d{yyyy-MM-dd HH:mm:ss}] %-5p %C.%M(%L) - %m%n" />
</layout>
</appender>
<logger name="org.apache.struts2">
<level value="WARN" />
</logger>
com.acme 패키지 및 하위 패키지에 포함된 클래스에서
생성되는 로그는 DEBUG 레벨까지 기록
<logger name="com.opensymphony.xwork2">
<level value="WARN" />
</logger>
<logger name="com.acme">
<level value="DEBUG" />
</logger>
<root>
<level value="DEBUG" />
<appender-ref ref="FILEAPPENDER" />
</root>
</log4j:configuration>
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
24
Framework library configuration – Java Cache System
JCS(Java Cache System) 라이브러리를 위한 설정 파일이다.
최대 2000개의 객체를 캐시(cache) 내에 저장하며, LRU(Lead Recently Used) 메모리 캐시 알고리즘을 사용한다.
디스크 등 외부 캐시를 사용하지 않고, 캐시에 저장된 객체의 유효 기간(생명 주기)는 5분으로 설정하였다.
{PROJECT_HOME}/src/cache.ccf
jcs.default=
jcs.default.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
jcs.default.cacheattributes.MaxObjects=2000
jcs.default.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
jcs.default.elementattributes=org.apache.jcs.engine.ElementAttributes
jcs.default.elementattributes.IsEternal=false
jcs.default.elementattributes.MaxLifeSeconds=300
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
25
Framework library configuration – iBatis
시스템에서 데이터베이스에 접근하기 위해 iBatis 프레임워크를 사용한다.
데이터베이스 접근을 공통화 하기 위해 DB 연결을 위한 설정 파일은 공통(common) 프로젝트에 포함시켰으며,
개별 프로젝트에서 사용하는 쿼리는 프로젝트 별로 설정 파일을 작성한다.
{PROJECT_HOME}/src/sqlmap-config.properties
driver=oracle.jdbc.driver.OracleDriver
url=jdbc:oracle:thin:@128.13.223.13:1521:MPDB
username=DBUSER
password=DBUSER
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
26
Framework library configuration – iBatis (continue)
{PROJECT_HOME}/src/config/sql-map/sqlmap-config.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE sqlMapConfig PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN"
"http://www.ibatis.com/dtd/sql-map-config-2.dtd">
데이터베이스 접근을 위한
계정 및 암호는 공통 설정 파일을 참조한다.
<sqlMapConfig>
<properties resource="properties/sqlmap-config.properties"/>
<settings
cacheModelsEnabled="true"
enhancementEnabled="true"
lazyLoadingEnabled="true"
maxRequests="32"
maxSessions="10"
maxTransactions="5"
useStatementNamespaces="false"
/>
<transactionManager type="JDBC">
<dataSource type="DBCP">
<property name="driverClassName" value="${driver}"/>
<property name="url" value="${url}"/>
<property name="username" value="${username}"/>
<property name="password" value="${password}"/>
<property name="maxActive" value="20"/>
<property name="initialSize" value="5"/>
</dataSource>
</transactionManager>
쿼리를 포함하는 설정 파일을 기능 단위 별로
작성하며, sqlmap-config.xml 파일에서 참조
(include) 한다.
<sqlMap resource="config/sqlmap/board-sqlmap.xml"/>
<sqlMap resource="config/sqlmap/member-sqlmap.xml"/>
<sqlMap resource="config/sqlmap/file-sqlmap.xml"/>
<sqlMap resource="config/sqlmap/device-sqlmap.xml"/>
<sqlMap resource="config/sqlmap/bill-sqlmap.xml"/>
</sqlMapConfig>
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
27
WAS startup process
1) WebLogic Startup
3) Initialize Struts 2 framework
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
Struts dispatcher
4) Initialize Spring 2 framework
WEB-INF/web.xml
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
Spring Container
2) Read web.xml
5) Initialize Tiles framework
<listener>
<listener-class>org.apache.tiles.web.startup.TilesListener</listener-class>
</listener>
6) Initialize listener
<listener>
<listener-class>com.acmeweb.listener.CustomSessionListener</listener-class>
</listener>
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
28
Tiles setting listener
Web Application Configuration files
① 프로젝트 홈 디렉토리
② 자바 소스 디렉토리
③ 스프링 설정 디렉토리
④ 스트럿츠 & 타일즈 설정 디렉토리
⑤ 웹 어플리케이션 설정 디렉토리
Location
Description
① 프로젝트 홈
{PRJECT_HOME}
웹 어플리케이션 홈 디렉토리. 설정 파일 없음.
② 자바 소스 홈
{PRJECT_HOME}/src
로거 설정 파일 (log4j.xml)
스트럿츠 루트 설정 파일 (struts.xml)
스트럿츠 변수 값 설정 파일 (struts.properties)
③ 스프링 설정
{PRJECT_HOME}/src/config/spring
스프링 설정 파일 (복수)
④ 스트럿츠 및 타일즈 설정
{PRJECT_HOME}/src/config/struts
스트럿츠 설정 파일 (복수)
타일즈 설정 파일
⑤ 웹 어플리케이션 설정
{PRJECT_HOME}/web/WEB-INF
웹 어플리케이션 설정 파일(web.xml)
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
29
Web Application Configuration files (Struts 2)
Struts 2
Configuration
<!-- 공통 설정 -->
<include file="/config/struts/hana-struts-default.xml"/>
{PROJECT_HOME}/src/struts.xml
root config file
<!-- 대메뉴별 메뉴 설정 -->
<include file="/config/struts/struts-pbk-banka.xml"/>
<include file="/config/struts/struts-pbk-card.xml"/>
{PROJECT_HOME}/src/config/struts/struts-pbk-banka.xml
include sub-menu config files
{PRJOECT_HOME}/src/config/struts/struts-pbk-card.xml
 {PRJ_HOME}/src/struts.xml 파일은 ‘스트럿츠 루트 설정’ 파일이며, 가장 먼저 로딩된다.
(스트럿츠 프레임워크는 CLASS_PATH에 등록된 경로를 스캔하여, struts.xml 파일을 찾는다.)
 공통(global) 설정 항목은 ‘/config/struts/hana-struts-default.xml’ 파일에 정의한다.
 각 메뉴(혹은 서비스) 별 액션 설정은 대메뉴별로 구분하여 설정 디렉토리에 등록하며,
struts.xml 설정 파일에서 포함(include) 시킨다.
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
30
Web Application Configuration files (Tiles)
Tiles
Configuration
<context-param>
<param-name>org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG</param-name>
<param-value>/WEB-INF/classes/config/struts/tiles-pbk.xml</param-value>
</context-param>
WEB-INF/web.xml
declare spring config location
{PRJECT_HOME}/src/config/struts/tiles-pbk.xml
set configuration files location
 Tiles 설정 파일 위치는 ‘WEB-INF/web.xml’ 파일에서 선언한다.
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
31
Web Application configuration files (Spring 2)
Spring 2
Configuration
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:config/spring/applicationContext-*.xml</param-value>
</context-param>
WEB-INF/web.xml
declare spring config location
{PRJECT_HOME}/src/config/spring/applicationContext-rule.xml
{PRJECT_HOME}/src/config/spring/applicationContext-service.xml
set configuration files location
{PRJECT_HOME}/src/config/spring/applicationContext-struts.xml
 스프링 설정 파일 위치는 ‘WEB-INF/web.xml’ 파일에서 선언한다.
 스프링 설정 파일은 3개의 영역으로 분리하여 작성한다.
applicationContext-rule.xml
: 입력 전문 빈(도메인 객체)을 설정한다.
applicationContext-service.xml
: 전문(message) 송수신을 처리하는 서비스 빈(컴포넌트)을 설정한다.
applicationContext-struts.xml
: 스트럿츠 액션 빈(컴포넌트)을 설정한다.
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
32
System Architecture
Workspace, Project, Build & Deploy
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
33
Workspace & projects
workspace
project
contents 공통 라이브러리
contents-COM
RMI File Transfer Library
contents-CTS
contents-GW
contents-RMIIO
contents-RLY
Contents Delivery Server
contents-RFS
contents-CTS
Dynamic Delivery Server
contents-DYN
contents-COM
Gateway Server
workspace01
contents-RMIIO
contents-GW
Admin Server
contents-DYN
contents-ADM
contents-ADM
Remote File Server
contents-RFS
Relay Server
contents-RLY
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
34
Common project root
Project Root
src
• 자바 소스 파일들이 위치한다.
web
• HTML, JSP, Image, Javascript 파일들이 위치한다.
• 만일 해당 프로젝트가 웹 프로젝트 아니라면, web 디렉토리 자체가 존재하지 않는다.
bin
• 목적 파일(object 파일)들이 위치한다.
cmd
• 서비스 실행 및 종료를 위한 스크립트 파일들이 위치한다.
• 데몬(daemon) 프로젝트가 아니라면, 디렉토리 자체가 존재하지 않는다.
lib
• 참조 라이브러리(reference library)들이 위치한다.
build.xml
• 프로젝트 컴파일, 배포 등을 위한 ant 빌드 스크립트 파일이다.
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
35
Project base package
Project
Name
Type
Description
Base package
contents-COM
Library
날짜 처리, 환경 변수 조회, 파일 입출력 등 표준 클래스를 제공하는
공통 라이브러리
com.acme.contents.common
contents-RMIIO
Library
RMI를 통한 파일 송수신 처리를 제공하는 라이브러리
com.healthmarketscience.rmiio
contents-CTS
Daemon
컨텐츠(contents) 배포 서버
com.acme.contents.contents
contents-DYN
Web
디바이스의 요청을 해석하고 인증을 처리하며,
컨텐츠 서버에 위젯, 컨텐츠 다운로드를 요청한다.
com.acme.contents.dynamic
contents-GW
Daemon
외부의 contents provider로부터 수신되는 컨텐츠를 데이터베이스
를 기록한다.
컨텐츠 파일들을 dynamic & static delivery server로 배포한다.
com.acme.contents.gw
contents-ADM
Web
컨텐츠, 사용자 등 contents 시스템 전반에 대한 관리를 수행한다.
com.acme.contents.admin
contents-RFS
Daemon
gateway 서버로부터 전송되는 파일들을 static & dynamic delivery
서버의 디렉토리에 저장하는 데몬.
com.acme.contents.rfs
contents-RLY
Daemon
KT 인증 서버와 SOAP 프로토콜을 통해 통신하며,
과금 요청을 처리하는 데몬
com.acme.contents.relay
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
36
Project library dependency
Libraries
commons-lang-2.3.jar
commons-logging-1.1.1.jar
log4j-1.2.15.jar
commons-io-1.4.jar
commons-beanutils-1.7.0.jar
commons-dbcp-1.2.2.jar
commons-pool-1.3.jar
commons-fileupload-1.2.1.jar
commons-codec-1.3.jar
ibatis-2.3.0.677.jar
ojdbc14.jar
struts2-core-2.0.11.1.jar
xwork-2.0.4.jar
ognl-2.6.11.jar
freemarker-2.3.8.jar
xwork-2.0.4.jar
xerces.jar
xercesImpl.jar
concurrent.jar
jcs-1.3.jar
DnPAuthCheck.jar
activation.jar
dom.jar
mail.jar
saaj-api.jar
saaj-impl.jar
sax.jar
xalan.jar
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
COM
CTS
DYN
GW
RFS
RLY
ADM
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
●
37
●
●
●
●
●
●
●
●
●
Project configrations
Configuration
type
Log4J
Description
File name
서비스 실행 시 발생하는 디버그, 경고,
오류 로그를 생성하는 Log4J 라이브러리
설정 파일
log4j.xml
Struts 2 Framework
스트럿츠 2 웹 프레임워크 설정
struts.xml
struts.properties
iBatis Framework
iBatis 데이터베이스 쿼리 프레임워크 설정
*sqlmap*.xml
COM
자바 캐시 시스템 설정
cache.ccf
contents properties
contents 시스템 서버 주소, 포트 등 네트워
크 설정 및 기타 설정
contents.properties
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
38
DYN
GW
RFS
RLY
ADM
●
●
●
●
●
●
●
●
Java Cache System
CTS
●
●
●
●
●
●
Deploy common module
{WORKSPACE}/{COMMON}/build.xml
contents-CTS
contents-RLY
contents-RFS
contents-GW
contents-DYN
contents-ADM
<project name=“Project common library“ basedir="." default=“all">
<property name="java.dir"
value="${basedir}/src" />
<property name="jar.file.path" value="${basedir}/contents-common.jar" />
<target name="deploy">
execute ANT build script
(delpoy jar file)
<jar destfile="${jar.file.path}">
<fileset dir="${classes.dir}"/>
</jar>
프로젝트 공통 라이브러리
<copy file="${jar.file.path}" todir="${basedir}/../contents-CTS/lib"/>
…… 생략 ……
utilities
file I/O
constants
<copy file="${jar.file.path}" todir="${basedir}/../contents-RLY/lib"/>
<delete file="${jar.file.path}"/>
SQL
map client
load
configuration
</target>
</project>
 시스템의 공통 라이브러리는 PRJ-COM 프로젝트에서 관리되며, 각 프로젝트에서 사용하기 위해서는 배포(deploy) 작업이 필요하다.
 공통 라이브러리에 추가, 변경 사항이 발생할 경우 ANT 빌드(build)를 수행하여 각 단위 프로젝트에 적용하는 작업을 수행해야 한다.
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
39
Deploy project
1. 최신 작업 파일 업데이트
{WORKSPACE}/scripts/build.xml
ant build-all
: 전체 프로젝트를 빌드(build)한다.
개발자 PC
CVS 서버
ant clean
2. 완성도 검사
컴파일 오류 확인.
: 모든 목적 파일(object files)을 삭제한다.
ant backup
3. 배포 실행
자원(resource) 업로드
: clean 태스크를 실행한 후,
워크스페이스 전체를 zip으로 압축한다.
개발 서버
[ant deploy] or [ant]
배포자
: 전체 프로젝트를 빌드(build)한 후,
4. 정상 동작 확인
Web Server & Daemon 재기동
각종 기능 오동작 여부 확인
로그 파일 점검
개발 서버로 배포한다. (기본)
ant javadoc
: javadoc help 파일을 작성한다.
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
40
System Architecture
Make Common Components
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
41
Prepared Actions (HanaAction)
ActionSupport
ServletRequestAware
SessionAware
StrutsStatics
HanaAction
+JSON_ERROR_RESULT
+JSON_NORMAL_RESULT
+JSON_REDIRECT_RESULT
+request
+session
+actionErrorList
+actionMap
+addActionMap()
+addActionError()
+service()
+getLoginSession()
 HanaAction은 struts framework ActionSupport를 상속하는 하나은행 인터넷뱅킹 시스템 내의 최상위 액션(action) 클래스이다.
 추상 클래스이며, 모든 구현 액션 클래스(concrete action class)는 HanaAction 클래스로부터 상속 되어야 한다.
 ServletRequestAware, SessionAware 인터페이스를 구현했기 때문에 인터셉터(interceptor)에 의해 session, request 속성이 자
동으로 설정된다.
 액션 실행 시 발생한 오류 목록은 actionErrorList, 결과(result)로 전송해야 할 데이터는 actionMap 속성에 기록한다.
 하위 클래스에서 비즈니스 로직(business logic)을 구현하기 위해서는 service() 추상 메소드를 구현해야 한다.
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
42
Prepared Actions (HanaBizAction)
HanaAction
ModelDriven
Preparable
Completable
HanaActionWiring
HanaBizAction
+certPolicyName
+service
+serviceId
+inputMsg
+outputMsg
+echo
-setTransErrors()
-echoService()
+execute()
#invoke()
 HanaBizAction은 전문 거래 서비스를 실행하는 클래스들을 위한 추상 클래스이다.
 모든 전문 거래 클래스(message transaction class)는 HanaBizAction 클래스로부터 상속 되어야 한다.
 Preparable, Completable 인터페이스를 구현했기 때문에 인터셉터(interceptor)에 의해 prepare(), comple() 메소드가 호출된다.
 ModelDriven 인터페이스를 구현했기 때문에 인터셉터에 의해 request 인자를 inputMsg 멤버 속성에 자동으로 설정(mapping) 한다.
 HanaActionWiring 인터페이스를 구현했기 때문에 인터셉터에 의해 서비스 객체가 자동 설정된다.
 전문 호출을 위해 service 객체와 service ID를 입력 받아야 한다. (struts.xml에 action 추가 시 인자로 설정)
 액션 설정 시 ‘echo = true’ 로 설정할 경우, 전문 거래를 수행하지 않고 echo 전문을 반환한다.
 하위 클래스에서 비즈니스 로직(business logic)을 추가하기 위해서는 service() 메소드를 재선언(override) 해야 한다.
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
43
Prepared Actions (HanaNormalAction)
HanaAction
HanaNormalAction
+execute()
 HanaNormalAction은 전문 거래 서비스를 실행하지 않는 클래스들을 구현하기 위한 추상 클래스이다.
 모든 비 전문거래 클래스(non message-transaction class)는 HanaNormalAction 클래스로부터 상속 되어야 한다.
하위 클래스에서 비즈니스 로직(business logic)을 추가하기 위해서는 service() 추상 메소드를 구현해야 한다.
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
44
Prepared Actions (DefaultBizAction)
HanaBizAction
DefaultBizAction
+execute()
 DefaultBizAction은 전문 거래 서비스 중 by-pass 패턴 전문을 처리하기 위한 구현 클래스(concrete class) 이다.
 비즈니스 로직을 구현할 필요한 없는 전문인 경우, DefaultBizAction 컴포넌트를 호출해야 한다.
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
45
Prepared Actions (Actions overview)
HanaAction
+JSON_ERROR_RESULT
+JSON_NORMAL_RESULT
+JSON_REDIRECT_RESULT
+request
+session
+actionErrorList
+actionMap
+addActionMap()
+addActionError()
+service()
+getLoginSession()
HanaBizAction
+certPolicyName
+service
+serviceId
+inputMsg
+outputMsg
+echo
HanaNormalAction
+execute()
-setTransErrors()
-echoService()
+execute()
#invoke()
 Struts 2 Action을 응용하는 방법은 3가지로 분류된다.
 첫째, 전문 거래를 포함하지 않는 서비스인 경우
HanaNormalAction 클래스를 상속한 클래스를 구현한다.
 둘째, 전문 거래를 실행하되, by-pass 성격인 경우
DefaultBizAction 클래스를 사용한다.
 셋째, 전문 거래를 실행하며, 전문 입출력 처리 중
부가적인 비즈니스 로직을 구현해야 할 경우
HanaBizAction 클래스를 상속한 클래스를 구현한다.
DefaultBizAction
+execute()
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
46
Prepared Interceptors
Struts components
TokenInterceptor
AbstractInterceptor
MethodFilterInterceptor
StrutsStatics
HanaBank interceptors
HanaTokenInterceptor
HanaInterceptor
CompleteInterceptor
CertInterceptor
RequireTransferInterceptor
HanaActionWiringInterceptor
RequireLoginInterceptor
TimeAcceptInterceptor
 하나은행 웹 서비스의 전처리(pre-processing)를 위해 스트럿츠 인터셉터를 확장(상속)한 인터셉터들을 구현한다.
 서비스 구현 시 스트럿츠 기본 인터셉터 스택(default stack)과 함께 사용된다.
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
47
Prepared Interceptors (description)
 HanaInterceptor
- 하나은행 인터셉터 구현을 위한 추상 클래스. 구현 클래스에서 필요한 유틸리티 메소드를 정의한다.
 HanaTokenInterceptor
- 이중 거래 방지를 위한 토큰 처리를 수행하는 인터셉터
 CertInterceptor
- 공인인증서 처리를 수행하는 인터셉터
 HanaActionWiringInterceptor
- Struts Action 컴포넌트에 service 컴포넌트를 삽입하는 인터셉터
 TimeAcceptInterceptor
- 거래 시간 제한을 수행하는 인터셉터. 허용된 거래 시간 외에 접속할 경우, REJECT_TIME 반환.
 RequiredLoginInterceptor
- 로그인 여부를 검사하는 인터셉터. 세션에 로그인 정보가 포함되어 있는지 검사한다.
 RequiredTransferInterceptor
- 거래 가능 여부를 검사하는 인터셉터. 세션에 저장된 거래 가능 상태를 확인한다.
 CompleteInterceptor
- 후처리(post processing) 인터셉터. 개별 action 클래스에 구현된 complete() 메소드를 호출한다.
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
48
Prepared Interceptors (configuration)
Struts 2
Configuration
<!-- 공통 설정 -->
<include file="/config/struts/hana-struts-default.xml"/>
{PRJ_HOME}/src/struts.xml
<interceptors>
root config file
<interceptor name="timeAccept"
class="com.hanabank….TimeAcceptInterceptor">
define interceptors &
interceptor stack
<param name="timeResource">accepttime-pbk.properties</param>
</interceptor>
….
 인터셉터 목록 및 인터셉터 스택은 ‘{PRJ_HOME}src/config/struts/hana-struts-default.xml’ 파일에 정의한다.
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
49
Prepared Interceptors (configuration)
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="hana-default" abstract="true" extends="struts-default">
인터셉터 정의 및
인자(param) 설정
<!-- INTERCEPTORS -->
<interceptors>
<interceptor name="timeAccept"
class="com.hanabank.ebk.channel.ibk.web.struts2.interceptor.TimeAcceptInterceptor">
<param name="timeResource">/properties/accepttime-pbk.properties</param>
</interceptor>
<interceptor name="requireLogin"
class="com.hanabank.ebk.channel.ibk.web.struts2.interceptor.RequireLoginInterceptor"/>
<interceptor name="requireTransfer"
class="com.hanabank.ebk.channel.ibk.web.struts2.interceptor.RequireTransferInterceptor"/>
<interceptor name="complete"
class="com.hanabank.ebk.channel.ibk.web.struts2.interceptor.CompleteInterceptor"/>
<interceptor name="actionWiring"
class="com.hanabank.ebk.channel.ibk.web.struts2.interceptor.HanaActionWiringInterceptor">
<param name="service">actionDefaultService</param>
</interceptor>
<interceptor name="hanaToken"
class="com.hanabank.ebk.channel.ibk.web.struts2.interceptor.HanaTokenInterceptor">
<param name="used">false</param>
</interceptor>
(계속)
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
50
Prepared Interceptors (configuration)
(계속)
<!-- hanaStack -->
<interceptor-stack name="hanaStack">
<interceptor-ref name="timer"/>
<interceptor-ref name="logger"/>
<interceptor-ref name="actionWiring"/>
<interceptor-ref name="defaultStack"/>
인터셉터 스택(stack) 정의
(설정 파일에서 나열된 순서대로 실행된다)
<interceptor-ref name="requireLogin"/>
<interceptor-ref name="hanaToken"/>
<interceptor-ref name="timeAccept" />
<interceptor-ref name="requireTransfer"/>
<interceptor-ref name="complete"/>
</interceptor-stack>
</interceptors>
<!-- DEFAULT INTERCEPTOR REF -->
기본 인터셉터 설정
(액션 선언 시 인터셉터를 지정하지 않으면,
hanaStack 인터셉터가 실행된다.)
<default-interceptor-ref name="hanaStack"/>
</package>
</struts>
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
51
Prepared Results (HanaJSONResult)
Result
HanaJsonResult
+NORMAL
+ERROR
+REDIRECT
+getEncoding()
+setDefaultEncoding()
+getExcludePropertiesList()
+setExcludeProperties()
+execute(ActionInvocation)
+getRoot()
+setRoot(String)
+getJsonType()
+setJsonType()
 액션의 실행 결과를 JSON(JavaScript Object Notation) 형식으로 출력하는 result 컴포넌트이다.
 HanaJsonResult 서비스 액션을 AJAX 방식으로 호출했을 때 실행된다.
 jsonType 속성은 NORMAL, ERROR, REDIRECT 등 3가지 값을 가질 수 있다.
- NORMAL 타입은 액션 실행 결과를 JSON 형식으로 반환 받고자 할 때 사용되며,
- ERROR 타입은 액션 실행 중 오류가 발생한 상황을 나타내며, 오류 메시지를 JSON 형식으로 반환한다. (global 선언)
- REDIRECT 타입은 액션 실행 결과, 웹 브라우저에서 redirect URL 기능을 실행해야 한다는 것을 의미하며, 이동할 URL을 반환한다.
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
52
Prepared Results (configuration)
Struts 2
Configuration
{PRJ_HOME}/src/struts.xml
<!-- 공통 설정 -->
<include file="/config/struts/hana-struts-default.xml"/>
<result-types>
root config file
<result-type name="tiles" class="org.apache.struts2.views.tiles.TilesResult"/>
define result type
….
</result-types>
….
<global-results>
<result name="jsonError" type="jsonError" />
<result name="jsonNormal" type="jsonNormal" />
….
</global-results>
 tiles, json 등 2 종류의 result type을 선언한다.
 액션 선언 시 result type을 지정하지 않을 경우, struts2에서 제공되는 JSP result type(default)이 적용된다.
 에러 처리 등 global result를 선언한다.
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
53
Prepared Results (configuration)
<result-types>
<result-type name="jsonError" class="com.hanabank.ebk.channel.ibk.web.struts2.result.HanaJSONResult">
<param name="jsonType">error</param>
<param name="root">actionErrorList</param>
</result-type>
<result-type name="jsonNormal" class="com.hanabank.ebk.channel.ibk.web.struts2.result.HanaJSONResult">
<param name="jsonType">normal</param>
<param name="root">actionMap</param>
</result-type>
<result-type name="jsonRedirect" class="com.hanabank.ebk.channel.ibk.web.struts2.result.HanaJSONResult" >
<param name="jsonType">redirect</param>
</result-type>
<result-type name="tiles" class="org.apache.struts2.views.tiles.TilesResult" />
</result-types>
<global-results>
<result name="jsonError" type="jsonError" />
<result name="jsonNormal" type="jsonNormal" />
<result name="jsonRedirect" type="jsonRedirect" />
</global-results>
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
54
How to make AJAX call
1. JHanaAjax instance 생성
When user click menu
- execute function
2. XmlHttpRequest 요청
3. Business
전문 송수신 및 비즈니스로직 수행.
javascript
Action
module
(execute)
USER
HTML page
(on Web Browser)
BT server
javascript
Result
module
(callback)
5. Render page
redraw section
Web Browser
4. Resonse
render text/html
or JSON formatted data
WAS server
 JHanaAjax.js (hana.JHanaAjax) 공통 모듈은 HttpXMLRequest(XHR)를 추상화한 prototype.js를 감싼 Wrapper 컴포넌트이다.
(요청 관리를 처리하는 hana.JHanaAjax class와 로그아웃 시점을 관리하는 hana.JHanaLogoutTimer class 등을 포함한다.)
 모든 HttpXMLRequest 요청은 JHanaAjax class 를 통해 호출되어야 한다.
 JHanaAjax class는 인스턴스 생성 시 ajax.responders.register의 onCreate, onComplete 함수를 오버라이드(override)하여
로딩 이미지, 이벤트 등록 및 해제, responder 해제, 타이머 초기화 등을 수행한다.
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
55
How to make AJAX call
Case 1 : 단순 치환 (replace division)
1. Reqeust service
execute ajaxCommSubmit()
Web Browser
menu
contents area
<div>
2. Redraw content
</div>
 ajaxCommSubmit() - 화면의 특정 컨텐츠 영역을 서버에서 전송 받은 HTML 페이지로 단순히 재구성(redraw) 하는 경우에 사용된다.
 Javascript 용법
var hanaAjax = new hana.JHanaAjax( ‘update element ID’, ‘ajax 통신 중 loading 표시 여부’, ‘update 영역에 mask layer 표시할 지 여부’);
hanaAjax.ajaxCommSubmit( ‘service URL', ‘form object’ );
 구현 예제
var hanaAjax = new hana.JHanaAjax(hanaBodyDiv, true, true);
hanaAjax.ajaxCommSubmit( pbk.APPLICATION_CONTEXT_ROOT + url, null );
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
56
How to make AJAX call
Case 2 : 치환 후 콜백 (replace & callback)
1. Reqeust service
execute ajaxCommSubmitCallback()
Web Browser
menu
contents area
<div>
2. Redraw content
callback
</div>
3. Execute callback
 ajaxCommSubmitCallback() - 단순한 화면 redraw는 ajaxCommSubmit()과 동일하나,
컨텐츠 redraw 후 추가로 callback 함수를 실행할 수 있다는 차이점이 있음.
예를 들면, 화면을 redraw한 후 바로 팝업 윈도우를 여는 기능을 구현할 수 있음.
 Javascript 용법
var hanaAjax = new hana.JHanaAjax( ‘update element ID’, ‘ajax 통신 중 loading 표시 여부’, ‘update 영역에 mask layer 표시할 지 여부’);
hanaAjax.ajaxCommSubmitCallback( ‘service URL', ‘form object’, ‘callback function’ );
 구현 예제
var hanaAjax = new hana.JHanaAjax(hanaBodyDiv, true, true);
hanaAjax.ajaxCommSubmitCallback(url, formObj, handleTransactSort);
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
57
How to make AJAX call
Case 3 : 순수 콜백 처리 (pure callback)
1. Reqeust service
execute ajaxSubmit()
Web Browser
menu
contents area
<div>
callback
</div>
2. Execute callback
3. Redraw content
 ajaxSubmit() - 액션의 응답 결과로 JSON(JavaScript Object Notation) 형식의 데이터가 콜백 함수로(callback function) 반환되며,
콜백 함수에 의해 컨텐트가 업데이트 된다.
 Javascript 용법
var hanaAjax = new hana.JHanaAjax( ‘update element ID’, ‘ajax 통신 중 loading 표시 여부’, ‘update 영역에 mask layer 표시할 지 여부’);
hanaAjax.ajaxSubmit( ‘service URL', ‘form object’, ‘sync or not’, ‘callback function’, ‘encoding type’ );
 구현 예제
hanaAjax = new hana.JHanaAjax(loginDiv, true, true);
hanaAjax.ajaxSubmit( pbk.APPLICATION_CONTEXT_ROOT + '/common/login/bizWcxLog1In.ebk',
formObj, true, callbackResult, 'EUC-KR‘ );
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
58
How to make Struts2 actions
Case 1 : 인덱스 페이지
 전체 초기 화면(main index page) 및 각 대메뉴 초기 화면(top menu index page).
 화면 전체가 로드(load)되므로, Tiles framework를 사용하여 화면 레이아웃(layout)을 구성한다.
Case 2 : 전문을 송수신 하지 않는 액션
 전문을 송수신하지 않지만, 비즈니스 로직을 구현해야 하는 액션.
Action 유형
Case 3 : 전문을 by-pass 하는 액션
 전문을 송수신 하지만 비즈니스 로직을 구현할 필요가 없는 액션
Case 4 : 전문 송수신 및 비즈니스 로직을 포함한 액션
 전문 송수신 전, 후에 비즈니스 로직을 포함해야 하는 액션.
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
59
How to make Struts2 actions
Case 1 : 인덱스 페이지
① 영역별 JSP 파일 생성
자바 스크립트 : pbk-banka.js
좌측 메뉴 : menu_left.jsp
바디 컨텐츠 : init_content.jsp
② Tiles 설정 추가
마스터 템플릿 상속하여 새로운 타일을 등록한다.
Tiles configuration : {PRJ_HOME}/src/config/struts/tiles-pbk.xml
<!-- <![CDATA[ 마스터 템플릿. ]> -->
<definition name="pbk.master" template="/WEB-INF/layout/template_master.jsp">
<put-attribute name="title" value="마스터" />
속성 재정의
<put-attribute name="javascript" value="/resource/js/blank.js" />
<put-attribute name="hanaTop" value="/common/pbk_common_top.jsp" />
<put-attribute name="hanaLeft" value="/common/pbk_common_left.jsp" />
<!-- <![CDATA[ 마스터 보험. ]> -->
<put-attribute name="hanaContent" value="/common/clear_content.jsp" />
<definition name="pbk.master.banka" extends="pbk.master">
<put-attribute name="hanaFooter" value="/common/pbk_common_footer.jsp" />
<put-attribute name="title" value="하나은행 보험" />
<put-attribute name="hanaRight" value="/common/pbk_common_right.jsp" />
<put-attribute name="javascript" value="/resource/js/pbk-banka.js" />
</definition>
<put-attribute name="hanaTop" value="/WEB-INF/jsp/banka/menu_top.jsp" />
<put-attribute name="hanaLeft" value="/WEB-INF/jsp/common/menu_left.jsp" />
<put-attribute name="hanaContent" value="/WEB-INF/jsp/banka/init_content.jsp" />
</definition>
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
60
How to make Struts2 actions
Case 1 : 인덱스 페이지 (계속)
③ struts.xml 설정 추가
struts 2 configuration : {PRJ_HOME}/src/config/struts/struts-pbk-banka.xml
<package name="banka" extends="hana-default" namespace="/banka">
<action name="index">
<interceptor-ref name="basicStack" />
<result type="tiles">pbk.master.banka</result>
</action>
</package>
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
61
How to make Struts2 actions
Case 2 : 전문을 송수신 하지 않는 액션
① HanaNormalAction 클래스를 상속하는 액션 클래스 생성
-액션 클래스 생성 및 비즈니스 로직 구현
HanaNormalAction
ReqServiceAction
② Spring 설정 추가
-액션 클래스 등록
spring 2 configuration : {PRJ_HOME}/src/config/spring/applicationContext-struts.xml
<bean id=“reqServiceAction" scope="prototype"
class="com.hanabank.ebk.channel.pbk.web.struts2.action.service.ReqServiceAction"/>
③ Struts 설정 추가
-액션 클래스 등록
struts 2 configuration : {PRJ_HOME}/src/config/struts/struts-pbk-service.xml
<action name="reqService" class="reqService">
<interceptor-ref name="hanaStack">
<param name="timeAccept.time">301</param>
</interceptor-ref>
<result name="success">/service/req_service_result.jsp</result>
</action>
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
62
How to make Struts2 actions
Case 3 : 전문을 by-pass 하는 액션
전문 목록 수신
① 전문 도메인 객체(domain object) 생성 및 등록
- 전문 도메인 객체 클래스 소스를 자동 생성.
- Spring 설정에 전문 도메인 객체를 등록.
전문 도메인 객체 일괄 생성
NeoFrame - 전문 저장소
※ 전문 도메인 객체 생성 일괄 작업은 개발 리더가 수행한다.
② Struts 설정 추가
-액션 클래스 등록
struts 2 configuration : {PRJ_HOME}/src/config/struts/struts-pbk-service.xml
<action name="bizWpx1414" class="defaultBizAction">
<interceptor-ref name="hanaStack">
<param name="actionWiring.serviceId">TK01.WBP_1414</param>
<param name="actionWiring.inputMsg">wbp1414Input</param>
</interceptor-ref>
<result name="success">/biz/biz_result.jsp</result>
</action>
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
63
How to make Struts2 actions
Case 4 : 전문 송수신 및 비즈니스 로직을 포함한 액션
전문 목록 수신
① 전문 도메인 객체(domain object) 생성 및 등록
- 전문 도메인 객체 클래스 소스를 자동 생성.
- Spring 설정에 전문 도메인 객체를 등록.
전문 도메인 객체 일괄 생성
NeoFrame - 전문 저장소
※ 전문 도메인 객체 생성 일괄 작업은 개발 리더가 수행한다.
② HanaBizAction 클래스를 상속하는 액션 클래스 생성
-액션 클래스 생성 및 비즈니스 로직 구현
HanaBizAction
WcxLog1InAction
② Spring 설정 추가
-액션 클래스 등록
spring 2 configuration : {PRJ_HOME}/src/config/spring/applicationContext-struts.xml
<bean id=“wcxLog1InAction" scope="prototype"
class="com.hanabank.ebk.channel.pbk.web.struts2.action.login.WcxLog1InAction"/>
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
64
How to make Struts2 actions
Case 4 : 전문 송수신 및 비즈니스 로직을 포함한 액션
④ Struts 설정 추가
-액션 클래스 등록
struts 2 configuration : {PRJ_HOME}/src/config/struts/struts-pbk-common.xml
<action name="bizWcxLog1In" class="wcxLog1InAction">
<interceptor-ref name="hanaStack">
<param name="actionWiring.serviceId">TK01.WCX_LOG1.D01</param>
<param name="actionWiring.inputMsg">wcxLog1Input</param>
</interceptor-ref>
<result name="success">/common/clear_content.jsp</result>
</action>
오픈 소스 프레임워크 기반 웹 어플리케이션 제작
65