오픈소스 프레임워크 기반 웹 서비스 설계 (example)
TRANSCRIPT
This report is written by Sunny Kwak. ([email protected], sunnykwak.egloos.com)
2008.11.02
오픈 소스 프레임워크 기반
웹 어플리케이션 개발
Version 0.1
2오픈 소스 프레임워크 기반 웹 어플리케이션 제작
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
3오픈 소스 프레임워크 기반 웹 어플리케이션 제작
Standard Annotations
업무 구분 ( 영역 )
업무 묶음 혹은 서버
소프트웨어 컴포넌트 블럭
Framework 컴포넌트 솔루션 컴포넌트
Framework 모듈 솔루션 모듈
Module
Component
Module
新 컴포넌트
新 모듈
Component
Module
Component
[ 서비스 분할 ] [ 컴포넌트 유형 ]
네트워크 어댑터
[ 네트워크 및 서비스 흐름 ]
데이터 통신
서비스 호출
Database orRepository
[ 서버 및 저장소 ]
서버
4오픈 소스 프레임워크 기반 웹 어플리케이션 제작
What is Good ?
What’s Good, What is Better
Solution?
5오픈 소스 프레임워크 기반 웹 어플리케이션 제작
What is Good? – 좋은 시스템의 요건
생산성
성능 및
안정성신뢰성
6오픈 소스 프레임워크 기반 웹 어플리케이션 제작
What is Bad? – 관습적 개발 방식의 문제점들
Copy & Paste !!! - 소스 코드의 반복
- 모든 페이지에 반복적인 소스 코드 삽입
뉴스 게시판 공지사항 게시판
소스분량 및 작업시간 증가 유지보수의 어려움
7오픈 소스 프레임워크 기반 웹 어플리케이션 제작
What is ? – 기존 개발 방식의 문제점들
[ 정확한 소스 ] [ 잘못된 소스 ]
코드 불일치
코드 누락 시 문제 발생 System Down !!!
개발자의 어쩔 수 없는 실수 유발
- 인간이기 때문에…
- 복사하면서 누락하거나 , 개선된 사항을 과거의 코드에 반영하지 못하거나 ... 밤샘을 하던가…
8오픈 소스 프레임워크 기반 웹 어플리케이션 제작
What is Bad? – 기존 개발 방식의 문제점들
기존 웹 프레임 워크 (MVC)
Servlet, JSP
request response
서비스 요청 자동화기기
PDA
WEB
Web 종속 타 채널 적용 불가
서비스 다양화를 위한 인력 , 시간 , 비용 증가
특정 환경에 종속적인 구조 설계 - 하지만 , 서비스 플랫폼은 끓임 없이 변화하고
- 동일한 서비스 혹은 비즈니스인데도 불구하고 다시 개발하는 불상사 발생
9오픈 소스 프레임워크 기반 웹 어플리케이션 제작
What is Bad? – 기존 개발 방식의 문제점들
• 코드의 증가로 인한 자원 낭비
회원 게시판 LINK 게시판 일반 게시판
• 개발자의 작업량 증가로 생산성 저하 및 개발 시간 연장
똑같은 작업의 무한 반복 - 프로젝트가 진행되고 , 서비스가 성공할 수록 오히려 해야 할 일들은 증가…
- 생산성은 오히려 떨어지고 … 몇 년 후에는 아예 다시 설계하게 되고 …- 그리고 , 상사의 질책과 야근은 늘어가고… 엄마가 보고 싶을 뿐이고… ( 왜 저를 낳으셨나요 ?)
10오픈 소스 프레임워크 기반 웹 어플리케이션 제작
What is Good? – Open source framework
SI Frame-work
• 대형 SI 업체가 SI 프로젝트 목적으로 제작
• 기술 지원에 대한 의존성이 높고 범용성이 떨어짐
상용 Frame-work
• 고가의 구매 비용
• 커스터마이징의 어려움
Framework 구성 요건
플랫폼 독립적이고 Layer 의 구분이 명확한 아키텍처
실제 프로젝트에서 생산성이 검증된 개발도구 지원
표준기술 준수로 각종 솔루션 및 업무 시스템과의 유연한 연계
상용
Framework
SI Framewo
rk
오픈소스
Framework
Reasonable Proof
11오픈 소스 프레임워크 기반 웹 어플리케이션 제작
What is Good? – Struts 2
Simple view vs Detail View
Struts 2 는 MVC(Model View Controller) 모델을 구현하는 프레임워크 .
내부적으로 WebWork 2 의 아키텍처를 수용하여 견고하고 확장성이 높은 구조로 설계되어 있다 .
12오픈 소스 프레임워크 기반 웹 어플리케이션 제작
What is Good? – Struts 2
관습적인 MVC Project
Interceptor 설정을 통해 기존의 반복된 소스 코드 작성을 대체한다 .
서비스 전 , 후에 실행되므로 각 페이지에 반복된 소스 삽입 불필요
Struts2 based Project
설정파일이 제공되므로 , 유지보수 및 개발의편의성 제공
설정파일이 제공되므로 , 유지보수 및 개발의 편의성 제공
13오픈 소스 프레임워크 기반 웹 어플리케이션 제작
What is Good? – Spring 2
CoreThe IoC container
DAOSpring JDBCTransaction manageme
nt
ORMHibernate
JPATopLink
JDOOJB
iBatis
AOPSpring AOP
AspectJ integration
JEEJMXJMSJCA
RemotingEJBs
WebSpring Web MVC
Framework IntegrationWebWorkTapestry
JSFRich View Support
JSPsVelocity
FreeMarkerPDF
Jasfer ReportsExcel
Spring Portlet MVC
Lightweight - 적은 시스템 자원 소모 (1MB 정도의 적은 JAR 크
기 ) - 무시해도 되는 수준의 성능 부하
- 어플리케이션이 프레임워크에 종속되지 않음 . ( 침입적이지 않은 아키텍쳐 )
IoC (Inversion of Control) - 제어 역행 기법을 통해 컴포넌트 간의 느슨한 결합
(loosely couple component) 구현
AOP (Aspect Oriented Programming) - 관점 지향 개발을 통해 비즈니스 로직 구현에 집중
가능
- 서비스 실행 시 필요한 부가 기능을 설정 파일로
추가 . ( 로그 생성 , 프로파일링 기능 적용 용이 )
Container - 객체의 생명 주기와 객체들 간의 관계를 제어
- XML 설정 파일을 통해 선언적으로 컴포넌트 구성
14오픈 소스 프레임워크 기반 웹 어플리케이션 제작
What is Good? – Spring 2
Spring Framework 를 활용하여 타 채널 (Mobile, PDA….) 에서 재사용 가능한 컴포넌트 구현 가능
가능
불가능
PDA
기존 웹 프레임 워크 (MVC)
Servlet, JSPWEB
Struts2 + Spring2 프레임워크
request response
서비스 요청
ServiceHandler
ServiceAction
Application Server
SpringFramework
StrutsFramework
Presentation Layer System
개발 시간 단축 및 개발 생산성 , 효율성 제공
Mobile
15오픈 소스 프레임워크 기반 웹 어플리케이션 제작
What is Good? – Struts 2 + Spring 2
MVC Project
Web Request
Action(injected)
Result
Struts2 + Spring2 Project
Interceptor(s)
자원 낭비 감소 , 유지보수 편리성 , 개발 작업량 감소
동일한 패턴의 반복적인 코드들을 하나의 모듈로 통합
16오픈 소스 프레임워크 기반 웹 어플리케이션 제작
What is Good? – Struts 2 + Spring 2 + iBatis
왜 2 가지 이상의 프레임워크를 함께 사용하는가 ?
Struts 2 Framework
• 웹 어플리케이션을 위한 적절한 제어 구조
및 컴포넌트가 충분히 확보되어 있다 . ( 인터셉터 , 리절트 )
• Tiles 등 UI 프레임워크와의 조합이 유연하다 .• 단점은 웹 환경에 종속적이라는 것이다 .
Spring 2 Framework
• 컴포넌트 생명 주기 및 관계 제어를 통한 결합도 하향
• 비즈니스 컴포넌트를 재활용할 수 있게 한다 .• 선언적 프로그래밍 가능 .
iBatisFramework
• 쿼리를 비즈니스 코드와 분리하여 선언 / 관리 가능
• 환경 설정 파일을 통한 직관적인 구성
• 진정한 OR Wrapper 는 아니지만 ,쿼리 최적화가 필요한 환경에서는 보다 유리함 .
Framework 설계 요건
프레임워크 설계 시에도
낮은 결합도 추구
은 탄환 (silver bullet) 은 없다 .완벽한 프레임워크도 없다 .
SpringFramewo
rk
Struts 2 Framewo
rk
UI, business, repository 등계층 별로 적절한 프레임워크 선정
iBatisFramewo
rk
재사용성을 극대화하고 ,가시성을 높일 수 있다 .
설계 및 교육에 따르는 비용 증가
지나치면 모자라는 것보다 못함
17오픈 소스 프레임워크 기반 웹 어플리케이션 제작
What is Good? – Struts 2 + Spring 2
MVC Project
4.2 query
1.request 2.Get Instance
3.request
4.1 Call function5.response
JSP
JSPJSPJSPBean
DB
Struts2 + Spring2 Project
Struts dispatche
r
Spring Container
build components(dependency injection)
Service Componen
tStruts Action
DB
MVC Project Struts2 + Spring2 Project유지보수 개발 패턴의 반복 삽입으로 인한 유지보수 어려움 Interceptor 설정을 통한 유지보수 편리
재사용성 타 채널에서 재사용 불가 타 채널에서 재사용 가능
개발 생산성 서비스 별 동일한 프로세스 생성으로 인한 개발 생산성 감소
하나의 통합된 모듈을 구현함으로써 개발생산성 증대
18오픈 소스 프레임워크 기반 웹 어플리케이션 제작
System Architecture
Open Source Framework based
System Architecture
19오픈 소스 프레임워크 기반 웹 어플리케이션 제작
웹 어플리케이션 구성도
비즈니스 컴포넌트 Pool
서비스
클라이언트
Mobile
PDA
PC
TV
메신저
웹 어플리케이션 시스템
J2EE Framework 공통 컴포넌트
예외처리 다국어 로그 메시지 JDBC Routing
ServiceDispatcher
로그인체크
회원정보조회
서비스실행
ServiceController
Legacy
Systems
서비스 DB
Biz.컴포넌트
TCP/IP
XML
RequestXML
Response XML
RequestData Object
TCP/IP
XML
RMI/IIOP
XML Parser
20오픈 소스 프레임워크 기반 웹 어플리케이션 제작
웹 어플리케이션 구성도 (RMI based system example)
Dynamic Delivery Server Dynamic Contents DeliveryServer
Spring 2 & iBatisFramework
HTTP, 80 port
RMI,9001 port
Contents & ProfileDatabase
Contents Provider Gateway
Oracle Database
Admin Center Server
Relay Server
CP Gateway(Web Application Server)
Contents Publisher(RMI Client)
Apache Tomcat Server
Action(RMI client)
Request Parser(HTTP client)
Admin Center(Web Application Server)
JDBC, 1521 port
Relay Server(Web Application Server)
Query Handler(DB client)
Content Provider(RMI server)
Billing Manager(HTTP client)
Remote File Server
RMI, 9003 port
RMI,9004 port
IP : 192.17.10.49 IP : 19217.10.50
IP 192.17.10.51
21오픈 소스 프레임워크 기반 웹 어플리케이션 제작
Service flow overview
사용자
Internet Ex-plorer
orFirefox
방화벽Web Ap-plicationServer
form submit
or Ajax call
Struts dis-
patcher
Spring Container
build components(dependency injection) Struts 2
ActionMessage
Object
MessageHandler
ServiceID
Persis-tenceLayer
Legacy Systems
BusinessService Compo-
nent
22오픈 소스 프레임워크 기반 웹 어플리케이션 제작
Open Source Framework architecture
Service (Biz.) LayerUI Layer
J2SE 6.0 (SUN JDK 1.6)
J2EE 6
JSP 2.0 (EL) POJO
Web Application Server (JEUS, Web Logic, ETC)
JSTL 1.1 Custom Tags Ajax Spring Bean
UI Framework(Struts 2)
Service Framework(Spring 2.0)
Interceptors Action Dependency Injection
Result Struts Tags
Web Common Framework
Message Handling Session Management
Security
Constants & Configuration
LoggingException HandlingUtilities (String, Date)
(Infrastructure)
(Biz Compo-nents)
Bean Management
23오픈 소스 프레임워크 기반 웹 어플리케이션 제작
Struts 2 & Spring 2 service flow
Struts 2Dipatcher
Web Request
Interceptor(s)
Struts 2 default &Custom intercep-
torLoad Injected
Action & components
ExecuteDependency Injec-
tion
applicationContext.xml
struts.xml
SpringContext Loader
Action(injected)
MessagingService
ResultRender JSP or
JSON
Form submit or Ajax call
HTML, Excel orJSON formatted
data ORWrapper
Database
ExecuteQuery
24오픈 소스 프레임워크 기반 웹 어플리케이션 제작
All needed framework & libraries
Library Group Jar File Name Description
Apache Com-mons(http://common-s.apache.org/)
commons-lang-2.3.jar 자바 표 준 JDK 의 java.lang 패키 지 에 있 는 기 능 을 확 장 하 고 편리하게 만든 패키지 .
commons-logging-1.1.1.jar 다양한 로깅 (logging) API 구현체에 대한 래퍼 (wrapper)commons-io-1.4.jar I/O 처리를 간편하게 해주는 패키지commons-beanutils-1.7.0.jar 빈 (bean) 접근을 간편하게 해주는 패키지commons-dbcp-1.2.2.jar 데이터베이스 커넥션 풀 관리 라이브러리commons-pool-1.3.jar 풀 (pool) 관리 라이브러리commons-fileupload-1.2.1.jar 파일 업로드 라이브러리commons-codec-1.3.jar CODEC 라이브러리
Log4J log4j-1.2.15.jar Log4J 로그 생성 라이브러
iBatis ibatis-2.3.0.677.jar iBatis 데이터베이스 쿼리 프레임워크
Oracle JDBC driver
ojdbc14.jar 오라클 JDBC 드라이버
Struts 2 Frame-work
struts2-core-2.0.11.1.jar 스트럿츠 2 프레임워크xwork-2.0.4.jarognl-2.6.11.jarfreemarker-2.3.8.jar
Xerces xerces.jar XML 파서 (parser)xercesImpl.jar
25오픈 소스 프레임워크 기반 웹 어플리케이션 제작
Framework library configuration – Log4j
<?xml version="1.0" encoding="UTF-8" ?>
<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>
<appender name="FILEAPPENDER" class="org.apache.log4j.RollingFileAppender"> <param name="append" value="false" />
<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>
<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>
{PROJECT-HOME}/src/log4j.xml
로그 파일 저장 경로 및 파일 명칭 지정
로그 파일 크기는 10MB 로 지정하였으며 , 변경 가능
최대 백업 횟수는 10 회
com.acme 패키지 및 하위 패키지에 포함된 클래스에서 생성되는 로그는 DEBUG 레벨까지 기록
26오픈 소스 프레임워크 기반 웹 어플리케이션 제작
Framework library configuration – Java Cache System
jcs.default=jcs.default.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributesjcs.default.cacheattributes.MaxObjects=2000jcs.default.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCachejcs.default.elementattributes=org.apache.jcs.engine.ElementAttributesjcs.default.elementattributes.IsEternal=falsejcs.default.elementattributes.MaxLifeSeconds=300
{PROJECT_HOME}/src/cache.ccf
JCS(Java Cache System) 라이브러리를 위한 설정 파일이다 .
최대 2000 개의 객체를 캐시 (cache) 내에 저장하며 , LRU(Lead Recently Used) 메모리 캐시 알고리즘을 사용한다 .
디스크 등 외부 캐시를 사용하지 않고 , 캐시에 저장된 객체의 유효 기간 ( 생명 주기 ) 는 5 분으로 설정하였다 .
27오픈 소스 프레임워크 기반 웹 어플리케이션 제작
Framework library configuration – iBatis
driver=oracle.jdbc.driver.OracleDriverurl=jdbc:oracle:thin:@128.13.223.13:1521:MPDBusername=DBUSERpassword=DBUSER
{PROJECT_HOME}/src/sqlmap-config.properties
시스템에서 데이터베이스에 접근하기 위해 iBatis 프레임워크를 사용한다 .
데이터베이스 접근을 공통화 하기 위해 DB 연결을 위한 설정 파일은 공통 (common) 프로젝트에 포함시켰으며 ,
개별 프로젝트에서 사용하는 쿼리는 프로젝트 별로 설정 파일을 작성한다 .
28오픈 소스 프레임워크 기반 웹 어플리케이션 제작
Framework library configuration – iBatis (continue)
<?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 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>
{PROJECT_HOME}/src/config/sql-map/sqlmap-config.xml
데이터베이스 접근을 위한
계정 및 암호는 공통 설정 파일을 참조한다 .
쿼리를 포함하는 설정 파일을 기능 단위 별로
작성하며 , sqlmap-config.xml 파일에서 참조
(include) 한다 .
29오픈 소스 프레임워크 기반 웹 어플리케이션 제작
WAS startup process
1) WebLogic Startup
2) Read web.xml
WEB-INF/web.xml
Struts dispatcher
Spring Container
<filter> <filter-name>struts2</filter-name> <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class></filter>
<listener> <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class></listener>
3) Initialize Struts 2 framework
4) Initialize Spring 2 framework
Tiles setting listener<listener> <listener-class>org.apache.tiles.web.startup.TilesListener</listener-class></listener>
5) Initialize Tiles framework
<listener> <listener-class>com.acmeweb.listener.CustomSessionListener</listener-class></listener>
6) Initialize listener
30오픈 소스 프레임워크 기반 웹 어플리케이션 제작
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)
31오픈 소스 프레임워크 기반 웹 어플리케이션 제작
Web Application Configuration files (Struts 2)
{PROJECT_HOME}/src/struts.xml
<!-- 공통 설정 --><include file="/config/struts/Han-struts-default-.xml"/>
<!-- 대메뉴별 메뉴 설정 --><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
Struts 2Configuration
root config file
{PRJOECT_HOME}/src/config/struts/struts-pbk-card.xmlinclude sub-menu config files
{PRJ_HOME}/src/struts.xml 파일은 ‘스트럿츠 루트 설정’ 파일이며 , 가장 먼저 로딩된다 . ( 스트럿츠 프레임워크는 CLASS_PATH 에 등록된 경로를 스캔하여 , struts.xml 파일을 찾는다 .)
공통 (global) 설정 항목은 ‘ /config/struts/Han-struts-default.xml’ 파일에 정의한다 .
각 메뉴 ( 혹은 서비스 ) 별 액션 설정은 대메뉴별로 구분하여 설정 디렉토리에 등록하며 , struts.xml 설정 파일에서 포함 (include) 시킨다 .
32오픈 소스 프레임워크 기반 웹 어플리케이션 제작
Web Application Configuration files (Tiles)
WEB-INF/web.xml
<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>
TilesConfiguration
set configuration files location
{PRJECT_HOME}/src/config/struts/tiles-pbk.xml
declare spring config location
Tiles 설정 파일 위치는 ‘WEB-INF/web.xml’ 파일에서 선언한다 .
33오픈 소스 프레임워크 기반 웹 어플리케이션 제작
Web Application configuration files (Spring 2)
WEB-INF/web.xml
<context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:config/spring/applicationContext-*.xml</param-value></context-param>
Spring 2Configuration
set configuration files location
{PRJECT_HOME}/src/config/spring/applicationContext-rule.xmldeclare spring config location
{PRJECT_HOME}/src/config/spring/applicationContext-service.xml
{PRJECT_HOME}/src/config/spring/applicationContext-struts.xml
스프링 설정 파일 위치는 ‘WEB-INF/web.xml’ 파일에서 선언한다 .
스프링 설정 파일은 3 개의 영역으로 분리하여 작성한다 .
applicationContext-rule.xml : 입력 전문 빈 ( 도메인 객체 ) 을 설정한다 . applicationContext-service.xml : 전문 (message) 송수신을 처리하는 서비스 빈 ( 컴포넌트 ) 을 설정한다 . applicationContext-struts.xml : 스트럿츠 액션 빈 ( 컴포넌트 ) 을 설정한다 .
34오픈 소스 프레임워크 기반 웹 어플리케이션 제작
System Architecture
Workspace, Project, Build & Deploy
35오픈 소스 프레임워크 기반 웹 어플리케이션 제작
Workspace & projects
workspace01
contents-COM
contents-RMIIO
contents-CTS
contents-DYN
contents-GW
contents-ADM
contents-RFS
contents-RLY
project
contents 공통 라이브러리
RMI File Transfer Library
Contents Delivery Server
Dynamic Delivery Server
Gateway Server
Admin Server
Remote File Server
Relay Server
contents-DYN
contents-CTS contents-GW
contents-ADM
contents-COM
contents-RMIIO
contents-RFScontents-RLY
36오픈 소스 프레임워크 기반 웹 어플리케이션 제작
Common project root
src
• 자바 소스 파일들이 위치한다 .
web
• HTML, JSP, Image, Javascript 파일들이 위치한다 .
• 만일 해당 프로젝트가 웹 프로젝트 아니라면 , web 디렉토리 자체가 존재하지 않는다 .
bin
• 목적 파일 (object 파일 ) 들이 위치한다 .
cmd
• 서비스 실행 및 종료를 위한 스크립트 파일들이 위치한다 .
• 데몬(daemon) 프로젝트가 아니라면 , 디렉토리 자체가 존재하지 않는다 .
lib
• 참조 라이브러리 (reference library) 들이 위치한다 .
build.xml
• 프로젝트 컴파일 , 배포 등을 위한 ant 빌드 스크립트 파일이다 .
Project Root
37오픈 소스 프레임워크 기반 웹 어플리케이션 제작
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
38오픈 소스 프레임워크 기반 웹 어플리케이션 제작
Project library dependency
Libraries COM CTS DYN GW RFS RLY ADMcommons-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 ●
39오픈 소스 프레임워크 기반 웹 어플리케이션 제작
Project configrations
Configuration type Description File name COM CTS DYN GW RFS RLY ADM
Log4J 서비스 실행 시 발생하는 디버그 , 경고 , 오류 로그를 생성하는 Log4J 라이브러리 설정 파일
log4j.xml● ● ● ● ● ●
Struts 2 Framework 스트럿츠 2 웹 프레임워크 설정 struts.xmlstruts.properties ● ●
iBatis Framework iBatis 데이터베이스 쿼리 프레임워크 설정 *sqlmap*.xml● ● ● ●
Java Cache System 자바 캐시 시스템 설정 cache.ccf ●contents properties contents 시스템 서버 주소 , 포트 등
네트워크 설정 및 기타 설정contents.proper-ties ●
40오픈 소스 프레임워크 기반 웹 어플리케이션 제작
Deploy common module
프로젝트 공통 라이브러리
utilities
contents-CTS
file I/O constants
SQLmap client
loadconfiguration
execute ANT build script
(delpoy jar file)
<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"> <jar destfile="${jar.file.path}"> <fileset dir="${classes.dir}"/> </jar>
<copy file="${jar.file.path}" todir="${basedir}/../contents-CTS/lib"/> …… 생략 ……
<copy file="${jar.file.path}" todir="${basedir}/../contents-RLY/lib"/> <delete file="${jar.file.path}"/>
</target> </project>
{WORKSPACE}/{COMMON}/build.xml
시스템의 공통 라이브러리는 PRJ-COM 프로젝트에서 관리되며 , 각 프로젝트에서 사용하기 위해서는 배포 (deploy) 작업이 필요하다 .
공통 라이브러리에 추가 , 변경 사항이 발생할 경우 ANT 빌드 (build) 를 수행하여 각 단위 프로젝트에 적용하는 작업을 수행해야 한다 .
contents-RLY contents-RFS
contents-GW contents-DYN contents-ADM
41오픈 소스 프레임워크 기반 웹 어플리케이션 제작
Deploy project
개발자 PC
개발 서버
CVS 서버
1. 최신 작업 파일 업데이트
2. 완성도 검사 컴파일 오류 확인 .
3. 배포 실행 자원 (resource)
업로드
배포자4. 정상 동작 확인 Web Server & Daemon 재기동 각종 기능 오동작 여부 확인 로그 파일 점검
ant build-all : 전체 프로젝트를 빌드 (build) 한다 .
ant clean : 모든 목적 파일 (object files) 을 삭제한다 .
ant backup : clean 태스크를 실행한 후 , 워크스페이스 전체를 zip 으로 압축한다 .
[ant deploy] or [ant]
: 전체 프로젝트를 빌드 (build) 한 후 , 개발 서버로 배포한다 . ( 기본 )
ant javadoc
: javadoc help 파일을 작성한다 .
{WORKSPACE}/scripts/build.xml
42오픈 소스 프레임워크 기반 웹 어플리케이션 제작
System Architecture
Make Common Components
43오픈 소스 프레임워크 기반 웹 어플리케이션 제작
Prepared Actions (HanAction)
ActionSupportServletRequestAware SessionAware StrutsStatics
HanaAction
+J SON_ERROR_RESULT+J SON_NORMAL_RESULT+J SON_REDIRECT_RESULT+request+session+actionErrorList+actionMap+addActionMap()+addActionError()+service()+getLoginSession()
HanAction 은 struts framework ActionSupport 를 상속하는 웹 시스템 내의 최상위 액션 (action) 클래스이다 .
추상 클래스이며 , 모든 구현 액션 클래스 (concrete action class) 는 Hanction 클래스로부터 상속 되어야 한다 .
ServletRequestAware, SessionAware 인터페이스를 구현했기 때문에 인터셉터 (interceptor) 에 의해 session, request 속성이 자동으로
설정된다 .
액션 실행 시 발생한 오류 목록은 actionErrorList, 결과 (result) 로 전송해야 할 데이터는 actionMap 속성에 기록한다 .
하위 클래스에서 비즈니스 로직 (business logic) 을 구현하기 위해서는 service() 추상 메소드를 구현해야 한다 .
44오픈 소스 프레임워크 기반 웹 어플리케이션 제작
Prepared Actions (HanBizAction)
HanBizAction 은 전문 거래 서비스를 실행하는 클래스들을 위한 추상 클래스이다 .
모든 전문 거래 클래스 (message transaction class) 는 HanBizAction 클래스로부터 상속 되어야 한다 .
Preparable, Completable 인터페이스를 구현했기 때문에 인터셉터 (interceptor) 에 의해 prepare(), comple() 메소드가
호출된다 .
ModelDriven 인터페이스를 구현했기 때문에 인터셉터에 의해 request 인자를 inputMsg 멤버 속성에 자동으로 설정 (mapping) 한다 .
HanctionWiring 인터페이스를 구현했기 때문에 인터셉터에 의해 서비스 객체가 자동 설정된다 .
전문 호출을 위해 service 객체와 service ID 를 입력 받아야 한다 . (struts.xml 에 action 추가 시 인자로 설정 )
액션 설정 시 ‘ echo = true’ 로 설정할 경우 , 전문 거래를 수행하지 않고 echo 전문을 반환한다 .
하위 클래스에서 비즈니스 로직 (business logic) 을 추가하기 위해서는 service() 메소드를 재선언 (override) 해야 한다 .
HanaAction
HanaBizAction
+certPolicyName+service+serviceId+inputMsg+outputMsg+echo-setTransErrors()-echoService()+execute()#invoke()
ModelDriven Preparable Completable HanaActionWiring
45오픈 소스 프레임워크 기반 웹 어플리케이션 제작
Prepared Actions (HanNormalAction)
HanaAction
HanaNormalAction
+execute()
HanNormalAction 은 전문 거래 서비스를 실행하지 않는 클래스들을 구현하기 위한 추상 클래스이다 .
모든 비 전문거래 클래스 (non message-transaction class) 는 HanNormalAction 클래스로부터 상속 되어야 한다 .
하위 클래스에서 비즈니스 로직 (business logic) 을 추가하기 위해서는 service() 추상 메소드를 구현해야 한다 .
46오픈 소스 프레임워크 기반 웹 어플리케이션 제작
Prepared Actions (DefaultBizAction)
DefaultBizAction 은 전문 거래 서비스 중 by-pass 패턴 전문을 처리하기 위한 구현 클래스 (concrete class) 이다 .
비즈니스 로직을 구현할 필요한 없는 전문인 경우 , DefaultBizAction 컴포넌트를 호출해야 한다 .
HanaBizAction
DefaultBizAction
+execute()
47오픈 소스 프레임워크 기반 웹 어플리케이션 제작
Prepared Actions (Actions overview)
Struts 2 Action 을 응용하는 방법은 3 가지로 분류된다 .
첫째 , 전문 거래를 포함하지 않는 서비스인 경우
HanNormalAction 클래스를 상속한 클래스를
구현한다 .
둘째 , 전문 거래를 실행하되 , by-pass 성격인 경우
DefaultBizAction 클래스를 사용한다 .
셋째 , 전문 거래를 실행하며 , 전문 입출력 처리 중
부가적인 비즈니스 로직을 구현해야 할 경우
HanBizAction 클래스를 상속한 클래스를 구현한다 .
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-setTransErrors()-echoService()+execute()#invoke()
HanaNormalAction
+execute()
DefaultBizAction
+execute()
48오픈 소스 프레임워크 기반 웹 어플리케이션 제작
Prepared Interceptors
AbstractInterceptorStrutsStatics
HanaInterceptor
CertInterceptor
MethodFilterInterceptor
CompleteInterceptor
HanaActionWiringInterceptor
TokenInterceptor
HanaTokenInterceptor
RequireLoginInterceptor
RequireTransferInterceptor
TimeAcceptInterceptor
Struts components
Han interceptors
웹 서비스의 전처리 (pre-processing) 를 위해 스트럿츠 인터셉터를 확장 ( 상속 ) 한 인터셉터들을 구현한다 .
서비스 구현 시 스트럿츠 기본 인터셉터 스택 (default stack) 과 함께 사용된다 .
49오픈 소스 프레임워크 기반 웹 어플리케이션 제작
Prepared Interceptors (description)
HanInterceptor - 인터셉터 구현을 위한 추상 클래스 . 구현 클래스에서 필요한 유틸리티 메소드를 정의한다 .
HanTokenInterceptor - 이중 거래 방지를 위한 토큰 처리를 수행하는 인터셉터
CertInterceptor - 공인인증서 처리를 수행하는 인터셉터
HanctionWiringInterceptor - Struts Action 컴포넌트에 service 컴포넌트를 삽입하는 인터셉터
TimeAcceptInterceptor - 거래 시간 제한을 수행하는 인터셉터 . 허용된 거래 시간 외에 접속할 경우 , REJECT_TIME 반환 .
RequiredLoginInterceptor - 로그인 여부를 검사하는 인터셉터 . 세션에 로그인 정보가 포함되어 있는지 검사한다 .
RequiredTransferInterceptor - 거래 가능 여부를 검사하는 인터셉터 . 세션에 저장된 거래 가능 상태를 확인한다 .
CompleteInterceptor - 후처리 (post processing) 인터셉터 . 개별 action 클래스에 구현된 complete() 메소드를 호출한다 .
50오픈 소스 프레임워크 기반 웹 어플리케이션 제작
Prepared Interceptors (configuration)
{PRJ_HOME}/src/struts.xml
<!-- 공통 설정 --><include file="/config/struts/Han-struts-default-.xml"/>
Struts 2Configuration
root config file<interceptors> <interceptor name="timeAccept" class="com.Hanbank….TimeAcceptInterceptor"> <param name="timeResource">accepttime-pbk.properties</param> </interceptor> ….
define interceptors & interceptor stack
인터셉터 목록 및 인터셉터 스택은 ‘ {PRJ_HOME}src/config/struts/Han-struts-default.xml’ 파일에 정의한다 .
51오픈 소스 프레임워크 기반 웹 어플리케이션 제작
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="Han-default" abstract="true" extends="struts-default">
<!-- INTERCEPTORS --> <interceptors> <interceptor name="timeAccept" class="com.Hanbank.ebk.channel.ibk.web.struts2.interceptor.TimeAcceptInterceptor"> <param name="timeResource">/properties/accepttime-pbk.properties</param> </interceptor> <interceptor name="requireLogin" class="com.Hanbank.ebk.channel.ibk.web.struts2.interceptor.RequireLoginInterceptor"/> <interceptor name="requireTransfer" class="com.Hanbank.ebk.channel.ibk.web.struts2.interceptor.RequireTransferInterceptor"/> <interceptor name="complete" class="com.Hanbank.ebk.channel.ibk.web.struts2.interceptor.CompleteInterceptor"/> <interceptor name="actionWiring" class="com.Hanbank.ebk.channel.ibk.web.struts2.interceptor.HanctionWiringInterceptor"> <param name="service">actionDefaultService</param> </interceptor> <interceptor name="HanToken" class="com.Hanbank.ebk.channel.ibk.web.struts2.interceptor.HanTokenInterceptor"> <param name="used">false</param> </interceptor>
( 계속 )
인터셉터 정의 및인자 (param) 설정
52오픈 소스 프레임워크 기반 웹 어플리케이션 제작
Prepared Interceptors (configuration)
( 계속 ) <!-- HanStack --> <interceptor-stack name="HanStack"> <interceptor-ref name="timer"/> <interceptor-ref name="logger"/> <interceptor-ref name="actionWiring"/> <interceptor-ref name="defaultStack"/> <interceptor-ref name="requireLogin"/> <interceptor-ref name="HanToken"/> <interceptor-ref name="timeAccept" /> <interceptor-ref name="requireTransfer"/> <interceptor-ref name="complete"/> </interceptor-stack> </interceptors>
<!-- DEFAULT INTERCEPTOR REF --> <default-interceptor-ref name="HanStack"/>
</package>
</struts>
인터셉터 스택 (stack) 정의( 설정 파일에서 나열된 순서대로 실행된다 )
기본 인터셉터 설정(액션 선언 시 인터셉터를 지정하지 않으면 ,
HanStack 인터셉터가 실행된다 .)
53오픈 소스 프레임워크 기반 웹 어플리케이션 제작
Prepared Results (HanJSONResult)
액션의 실행 결과를 JSON(JavaScript Object Notation) 형식으로 출력하는 result 컴포넌트이다 .
HanJsonResult 서비스 액션을 AJAX 방식으로 호출했을 때 실행된다 .
jsonType 속성은 NORMAL, ERROR, REDIRECT 등 3 가지 값을 가질 수 있다 . - NORMAL 타입은 액션 실행 결과를 JSON 형식으로 반환 받고자 할 때 사용되며 , - ERROR 타입은 액션 실행 중 오류가 발생한 상황을 나타내며 , 오류 메시지를 JSON 형식으로 반환한다 . (global 선언 ) - REDIRECT 타입은 액션 실행 결과 , 웹 브라우저에서 redirect URL 기능을 실행해야 한다는 것을 의미하며 , 이동할 URL 을
반환한다 .
Result
HanaJ sonResult
+NORMAL+ERROR+REDIRECT+getEncoding()+setDefaultEncoding()+getExcludePropertiesList()+setExcludeProperties()+execute(ActionInvocation)+getRoot()+setRoot(String)+getJ sonType()+setJ sonType()
54오픈 소스 프레임워크 기반 웹 어플리케이션 제작
Prepared Results (configuration)
{PRJ_HOME}/src/struts.xml<!-- 공통 설정 --><include file="/config/struts/Han-struts-default-.xml"/>
Struts 2Configuration
root config file <result-types> <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" /> ….</global-results>
define result type
tiles, json 등 2 종류의 result type 을 선언한다 .
액션 선언 시 result type 을 지정하지 않을 경우 , struts2 에서 제공되는 JSP result type(default) 이 적용된다 .
에러 처리 등 global result 를 선언한다 .
55오픈 소스 프레임워크 기반 웹 어플리케이션 제작
Prepared Results (configuration)
<result-types>
<result-type name="jsonError" class="com.Hanbank.ebk.channel.ibk.web.struts2.result.HanJSONResult"> <param name="jsonType">error</param> <param name="root">actionErrorList</param></result-type>
<result-type name="jsonNormal" class="com.Hanbank.ebk.channel.ibk.web.struts2.result.HanJSONResult"> <param name="jsonType">normal</param> <param name="root">actionMap</param></result-type>
<result-type name="jsonRedirect" class="com.Hanbank.ebk.channel.ibk.web.struts2.result.HanJSONResult" > <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>
56오픈 소스 프레임워크 기반 웹 어플리케이션 제작
How to make AJAX call
HTML page(on Web Browser)
javascriptmodule
(execute)
When user click menu- execute function
USER
1. JHanjax instance 생성
2. XmlHttpRequest 요청
Action
Result
JHanjax.js (Han.JHanjax) 공통 모듈은 HttpXMLRequest(XHR) 를 추상화한 prototype.js 를 감싼 Wrapper 컴포넌트이다 . ( 요청 관리를 처리하는 Han.JHanjax class 와 로그아웃 시점을 관리하는 Han.JHanLogoutTimer class 등을 포함한다 .)
모든 HttpXMLRequest 요청은 JHanjax class 를 통해 호출되어야 한다 .
JHanjax class 는 인스턴스 생성 시 ajax.responders.register 의 onCreate, onComplete 함수를 오버라이드 (override) 하여
로딩 이미지 , 이벤트 등록 및 해제 , responder 해제 , 타이머 초기화 등을 수행한다 .
BT server
javascriptmodule
(callback)
4. Resonse render text/html or JSON formatted data
3. Business 전문 송수신 및 비즈니스로직 수행 .
5. Render page redraw section
Web Browser WAS server
57오픈 소스 프레임워크 기반 웹 어플리케이션 제작
How to make AJAX call
Case 1 : 단순 치환 (replace division)
execute ajaxCommSubmit()
Web Browser
menucontents area<div>
</div>
ajaxCommSubmit() - 화면의 특정 컨텐츠 영역을 서버에서 전송 받은 HTML 페이지로 단순히 재구성 (redraw) 하는 경우에 사용된다 .
Javascript 용법
var Hanjax = new Han.JHanjax( ‘update element ID’, ‘ajax 통신 중 loading 표시 여부’ , ‘update 영역에 mask layer 표시할 지 여부’ ); Hanjax.ajaxCommSubmit( ‘service URL', ‘form object’ );
구현 예제
var Hanjax = new Han.JHanjax(HanBodyDiv, true, true); Hanjax.ajaxCommSubmit( pbk.APPLICATION_CONTEXT_ROOT + url, null );
2. Redraw con-tent
1. Reqeust ser-vice
58오픈 소스 프레임워크 기반 웹 어플리케이션 제작
How to make AJAX call
Case 2 : 치환 후 콜백 (replace & callback)
execute ajaxCommSubmitCallback()
ajaxCommSubmitCallback() - 단순한 화면 redraw 는 ajaxCommSubmit() 과 동일하나 , 컨텐츠 redraw 후 추가로 callback 함수를 실행할 수 있다는 차이점이 있음 . 예를 들면 , 화면을 redraw 한 후 바로 팝업 윈도우를 여는 기능을 구현할 수 있음 .
Javascript 용법
var Hanjax = new Han.JHanjax( ‘update element ID’, ‘ajax 통신 중 loading 표시 여부’ , ‘update 영역에 mask layer 표시할 지 여부’ ); Hanjax.ajaxCommSubmitCallback( ‘service URL', ‘form object’, ‘callback function’ );
구현 예제
var Hanjax = new Han.JHanjax(HanBodyDiv, true, true); Hanjax.ajaxCommSubmitCallback(url, formObj, handleTransactSort);
Web Browser
menucontents area<div>
</div>callback
2. Redraw con-tent
1. Reqeust ser-vice
3. Execute call-back
59오픈 소스 프레임워크 기반 웹 어플리케이션 제작
How to make AJAX call
Case 3 : 순수 콜백 처리 (pure callback)
execute ajaxSubmit()
ajaxSubmit() - 액션의 응답 결과로 JSON(JavaScript Object Notation) 형식의 데이터가 콜백 함수로 (callback function) 반환되며 , 콜백 함수에 의해 컨텐트가 업데이트 된다 .
Javascript 용법
var Hanjax = new Han.JHanjax( ‘update element ID’, ‘ajax 통신 중 loading 표시 여부’ , ‘update 영역에 mask layer 표시할 지 여부’ ); Hanjax.ajaxSubmit( ‘service URL', ‘form object’, ‘sync or not’, ‘callback function’, ‘encoding type’ );
구현 예제
Hanjax = new Han.JHanjax(loginDiv, true, true); Hanjax.ajaxSubmit( pbk.APPLICATION_CONTEXT_ROOT + '/common/login/bizWcxLog1In.ebk', formObj, true, callbackResult, 'EUC-KR‘ );
1. Reqeust ser-vice
Web Browser
menucontents area<div>
</div>callback
3. Redraw con-tent
2. Execute call-back
60오픈 소스 프레임워크 기반 웹 어플리케이션 제작
How to make Struts2 actions
Case 1 : 인덱스 페이지
Case 2 : 전문을 송수신 하지 않는 액션
Case 3 : 전문을 by-pass 하는 액션
Case 4 : 전문 송수신 및 비즈니스 로직을 포함한 액션
Action 유형
전체 초기 화면 (main index page) 및 각 대메뉴 초기 화면 (top menu index page). 화면 전체가 로드 (load) 되므로 , Tiles framework 를 사용하여 화면 레이아웃 (layout) 을
구성한다 .
전문을 송수신하지 않지만 , 비즈니스 로직을 구현해야 하는 액션 .
전문을 송수신 하지만 비즈니스 로직을 구현할 필요가 없는 액션
전문 송수신 전 , 후에 비즈니스 로직을 포함해야 하는 액션 .
61오픈 소스 프레임워크 기반 웹 어플리케이션 제작
How to make Struts2 actions
Case 1 : 인덱스 페이지
Tiles configuration : {PRJ_HOME}/src/config/struts/tiles-pbk.xml
① 영역별 JSP 파일 생성
② Tiles 설정 추가 마스터 템플릿 상속하여 새로운 타일을 등록한다 .
자바 스크립트 : pbk-banka.js
좌측 메뉴 : menu_left.jsp
바디 컨텐츠 : init_content.jsp
<!-- <![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="HanTop" value="/common/pbk_common_top.jsp" /> <put-attribute name="HanLeft" value="/common/pbk_common_left.jsp" /> <put-attribute name="HanContent" value="/common/clear_content.jsp" /> <put-attribute name="HanFooter" value="/common/pbk_common_footer.jsp" /> <put-attribute name="HanRight" value="/common/pbk_common_right.jsp" /></definition>
<!-- <![CDATA[ 마스터 보험 . ]> --><definition name="pbk.master.banka" extends="pbk.master"> <put-attribute name="title" value=“ 보험 " /> <put-attribute name="javascript" value="/resource/js/pbk-banka.js" /> <put-attribute name="HanTop" value="/WEB-INF/jsp/banka/menu_top.jsp" /> <put-attribute name="HanLeft" value="/WEB-INF/jsp/common/menu_left.jsp" /> <put-attribute name="HanContent" value="/WEB-INF/jsp/banka/init_content.jsp" /></definition>
속성 재정의
62오픈 소스 프레임워크 기반 웹 어플리케이션 제작
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="Han-default" namespace="/banka"> <action name="index"> <interceptor-ref name="basicStack" /> <result type="tiles">pbk.master.banka</result> </action></package>
63오픈 소스 프레임워크 기반 웹 어플리케이션 제작
How to make Struts2 actions
Case 2 : 전문을 송수신 하지 않는 액션
HanNormalAction
ReqServiceAction
① HanNormalAction 클래스를 상속하는 액션 클래스 생성 -액션 클래스 생성 및 비즈니스 로직 구현
② Spring 설정 추가 -액션 클래스 등록
③ Struts 설정 추가 -액션 클래스 등록
spring 2 configuration : {PRJ_HOME}/src/config/spring/applicationContext-struts.xml
<bean id=“reqServiceAction" scope="prototype"
class="com.Hanbank.ebk.channel.pbk.web.struts2.action.service.ReqServiceAction"/>
struts 2 configuration : {PRJ_HOME}/src/config/struts/struts-pbk-service.xml
<action name="reqService" class="reqService">
<interceptor-ref name="HanStack">
<param name="timeAccept.time">301</param>
</interceptor-ref>
<result name="success">/service/req_service_result.jsp</result>
</action>
64오픈 소스 프레임워크 기반 웹 어플리케이션 제작
How to make Struts2 actions
Case 3 : 전문을 by-pass 하는 액션
① 전문 도메인 객체 (domain object) 생성 및 등록 - 전문 도메인 객체 클래스 소스를 자동 생성 . - Spring 설정에 전문 도메인 객체를 등록 .
② Struts 설정 추가 -액션 클래스 등록
struts 2 configuration : {PRJ_HOME}/src/config/struts/struts-pbk-service.xml
<action name="bizWpx1414" class="defaultBizAction">
<interceptor-ref name="HanStack">
<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>
NeoFrame - 전문 저장소
전문 도메인 객체 일괄 생성
전문 목록 수신
※ 전문 도메인 객체 생성 일괄 작업은 개발 리더가 수행한다 .
65오픈 소스 프레임워크 기반 웹 어플리케이션 제작
How to make Struts2 actions
Case 4 : 전문 송수신 및 비즈니스 로직을 포함한 액션
① 전문 도메인 객체 (domain object) 생성 및 등록 - 전문 도메인 객체 클래스 소스를 자동 생성 . - Spring 설정에 전문 도메인 객체를 등록 .
NeoFrame - 전문 저장소
전문 도메인 객체 일괄 생성
전문 목록 수신
※ 전문 도메인 객체 생성 일괄 작업은 개발 리더가 수행한다 .
HanBizAction
WcxLog1InAction
② HanBizAction 클래스를 상속하는 액션 클래스 생성 -액션 클래스 생성 및 비즈니스 로직 구현
② Spring 설정 추가 -액션 클래스 등록
spring 2 configuration : {PRJ_HOME}/src/config/spring/applicationContext-struts.xml
<bean id=“wcxLog1InAction" scope="prototype"
class="com.Hanbank.ebk.channel.pbk.web.struts2.action.login.WcxLog1InAction"/>
66오픈 소스 프레임워크 기반 웹 어플리케이션 제작
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="HanStack">
<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>