kr.co.hit.live.web.action
Class AbstractWebMultiAction

java.lang.Object
  extended by kr.co.hit.live.web.action.AbstractWebAction
      extended by kr.co.hit.live.web.action.AbstractWebMultiAction
All Implemented Interfaces:
WebAction, WebMultiAction

public abstract class AbstractWebMultiAction
extends AbstractWebAction
implements WebMultiAction

WebMultiAction을 구현시 필요한 호출 메소드 설정 및 조회 기능을 구현한 클래스이다. WebMultiAction은 다음과 같이 구현한다.

  1. 구현할 멀티 액션 인터페이스를 정의한다. 이때 WebMultiAction 인터페이스를 extends한다.
  2. 멀티 액션 클래스를 구현한다. 이때 AbstractWebMultiAction을 extends 하고 위에서 정의한 인터페이스를 implements 해야한다.
  3. 서비스 구성파일 작성한다. 이때 "selector"와 "defaultMethod" property를 설정하도록 한다.
작성 예)
 public interface TestWebMultiAction extends WebMultiAction {

        WebActionForward display(HttpServletRequest request, HttpServletResponse response) throws Exception;
        WebActionForward update(HttpServletRequest request, HttpServletResponse response) throws Exception;
        ... 중략 ...
 }

 public class TestWebMultiActionImpl extends AbstractWebMultiAction
         implements TestWebMultiAction {

        private static final Logger logger = LoggerFactory.getLogger(TestWebMultiActionImpl.class);

        public WebActionForward display(HttpServletRequest request,
                        HttpServletResponse response) throws Exception {
                logger.error("This is TestWebMultiAction.display()...");
                return createForward("default").addModel("code","display");
        }

        public WebActionForward update(HttpServletRequest request,
                        HttpServletResponse response) throws Exception {
                logger.error("This is TestWebMultiAction.update()...");
                return createForward("default").addModel("code","update");
        }
 }

     <service name="testmulti.do"
             interface="${package}.TestWebMultiAction"
             class="${package}.TestWebMultiActionImpl"
             interceptor="system.proxy"
             singleton="true">
         <property name="selector" value="method"/>
         <property name="defaultMethod" value="display"/>
         <property name="forward" value="default:=/ganhogibonweb/jsp/test.jsp"/>
         <property name="prefix" value="/webapps/tmp"/>
     </service>
 

Since:
4.0
Author:
김형도

Field Summary
protected  String defaultMethodName
          호출할 메소드 명을 찾지 못할 경우 사용할 디폴트 메소드 명
protected  String methodSelector
          호출할 메소드 명을 얻기위한 reqeust parameter 명
 
Fields inherited from class kr.co.hit.live.web.action.AbstractWebAction
context, logger
 
Constructor Summary
AbstractWebMultiAction()
           
 
Method Summary
 WebActionForward execute(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          WebActionDispatcher 서블릿이 호출하는 메소드이다.
 String getMethodName(javax.servlet.http.HttpServletRequest request)
          HttpServletRequest의 request parameter 중에서 selector로 지정된 파라메터 명을 사용하여 호출할 메소드 명을 얻어온다. selector로 지정된 파라메터명에 해당되는 값이 존재하지 않으면 디폴트로 설정한 메소드 명을 반환한다.
 void setDefaultMethod(String defaultName)
          호출할 메소드 명을 찾지 못했을 경우 사용할 디폴트 메소드 명을 지정한다.
 void setSelector(String selectorName)
          호출할 메소드 명을 얻기 위하여 사용할 파라메터의 이름(Selector)을 지정한다.
 void showConfiguration(javax.servlet.http.HttpServletResponse response)
          WebAction의 설정값을 출력하는 메소드이다.
 
Methods inherited from class kr.co.hit.live.web.action.AbstractWebAction
createForward, getServletContext, getWebApplicationContext, setForward, setPrefix, setSuffix, setWebApplicationContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface kr.co.hit.live.web.action.WebAction
setWebApplicationContext
 

Field Detail

methodSelector

protected String methodSelector
호출할 메소드 명을 얻기위한 reqeust parameter 명


defaultMethodName

protected String defaultMethodName
호출할 메소드 명을 찾지 못할 경우 사용할 디폴트 메소드 명

Constructor Detail

AbstractWebMultiAction

public AbstractWebMultiAction()
Method Detail

execute

public WebActionForward execute(javax.servlet.http.HttpServletRequest request,
                                javax.servlet.http.HttpServletResponse response)
                         throws Exception
Description copied from interface: WebAction
WebActionDispatcher 서블릿이 호출하는 메소드이다. 이 인터페이스를 구현하는 클래스는 이 메소드에서 업무처리를 수행하고 forward할 View의 URL을 WebActionForward로 리턴한다. null을 리턴할 경우에는 forward하지 않는다.

Specified by:
execute in interface WebAction
Specified by:
execute in class AbstractWebAction
Returns:
Throws:
Exception

showConfiguration

public void showConfiguration(javax.servlet.http.HttpServletResponse response)
                       throws IOException
Description copied from interface: WebAction
WebAction의 설정값을 출력하는 메소드이다.

Specified by:
showConfiguration in interface WebAction
Overrides:
showConfiguration in class AbstractWebAction
Throws:
IOException

setSelector

public void setSelector(String selectorName)
호출할 메소드 명을 얻기 위하여 사용할 파라메터의 이름(Selector)을 지정한다. Selector가 지정되지 않은 경우 getMethodName()는 항상 null을 리턴한다.

Parameters:
selectorName -

setDefaultMethod

public void setDefaultMethod(String defaultName)
호출할 메소드 명을 찾지 못했을 경우 사용할 디폴트 메소드 명을 지정한다.

Parameters:
defaultName -

getMethodName

public String getMethodName(javax.servlet.http.HttpServletRequest request)
HttpServletRequest의 request parameter 중에서 selector로 지정된 파라메터 명을 사용하여 호출할 메소드 명을 얻어온다. selector로 지정된 파라메터명에 해당되는 값이 존재하지 않으면 디폴트로 설정한 메소드 명을 반환한다. Selector나 디폴트 메소드명이 지정되지 않은 경우에는 null을 반환한다.

Specified by:
getMethodName in interface WebMultiAction
Parameters:
request -
defaultSelector - 설정된 Selector가 없을 경우에 사용할 디폴트 selector 값
Returns:
호출할 메소드명


Copyright © 2014. All Rights Reserved.