kr.co.hit.live.web.json
Class JsonWebAction

java.lang.Object
  extended by kr.co.hit.live.web.action.AbstractWebAction
      extended by kr.co.hit.live.web.json.JsonWebAction
All Implemented Interfaces:
WebAction

public class JsonWebAction
extends AbstractWebAction

JSON 기반의 데이터교환 및 서비스호출 기능을 구현하기 위한 WebAction 클래스이다.

이 클래스에서는 다음의 Diagnostic Context 값들을 생성한다.

Since:
5.0.3
Author:
이상준

Field Summary
static String DEFAULT_CLIENT_MESSAGE_KEY
          서버 처리 메시지가 없을 경우 전달할 디폴트 메시지 키
protected static String DEFAULT_CONTENT_TYPE
           
static String DEFAULT_DATA_KEY
          서버 데이터를 전달하기 위한 디폴트 키명
protected static String DEFAULT_ENCODING
           
static String DEFAULT_MESSAGE_KEY
          서버 처리 메시지를 전달하기 위한 디폴트 키명
static String DEFAULT_METHOD_SELECTOR
           
static String DEFAULT_SERVERTIME_KEY
          서버 시간을 전달하기 위한 디폴트 키명
static String DEFAULT_SERVICE_SELECTOR
           
protected  ServiceDelegator serviceDelegator
           
 
Fields inherited from class kr.co.hit.live.web.action.AbstractWebAction
context
 
Constructor Summary
JsonWebAction()
           
 
Method Summary
 WebActionForward execute(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          WebActionDispatcher 서블릿이 호출하는 메소드이다.
protected  JsonMessage handleMessage(JsonMessage jsonRequest)
          JsonMessage 입력받아 서비스를 호출한다.
protected  JsonMessage readMessage(javax.servlet.http.HttpServletRequest request)
          HTTP Request의 input stream을 deserialize하여 JsonMessage 객체를 생성하여 반환한다.
 void setDataKey(String key)
          (옵션)서버 시간을 전달하기 위한 키명 Setter. - default: "svrtime"
 void setMessageKey(String key)
          (옵션)서버 처리 메시지를 전달하기 위한 키명 Setter. - default: "message"
 void setMethodSelector(String methodSelector)
          (옵션)HttpServletRequest에서 Service Object의 Method를 호출하기 위한 Method명에 대한 request Parameter 명을 지정한다. - default: "method"
 void setServiceDelegator(ServiceDelegator delegator)
          주어진 ServiceDelegator를 사용하도록 설정한다.
 void setSvcSelector(String svcSelector)
          (옵션)HttpServletRequest에서 Service Object를 호출 하기 위한 Service명에 대한 request Parameter 명을 지정한다. - default: "target"
 void setTimeKey(String key)
          (옵션)서버 데이터를 전달하기 위한 키명 Setter. - default: "data"
 void showConfiguration(javax.servlet.http.HttpServletResponse response)
          WebAction의 설정값을 출력하는 메소드이다.
protected  Object wrapResult(Object result)
          서비스 결과값을 입력받아 전달 가능한 JSON Object으로 Wrapping 한다.
protected  Object wrapResult(Throwable thr)
          에러 Exceptiong을 입력받아 전달 가능한 JSON Object으로 Wrapping 한다.
protected  void writeMessage(javax.servlet.http.HttpServletResponse response, JsonMessage message)
          JsonMessage 객체를 HTTP Response의 output stream으로 Json Object을 전송한다.
 
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
 

Field Detail

serviceDelegator

protected ServiceDelegator serviceDelegator

DEFAULT_SERVICE_SELECTOR

public static final String DEFAULT_SERVICE_SELECTOR
See Also:
Constant Field Values

DEFAULT_METHOD_SELECTOR

public static final String DEFAULT_METHOD_SELECTOR
See Also:
Constant Field Values

DEFAULT_ENCODING

protected static final String DEFAULT_ENCODING
See Also:
Constant Field Values

DEFAULT_CONTENT_TYPE

protected static final String DEFAULT_CONTENT_TYPE
See Also:
Constant Field Values

DEFAULT_MESSAGE_KEY

public static final String DEFAULT_MESSAGE_KEY
서버 처리 메시지를 전달하기 위한 디폴트 키명

See Also:
Constant Field Values

DEFAULT_DATA_KEY

public static final String DEFAULT_DATA_KEY
서버 데이터를 전달하기 위한 디폴트 키명

See Also:
Constant Field Values

DEFAULT_SERVERTIME_KEY

public static final String DEFAULT_SERVERTIME_KEY
서버 시간을 전달하기 위한 디폴트 키명

See Also:
Constant Field Values

DEFAULT_CLIENT_MESSAGE_KEY

public static final String DEFAULT_CLIENT_MESSAGE_KEY
서버 처리 메시지가 없을 경우 전달할 디폴트 메시지 키

See Also:
Constant Field Values
Constructor Detail

JsonWebAction

public JsonWebAction()
Method Detail

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

setMessageKey

public void setMessageKey(String key)
(옵션)서버 처리 메시지를 전달하기 위한 키명 Setter. - default: "message"

Parameters:
key -

setDataKey

public void setDataKey(String key)
(옵션)서버 시간을 전달하기 위한 키명 Setter. - default: "svrtime"

Parameters:
key -

setTimeKey

public void setTimeKey(String key)
(옵션)서버 데이터를 전달하기 위한 키명 Setter. - default: "data"

Parameters:
key -

setSvcSelector

public void setSvcSelector(String svcSelector)
(옵션)HttpServletRequest에서 Service Object를 호출 하기 위한 Service명에 대한 request Parameter 명을 지정한다. - default: "target"

Parameters:
svcSelector -

setMethodSelector

public void setMethodSelector(String methodSelector)
(옵션)HttpServletRequest에서 Service Object의 Method를 호출하기 위한 Method명에 대한 request Parameter 명을 지정한다. - default: "method"

Parameters:
methodSelector -

setServiceDelegator

public void setServiceDelegator(ServiceDelegator delegator)
주어진 ServiceDelegator를 사용하도록 설정한다.

Parameters:
delegator -

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

readMessage

protected JsonMessage readMessage(javax.servlet.http.HttpServletRequest request)
                           throws IOException,
                                  ClassNotFoundException
HTTP Request의 input stream을 deserialize하여 JsonMessage 객체를 생성하여 반환한다.

Parameters:
request -
Returns:
Throws:
IOException
ClassNotFoundException

writeMessage

protected void writeMessage(javax.servlet.http.HttpServletResponse response,
                            JsonMessage message)
                     throws IOException
JsonMessage 객체를 HTTP Response의 output stream으로 Json Object을 전송한다.

Parameters:
response -
JsonMessage -
Throws:
IOException

handleMessage

protected JsonMessage handleMessage(JsonMessage jsonRequest)
JsonMessage 입력받아 서비스를 호출한다. 호출중 오류가 발생하면 에러메시지를 생성하여 반환한다.

Parameters:
jsonRequest - 처리할 메시지
Returns:
JsonMessage 응답 전송할 JsonMessage 객체

wrapResult

protected Object wrapResult(Object result)
서비스 결과값을 입력받아 전달 가능한 JSON Object으로 Wrapping 한다.

Parameters:
result - 서비스 호출 후 Object를 전달 가능한 JSON Object으로 Wrapping 한다.

wrapResult

protected Object wrapResult(Throwable thr)
에러 Exceptiong을 입력받아 전달 가능한 JSON Object으로 Wrapping 한다.

Parameters:
에러 - Exceptiong을 전달 가능한 JSON Object으로 Wrapping 한다.


Copyright © 2014. All Rights Reserved.