Date post: | 30-Dec-2015 |
Category: |
Documents |
Upload: | christina-bradford |
View: | 214 times |
Download: | 0 times |
Business Computing LabAhn, Younghoe
2003. 9. 6
WAF overview and
Study guide
WAF overview and
Study guide
J2EE BluePrint Seminar 2003 2 Business Computing Since 2002
Contents
• Separation between framework and application
• Walk through PetStore application
• WAF Building-blocks
• WAF Study Best-practice
• Reference
J2EE BluePrint Seminar 2003 3 Business Computing Since 2002
Separation between framework and application
• Framework 와 Application (application-specific code) 은 사용 목적이 다르다 .
• Framework 와 application 의 관계
구분 Framework Application
사용 목적 Application 개발을 용이하고 , 아키텍처 반영을 유도
특정 도메인에서의 요구사항을 충족시키기 위함
사용자 Application 개발자 End user
Framework
Application
General relationship
WAF
Application Component
In Petstore
J2EE BluePrint Seminar 2003 4 Business Computing Since 2002
Separation between framework and application
• Guidelines: – Package 를 이용한 구분– Namespace 를 이용한 구분
J2EE BluePrint Seminar 2003 5 Business Computing Since 2002
Walk through PetStore application• Walk through Scenario
J2EE BluePrint Seminar 2003 6 Business Computing Since 2002
Walk through PetStore application
• Visit the pet store web site
J2EE BluePrint Seminar 2003 7 Business Computing Since 2002
Walk through PetStore application
• Behind the scene– Request!
– Container intercept the request By configuration in web application deployment descriptor EncodingFilter, SignOnFilter
– Show the main screen The request *.screen goes to Template servlet Template JSP composes main screen
Index.jsp main.screen
( populating.jsp )
J2EE BluePrint Seminar 2003 8 Business Computing Since 2002
Walk through PetStore application
• Behind the Scene(continued)
banner
sidebar bodymylist
(optional)
advicebanner(optional)banner
J2EE BluePrint Seminar 2003 9 Business Computing Since 2002
Walk through PetStore application
• Search an iguana
item.jspproduct.jspcategory.jsp
index.jsp in body section
J2EE BluePrint Seminar 2003 10 Business Computing Since 2002
Walk through PetStore application
• Behind the Scene– category.jsp, product.jsp, item.jsp– Using JSTL and EL
J2EE BluePrint Seminar 2003 11 Business Computing Since 2002
Walk through PetStore application
• Behind the Scene(continued)– item.jsp
<%@ taglib prefix="c" uri="/WEB-INF/c.tld" %><%@ taglib prefix="fmt" uri="/WEB-INF/fmt.tld" %>
<jsp:useBean id="catalog" class="com.sun.j2ee.blueprints.catalog.client.CatalogHelper" scope="session"/>
<c:set value="en_US" target="${catalog}" property="locale"/><c:set value="${param.item_id}" target="${catalog}" property="itemId"/><c:set value="${catalog.item}" var="item" />
<p class="petstore_title"> <c:out value="${item.attribute}"/> <c:out value="${item.productName}"/></p><fmt:setLocale value="en_US" />
J2EE BluePrint Seminar 2003 12 Business Computing Since 2002
Walk through PetStore application
• Behind the Scene(continued)– item.jsp(continued)
<table cellpadding="2" cellspacing="0" border="0" width="100%"> <tr> <td><img src='images/<c:out value="${item.imageLocation}"/>'></td> <td class="petstore" width="100%"><b>List Price:</b> <fmt:formatNumber value="${item.listCost}" type="currency" /> <br><br> <b>Your Price:</b> <fmt:formatNumber value="${item.unitCost}" type="currency" /> <br><br> <c:url value="/cart.do" var="cartURL"> <c:param name="action" value="purchase"/> <c:param name="itemId" value="${item.itemId}"/> </c:url> <a href='<c:out value="${cartURL}"/>'> Add to Cart </a> </td> </tr></table>
J2EE BluePrint Seminar 2003 13 Business Computing Since 2002
Walk through PetStore application
• Check out
cart.do?action=purchase&itemId=EST-13
J2EE BluePrint Seminar 2003 14 Business Computing Since 2002
Walk through PetStore application
• Process the order– Generating the “cart.do” request– Generating the “order.do” request
J2EE BluePrint Seminar 2003 15 Business Computing Since 2002
Walk through PetStore application
• Process the order(continued)– Processing the “order.do” request
order.do MainServlet
‘do’ RequestProcessor
delegateOrderHTML
Action
perform
OrderEvent
PetstoreComponent
Manager
reference via session
ShoppingWebController
reference via contextOrderEvent
delegate
OrderEJBAction
delegate
perform
ShoppingController
EJBStateMachine
J2EE BluePrint Seminar 2003 16 Business Computing Since 2002
Walk through PetStore application
• Process the order(continued)– Processing the “order.do” request
order.do MainServlet
RequestProcessor
OrderHTMLAction
DefaultWebController
EJBController
Local
OrderEJBAction
StateMachine
OrderEventResponse
OrderEventResponse
OrderEventResponse
doEnd
Binding with Request
OrderEventResponse
J2EE BluePrint Seminar 2003 17 Business Computing Since 2002
Walk through PetStore application
• Process the order(continued)– Processing the “order.do” request
order_complete.screen
MainServlet
ScreenFlowManager
Taglib
TemplateServlet
forwardToNextScreen
forward
.screen
forward
template.jsp
OrderEventResponse
Make client page
J2EE BluePrint Seminar 2003 18 Business Computing Since 2002
WAF Buiding-blocks
• Big picture by sun– deprecated?
J2EE BluePrint Seminar 2003 19 Business Computing Since 2002
WAF Buiding-blocks
• Reverse model on WAF Building-blocks
– Loosely coupled
RequestProcessor(from web)
H S
MainServlet
-requestProcessor
WebControllerH S
TemplateServlet(from template)
EJBControl lerLocal<<EJBLocalInterface>>
EJBControl lerLocalHome<<EJBSessionLocalHomeInterface>>
S
EJBControl lerLocalEJB
EJBAction
StateMachine#sm
-ccejb
EJBActionSupport
#machine
HTMLAction
HTMLActionSupport
FlowHandler
ScreenFlowData
ScreenFlowManager
WebKeys
ComponentManager
DefaultWebControl ler
EventMapping
URLMapping
URLMappingsXmlDAO
Event
EventResponse
EventResponseSupport
EventSupportScreens
ScreenDefinitionDAO
Parameter
Screen
InsertTag
-parameterRef
-screen
J2EE BluePrint Seminar 2003 20 Business Computing Since 2002
WAF Buiding-blocks
• WAF Building-blocks
FrontController
ServletFilter
request
TemplateService
RequestProcessor
Component Manager
WebController
EJBController
StateMachine
ScreenFlow
Managerresponse
J2EE BluePrint Seminar 2003 21 Business Computing Since 2002
WAF Buiding-blocks
• Servlet Filter
– 주요 역할 Request 나 Response 를 가로채서 반복적인 사전 /사후 작업 Encapulation
– 실제 소스 파일 Just place holder
– 구현 방식 (WAF 의 확장 지점 ) javax.servlet.Filter 인터페이스를 구현 DD (Deployment Descriptor) 에 등록
– 관련 기술 및 패턴 Chain of Responsibility (in GoF Design Patterns) Intercepting Filter (in Core J2EE Patterns) Filter/FilterChain (in Servlet 2.3)
J2EE BluePrint Seminar 2003 22 Business Computing Since 2002
WAF Buiding-blocks
• Front Controller
– 주요 역할 Request 처리를 위한 진입점 (‘ 콜 센터’ ) 실제 Request 를 처리와 화면 처리 사이의 중재자 역할
– 실제 소스 파일 MainServlet.java
– 구현 방식 (WAF 의 확장 지점 ) No customization required DD 에서 Request 유형에 맞춰 설정 (Servlet-mapping)
– 관련 기술 및 패턴 Façade (in GoF Design Patterns) Front Controller (in Core J2EE Patterns)
J2EE BluePrint Seminar 2003 23 Business Computing Since 2002
WAF Buiding-blocks
• Request Processor
– 주요 역할 Request 처리 위한 알고리즘 Encapsulation 다수의 if 문을 제거하는 역할
– 실제 소스 파일 RequestProcessor.java
– 구현 방식 (WAF 의 확장 지점 ) No customization required MainServlet 과 tightly-coupled url-mappings (URL to screen, HTML Action and Flow Handler) event-mappings (Event to EJB Action) 정의
– 관련 기술 및 패턴 Strategy/Policy (in GoF Design Patterns)
J2EE BluePrint Seminar 2003 24 Business Computing Since 2002
WAF Buiding-blocks
• Web Controller
– 주요 역할 HTML Action 처리 EJB-tier 와의 연결 지점 ( 처리 결과를 얻음 )
– 실제 소스 파일 WebController.java
– 구현 방식 (WAF 의 확장 지점 ) WebController 인터페이스를 구현 WebKeys 인터페이스에 Fully qualified class name 등록 HTMLAction 을 구현하거나 , HTMLActionSupport 를 확장한 HTML Action 정의 HTML Action 과 대응되는 Event 및 EventResponse 정의
– 관련 기술 및 패턴 Command (in GoF Design Patterns)
J2EE BluePrint Seminar 2003 25 Business Computing Since 2002
WAF Buiding-blocks• EJB Controller
– 주요 역할 Web Controller 를 통해 받은 Event 를 처리 EJB 컴포넌트에 대한 Location 은 Service Location 컴포넌트 이용 내부적으로는 State Machine 이용
– Invoke event hander– EJBSessionFaçade 정보 관리
– 실제 소스 파일 EJBController Session bean StateMachine.java
– 구현 방식 (WAF 의 확장 지점 ) EJBController Session bean 을 확장한 WebKeys 인터페이스에 Fully qualified class name 등록 EJBAction 을 구현하거나 , EJBActionSupport 를 확장한 EJB Action 정의
– 관련 기술 및 패턴 Visitor (in GoF Design Patterns) Business Delegate (in Core J2EE Patterns)
J2EE BluePrint Seminar 2003 26 Business Computing Since 2002
WAF Buiding-blocks
• Component Manager
– 주요 역할 Web-tier 와 EJB-tier 서비스에 대한 Location 서비스 내부적으로는 Service Locator 컴포넌트 이용 사용자 Session 에 대해 필요한 정보 관리
– 실제 소스 파일 ComponentManager.java
– 구현 방식 (WAF 의 확장 지점 ) ComponentManager 인터페이스를 구현하거나 DefaultComponentManager 확장 WebKeys 인터페이스에 Fully qualified class name 등록
– 관련 기술 및 패턴 Service Locator (in Core J2EE Patterns) HttpSessionListener (in Servlet 2.3)
J2EE BluePrint Seminar 2003 27 Business Computing Since 2002
WAF Buiding-blocks
• Screen Flow Manager
– 주요 역할 Event 처리 이후의 화면을 결정하고 , 다음 화면으로 향하게 함
– 실제 소스 파일 ScreenFlowManager.java, FlowHandler.java
– 구현 방식 (WAF 의 확장 지점 ) ScreenFlowManager 는 변화 없음 WebKeys 인터페이스에 Fully qualified class name 등록 url-mappings 에 정의된 FlowHandler 인터페이스를 구현
J2EE BluePrint Seminar 2003 28 Business Computing Since 2002
WAF Buiding-blocks
• Template Service– 주요 역할
사용자에게 보여질 화면을 구성하고 보여줌 내부적으로는 DOM 처리와 Custom Tag 처리등을 hiding 사용자 Session 에 대해 필요한 정보 관리
– 실제 소스 파일 TemplateServlet.java
– 구현 방식 (WAF 의 확장 지점 ) No customization required DD 에서 Request 유형에 맞춰 설정 (Servlet-mapping) Template 구성 , 화면 정의 및 타일을 구성하는 jsp 작성
– 관련 기술 및 패턴 Composite View (in Core J2EE Patterns) DOM Parsing (in J2SE 1.4)
J2EE BluePrint Seminar 2003 29 Business Computing Since 2002
WAF Study Best-practice
• 기존에 작성된 문서를 숙지하자– 기존의 ( 지적 ) 유산은 철저하게 활용할 수 있어야 한다 .
• 하나의 처리 흐름을 타고 쭉 훑어보자– “Separation of Concern”
• 주석을 달면서 코드를 묶어 보자– 모든 코드에 주석을 달아보면서 작성자의 의도를 파악– “ 행 -> 단락 -> 메소드” 순서로 의미를 파악
• 블록 단위로 추상화 하여 개념적으로 정리해 본다
• 패턴과의 매핑으로 개념을 더욱 견고하게 하자