Spring_FrameWork

AOP 빈태그예제정리

tmxhsk99 2018. 11. 20. 16:36

<!–빈태그로 객체생성->포인트컷_aspect_사용패턴 –>


//after - 비즈니스메소드가 실행한된 후에 무조건 실행
<!– <bean id=“after” class=“com.springbook.biz.common.AfterAdvice”></bean> 


//afterthrowing - 비즈니스메소드에서 예외 발생시 실행되는 메소드 


객체생성 

<bean id=“afterThrowing” class=“com.springbook.biz.common.AfterThrowingAdvice" /> –>


//around - 메소드 실행 전후 실행됨

객체생성

<!– <bean id="around” class=“com.springbook.biz.common.AroundAdvice” />

<aop:config>

//포인트컷 적용범위에 그에대한  id 지정
<aop:pointcut
expression=“execution(* com.springbook.biz..*Impl.*(..))”
id=“allPointcut” />

//실행할 객체 태그

<aop:aspect ref=“around”>

//실행할 객체의 메소드 와 포인트 컷의 ID
<aop:around method=“aroundLog” pointcut-ref=“allPointcut” />
</aop:aspect>
</aop:config> –>
<!– <aop:config> <aop:pointcut expression=“execution(* com.springbook.biz..*Impl.*(..))” 
id=“allPointcut” /> <aop:aspect ref=“afterThrowing”> <aop:after-throwing 
method=“exceptionLog” pointcut-ref=“allPointcut” /> </aop:aspect> <aop:aspect 
ref=“after”> <aop:after method=“finallyLog” pointcut-ref=“allPointcut” /> 
</aop:aspect> </aop:config> –>
<!– afterReturning () –>
<!– <bean id=“afterReturning”
class=“com.springbook.biz.common.AfterReturningAdvice”></bean>
<aop:config>
<aop:pointcut
expression=“execution(* com.springbook.biz..*Impl.get*(..))”
id=“getPointcut” />
<aop:aspect ref=“afterReturning”>
<aop:after-returning method=“afterLog”
pointcut-ref=“getPointcut” returning=“returnObj” />
</aop:aspect>
</aop:config>
–>
<!– <bean id =“before” class=“com.springbook.biz.common.BeforeAdvice”/> 
<aop:config> <aop:pointcut expression=“execution(* com.springbook.biz..*Impl.*(..))” 
id=“allPointcut”/> <aop:aspect ref=“before”> <aop:before method=“beforeLog” 
pointcut-ref=“allPointcut”/> </aop:aspect> </aop:config> 
–>
<!– <bean id=“log” class=“com.springbook.biz.common.LogAdvice”></bean> <aop:config> <aop:pointcut 
expression=“execution(* com.springbook.biz..*Impl.*(..))” id=“allPointcut”/> 
<aop:pointcut expression=“execution(* com.springbook.biz..*Impl.get*(..))” 
id=“getPointcut”/> <aop:aspect ref=“log”> <aop:after pointcut-ref=“getPointcut” 
method=“printLog”/> </aop:aspect> </aop:config>  –>