12.07.2015 Views

4.3.1.Action의 역할 - Anyframe

4.3.1.Action의 역할 - Anyframe

4.3.1.Action의 역할 - Anyframe

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

4.ControllerController는 MVC의 Model과 View사이의 중계자 역할을 한다. Struts의 Controller는 사용자의 Request를 처리하고 리소스의 초기화 등을 담당하고 있는 ActionServlet, 사용자 Request로 부터 ActionForm 객체를 생성하고 Action클래스의 execute()를 실행하는 RequestProcessor, 그리고 비즈니스 로직을 호출하고 성공과 실패에 대한 forward 정보를 설정하는 Action클래스로 이루어져있다.4.1.ActionServletActionServlet은 Struts에서 Controller역할을 담당하는 주요한 클래스이다.4.1.1.ActionServlet의 역할• 사용자의 요청을 받는 단일 진입점의 역할 (Front Controller)• 리소스의 초기화와 clean-up 을 담당4.1.2.초기화 프로세스ActionServlet의 init() 메소드에서 다음과 같이 초기화 절차가 진행된다.• Struts 내부에서 사용되는 에러나 경고에 사용되는 메세지 초기화• web.xml에서 init-param으로 정의된 정보(debug, config, detail 등)들을 초기화• web.xml에서 설정한 servlet-mapping 정보 초기화• ServletContext에 ActionServlet 객체 저장• init-param의 'config'에 의해 정의된 디폴트 모듈 정보(정의되지 않은 경우 '/WEB-INF/strutsconfig.xml')를이용하여 ApplicationConfig 객체를 생성• struts-config.xml에 메세지 리소스 관련 설정이 있을 경우 초기화• struts-config.xml에 DataSource가 설정되어 있을 경우 초기화• struts-config.xml에 정의된 Plug-In정보를 초기화4.1.3.실행 시(ActionServlet 인스턴스가 HTTPRequest를 받을 때)• Request의 prefix에 따라 해당되는 서브 어플리케이션을 찾음• RequestProcessor를 찾아 process() 메소드 호출4.1.4.ShutDown 프로세스• RequestProcessor의 destroy() 메소드 호출• 에 의해 정의된 값이 존재하는 경우 해당 destroy() 메소드 호출• 에 의해 정의된 값이 존재하는 경우 해당 close() 메소드 호출15

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!