- 웹/전자정부프레임워크 (eGovFrame)

EgovAbstractServiceImpl 상속. 이게 뭘까?

codingEasy 2020. 8. 31. 14:35

spring/전자정부프레임워크 로 짜여진 프로그램 코드 분석 중

ServiceImpl구현 클래스에서 extends EgovAbstractServiceImpl로 상속 받는 것을 봤다.

 

뭔가 Egov붙여있는 걸로 봐서는 전자정부프레임워크에서 기본적으로 제공해주는 기능인 것 같지만, 

명확하게 감이 잡히지 않아 이리저리 찾아봤다.

 

 

  • EgovAbstractServiceImpl클래스

 : 프레임워크 공통의 Exception처리를 위한 기능을 제공하는 추상클래스

 (ref. 적용기준 항목 중 위의 클래스를 상속을 해야 되는 항목이 존재한다.)


비즈니스 서비스 구현시 디폴트로 Exception 처리를 위한 processException 메소드leaveaTrace 메소드를 가지고 있다.

 

 

   1.  processException

 

  -> EgovBizException(표준표레임워크 내 서비스 레이어에서 발생되는 비즈니스 예외) 발생 시,

     Exception을 메시지와 함께 presentation layer로 전달해준다.

 

예시)

// 넘어온 resultVO 가 null 인경우 EgovBizException 발생 (result.nodata.msg 는 메세지 키에 해당됨)
if (resultVO == null)
	throw processException("result.nodata.msg"); 
          // 또는 throw processException("result.nodata.msg", 발생한 Excpetion );
	return resultVO;

 

 

   2. leaveaTrace 

 

   ->  Exception을 presentation layer로 던지지 않고 수행 후 계속 비즈니스 로직으로 돌아오게 해주는 기능을 제공.

       (Exception 후처리 로직과 유사)

 

예시)

try {
		//강제로 발생한 ArithmeticException  
		int i = 1 / 0;
} catch (ArithmeticException athex) {
        	//Exception 을 발생하지 않고 후처리 로직 실행.
		leaveaTrace("message.trace.msg");
}
 
return resultVO;

 

 

  • EgovAbstractServiceImpl 관련 오류

 

 

- extends EgovAbstractServiceImpl과  import egovframework.rte.fdl.cmmn.EgovAbstractServiceImpl; import부분 에러

 

  : egovframework.rte로 시작하는 모든 파일은 실행환경에 포함되어 있다.
   자가로 생성한 프로젝트에 실행환경 라이브러리가 없어서 생긴 오류로 판단.
   실행환경 라이브러리를 프로젝트에 추가하시고 기동해 보는 것 권장.

 

 

- WARN : org.springframework.web.context.support.XmlWebApplicationContext - Exception encountered during context initialization - cancelling refresh attempt
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'adminService': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'leaveaTrace' is defined

 

  : EgovAbstractServiceImpl 에서 leaveaTrace bean을 injection하고 있어서 발생된 오류

 

  오류 발생 시, context-common.xml 설정 파일에서 아래의 bean 추가.

 

<bean id="leaveaTrace" class="egovframework.rte.fdl.cmmn.trace.LeaveaTrace">
		<property name="traceHandlerServices">
			<list>
				<ref bean="traceHandlerService" />
			</list>
		</property>
	</bean>
 
	<bean id="traceHandlerService" 	class="egovframework.rte.fdl.cmmn.trace.manager.DefaultTraceHandleManager">
		<property name="patterns">
			<list>
				<value>*</value>
			</list>
		</property>
		<property name="handlers">
			<list>
				<ref bean="defaultTraceHandler" />
			</list>
		</property>
	</bean>
 
	<bean id="antPathMater" class="org.springframework.util.AntPathMatcher" />
 
	<bean id="defaultTraceHandler"
		class="egovframework.rte.fdl.cmmn.trace.handler.DefaultTraceHandler" />

 

 

 

 

[참조]

https://www.egovframe.go.kr/uss/olh/qna/QnaInqireCoUpdt.do?qaId=QA_00000000000015078&passwordConfirmAt=

https://open.egovframe.org/cop/bbs/selectBoardArticle.do?bbsId=BBSMSTR_000000000013&nttId=17089&pageIndex=203

http://www.egovframe.go.kr/wiki/doku.php?id=egovframework:rte:bsl:exception_handling