본문 바로가기

카테고리 없음

전자정부의 예외처리 방법

context-aspsect.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:aop="http://www.springframework.org/schema/aop"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd">
	<aop:config>
		<aop:pointcut id="serviceMethod" expression="execution(* egovframework.example..impl.*Impl.*(..))" />

		<aop:aspect ref="exceptionTransfer">
			<aop:after-throwing throwing="exception" pointcut-ref="serviceMethod" method="transfer" />
		</aop:aspect>
	</aop:config>
	
	<bean id="exceptionTransfer" class="egovframework.rte.fdl.cmmn.aspect.ExceptionTransfer">
		<property name="exceptionHandlerService">
			<list>
				<ref bean="defaultExceptionHandleManager" />
				<ref bean="otherExceptionHandleManager" />
			</list>
		</property>
	</bean>

	<bean id="defaultExceptionHandleManager" class="egovframework.rte.fdl.cmmn.exception.manager.DefaultExceptionHandleManager">
		<property name="reqExpMatcher">
			<ref bean="antPathMater"/>
		</property>
		<property name="patterns">
			<list>
				<value>**service.impl.*</value>
			</list>
		</property>
		<property name="handlers">
			<list>
				<ref bean="egovHandler" />
			</list>
		</property>
	</bean>

	<bean id="otherExceptionHandleManager" class="egovframework.rte.fdl.cmmn.exception.manager.DefaultExceptionHandleManager">
		<property name="reqExpMatcher">
			<ref bean="antPathMater"/>
		</property>
		<property name="patterns">
			<list>
				<value>**service.impl.*</value>
			</list>
		</property>
		<property name="handlers">
			<list>
				<ref bean="otherHandler" />
			</list>
		</property>
	</bean>

	<bean id="egovHandler" class="egovframework.example.cmmn.EgovSampleExcepHndlr" />
	<bean id="otherHandler" class="egovframework.example.cmmn.EgovSampleOthersExcepHndlr" />	
	
</beans>

 

관련된 개념

- AOP

- Bean

 

질문

SQL Excetion이 발생하게되면 impl단에서 error를 캐치. 로그를 뿌리는걸까. 그러면 throw Exception 안해줘도 될 것 같은데..

 

레퍼런스

1. context-aspect 분석

https://m.blog.naver.com/PostView.naver?blogId=1_soft&logNo=220706819718&targetKeyword=&targetRecommendationCode=1