Anyframe Web를 기반으로 웹 어플리케이션을 개발할 때 프로젝트 고유의 기능을 추가로 고려해야할 경우가 있을 것이다.
전체 어플리케이션에 공통적으로 필요한 기능인 경우 프레임워크를 확장하여 이러한 요구사항을 쉽게 해결할 수 있다.
Anyframe Web는 Struts를 확장한 Web Application Framework 이기에 Struts와 같은 확장 Point를 제공한다.
<contoller
contentType="text/html;charset=euc-kr"
debug="3" local="true" nocache="true"
processorClass="anyframe.web.struts.common.action.DefaultRequestProcessor" />
public abstract class EmpActionSupport extends DefaultActionSupport {
private Log logger;
public EmpActionSupport() throws Exception {
logger = this.getLogger();
}
public Log getLogger() throws Exception {
return DefaultActionUtils.getLogger(this.getClass().getName());
}
public abstract ActionForward process(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception;
public void preProcess(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
super.preProcess(mapping, form, request, response);
logger.info(this.getClass().getName() + "preProcess extended some logic here ..");
}
public ActionForward postProcess(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response,
ActionForward forward) throws Exception {
logger.info(this.getClass().getName() + "postProcess extended some logic here ..");
return super.postProcess(mapping, form, request, response, forward);
}
}
public class GetUserListAction extends EmpActionSupport {
public ActionForward process(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
logger.debug("this.getClass().getName() process() started.");
...
}
}