11. 웹 애플리케이션 개발 프레임워크 보안 프레임워크 SQL & OR Mapper 프레임워크 DI (Dependency Injection) & AOP (Aspected Oriented Programming) 프레임워크 디스플레이 레이아웃 프레임워크 SOA 프레임워크 리포팅 프레임워크 … 배포 및 형상 관리 프레임워크 자바 기반의 오픈 소스 프레임워크 개요 프레임워크란
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27. public class MyAction { ... public String execute() throws Exception { ... return "success"; } } 액션 클래스의 프로토타입 Struts2 란
46. 액션 인보케이션 액션 매퍼 액션프록시 필터 디스패처 태그 서브시스템 HTML, Dojo, Forms, etc 템플릿 JSP, FreeMarker, Velocity, etc HttpServletResponse 인터셉터 1 리절트 인터셉터 3 인터셉터 2 인터셉터 3 인터셉터 1 인터셉터 2 액션 환경설정관리자 struts.xml HttpServletRequest 액션 프록시 / 액션 인보케이션 Struts2 아키텍쳐
47.
48. 필터 디스패처 proxy = ActionProxyFactory.getFactory().createActionProxy() proxy.execute() 액션 프록시 invocation.invoke() 액션 인보케이션 interceptor() invokeActionOnly() executeResult() 인터셉터 인터셉터 인터셉터 리절트 액션 액션 프록시 / 액션 인보케이션 작업 흐름 Struts2 아키텍쳐
49. ActionProxy invocation.invoke() ActionInvocation invoke() { if (interceptors.hasNext()) { interceptor.interceptor(this); } else { invokeActionOnly(); } if (!executed) { executeResult(); } Interceptor interceptor(invocation) { … return invocation.invoke(); } 액션 프록시 / 액션 인보케이션 호출 구조 Struts2 아키텍쳐
50.
51. 액션 컨텍스트 시퀀스 다이어그램 Struts2 아키텍쳐 :ActionContext :ActionProxy :ActionInvocation 1. getContext() ActionProxy 가 실행될 때 ThreadLocal 로부터 ActionContext 를 얻고 이를 저장한다 . 2. return 4. return 3. getInvocationContext() ActionProxy 는 ActionInvocation 을 위해 ActionContext 를 얻고 ThreadLocal 상에 이를 설정한다 . 5. setContext(aContext) 6. invoke() 7. setContext(aContext) ActionInvocation 이 리턴된 후 , ThreadLocal 상의 예전 ActionContext 를 설정한다 .
113. <action name= " logon" class= " example .SecurityAction " method="logon> <result> logon.jsp </result> </action> 액션 이름 리절트 (type 생략 시 기본값은 dispatcher 타입 사용 name 생략 시 기본값은 success 리절트 코드 사용 ) 리절트 페이지 정의 액션 클래스 액션 메소드 (method 속성 생략 시 execute() 사용 ) 액션 설정 환경설정
114. <action name= " logon" class= " example .SecurityAction " method= " logon " > <interceptor-ref name="basicStack"> <result type="redirect-action">menu</result> <result name="input">/example/logon.jsp</result> </action> 액션 이름 다른 액션을 리절트로 사용 JSP 를 리절트로 사용 액션에 인터셉터 스택 적용 액션 클래스 액션 메소드 다중 리절트 정의 액션 설정 예 환경설정
115.
116.
117.
118.
119.
120.
121.
122.
123. # 리소스 번들 파일 label.sample = 이 것은 properties 파일 안의 메시지입니다 . // 액션 클래스 public class MyAction extends ActionSupport { private String message; public String execute() throws Exception { message = getText(" label.sample ")); return SUCCESS; } ... } #JSP <s:text name=" label.sample "/> <s:submit key=" label.sample "/> <s:property value=" %{getText(‘label.sample’)} "/> 리소스 번들 사용 예 환경설정
124. 액션 리소스 번들 부모 클래스 리소스 번들 인터페이스 리소스 번들 모델 드리븐의 모델 리소스 번들 패키지 리소스 번들 글로벌 리소스 번들 리소스 번들 검색 순서 환경설정
125.
126.
127.
128. welcome.jsp - Home Page example.com 광고 배너 1 검색 최신 뉴스 . . search.cgi - Search Results 검색 결과 . . . . . 광고 배너 2 메타 데이터 바디 내용 메타 데이터 example.com: {title} 메뉴 . 홈 . 뉴스 . 검색 . 공지 copyright 2007 example.com welcome.jsp - Home Page example.com: Home Page 메뉴 . 홈 . 뉴스 . 검색 . 공지 copyright 2007 example.com example.com 검색 최신 뉴스 . . 광고 배너 1 search.cgi - Search Results example.com: Search Results 메뉴 . 홈 . 뉴스 . 검색 . 공지 copyright 2007 example.com 검색 결과 . . . . . 광고 배너 2 decorator 에 의해서 레이아웃을 구성 . 최종 페이지를 생성한다 . decorator 에 의해서 레이아웃을 구성한다 . 최종 페이지를 생성한다 . decorator 에 정의된 레이아웃 . Sitemesh 작업 개념도 플러그인