kr.co.hit.live.context
Class ContextAwareService

java.lang.Object
  extended by kr.co.hit.live.context.ContextAwareService
Direct Known Subclasses:
AbstractBatchJob

public class ContextAwareService
extends Object

현재 Application이 실행환경이 WAS나 stand-alone Java application인지 상관없이 동일하게 Transaction 관련 기능을 사용할 수 있도록 관련 기능들을 제공한다. 또한 추가적인 사용자 정의 컨텍스트(ServiceContext)를 접근할 수 있는 기능을 제공한다.

Since:
4.0
Author:
김형도

Constructor Summary
ContextAwareService()
           
 
Method Summary
protected  ApplicationContext getApplicationContext()
          현재 쓰레드에 연결된 어플리케이션 컨텍스트 객체를 반환한다.
protected  Map<String,Object> getDiagnosticContext()
          현재 쓰레드에 연결된 Diagnostic 컨텍스트 객체를 반환한다.
protected  ServiceContext getServiceContext()
          현재 쓰레드에 연결된 서비스 컨텍스트 객체를 반환한다.
protected  UserTransaction getUserTransaction()
          현재 쓰레드와 연결된 UserTransaction 객체를 생성한다.
protected  void setMessage(String msgKey)
          현재 쓰레드에 연결된 서비스 컨텍스트의 서버 메시지를 설정한다.
protected  void setMessage(String msgKey, Object param1)
          현재 쓰레드에 연결된 서비스 컨텍스트의 서버 메시지를 설정한다.
protected  void setMessage(String msgKey, Object[] params)
          현재 쓰레드에 연결된 서비스 컨텍스트의 서버 메시지를 설정한다.
protected  void setMessage(String msgKey, Object param1, Object param2)
          현재 쓰레드에 연결된 서비스 컨텍스트의 서버 메시지를 설정한다.
protected  void setMessage(String msgKey, Object param1, Object param2, Object param3)
          현재 쓰레드에 연결된 서비스 컨텍스트의 서버 메시지를 설정한다.
protected  void setRollbackOnly()
           현재 쓰레드에 연결된 트랜젝션을 롤백상태로 마크한다.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContextAwareService

public ContextAwareService()
Method Detail

setRollbackOnly

protected void setRollbackOnly()
                        throws IllegalStateException

현재 쓰레드에 연결된 트랜젝션을 롤백상태로 마크한다. ContextManager로부터 현재 쓰레드의 EJBContext와 UserTransaction 객체를 얻어온 후, UserTransaction이 설정되어 있다면 UserTransaction의 setRollbackOnly()를 호출하고, UserTransaction이 설정되어 있지 않다면 EJBContext의 setRollbackOnly()를 호출한다.

또한 어플리케이션에서 setRollbackOnly() 가 호출되어 트랜젝션이 rollback으로 마킹이 되었는지 아니면 트랜젝션 타임아웃등 시스템 적으로 rollback이 마킹되었는지 구분하기 위하여 ContextManager.setRollbackOnly()를 호출한다.

Throws:
IllegalStateException

getUserTransaction

protected UserTransaction getUserTransaction()
                                      throws IllegalStateException
현재 쓰레드와 연결된 UserTransaction 객체를 생성한다.

Returns:
Throws:
IllegalStateException

getServiceContext

protected ServiceContext getServiceContext()
현재 쓰레드에 연결된 서비스 컨텍스트 객체를 반환한다.

Returns:

getDiagnosticContext

protected Map<String,Object> getDiagnosticContext()
현재 쓰레드에 연결된 Diagnostic 컨텍스트 객체를 반환한다.

Returns:

setMessage

protected void setMessage(String msgKey)
현재 쓰레드에 연결된 서비스 컨텍스트의 서버 메시지를 설정한다.

Parameters:
msgKey - 메시지 번호

setMessage

protected void setMessage(String msgKey,
                          Object param1)
현재 쓰레드에 연결된 서비스 컨텍스트의 서버 메시지를 설정한다.

Parameters:
msgKey - 메시지 번호
param1 - 메시지 파라메터

setMessage

protected void setMessage(String msgKey,
                          Object param1,
                          Object param2)
현재 쓰레드에 연결된 서비스 컨텍스트의 서버 메시지를 설정한다.

Parameters:
msgKey - 메시지 번호
param1 - 메시지 파라메터 1
param2 - 메시지 파라메터 2

setMessage

protected void setMessage(String msgKey,
                          Object param1,
                          Object param2,
                          Object param3)
현재 쓰레드에 연결된 서비스 컨텍스트의 서버 메시지를 설정한다.

Parameters:
msgKey - 메시지 번호
param1 - 메시지 파라메터 1
param2 - 메시지 파라메터 2
param3 - 메시지 파라메터 3

setMessage

protected void setMessage(String msgKey,
                          Object[] params)
현재 쓰레드에 연결된 서비스 컨텍스트의 서버 메시지를 설정한다.

Parameters:
msgKey - 메시지 번호
params - 메시지 파라메터 배열

getApplicationContext

protected ApplicationContext getApplicationContext()
현재 쓰레드에 연결된 어플리케이션 컨텍스트 객체를 반환한다.

Returns:


Copyright © 2014. All Rights Reserved.