웹 & 프레임워크

proxy joinPoint 확장

늘근이 2014. 5. 25. 22:53

     //이놈은  확장된놈임, around 알맞는놈따로따로 만들필요가읍어

                  //트랜젝션은 이런 형태가 될것임.

                  public Object aroundLogging(ProceedingJoinPoint joinPoint) {

                                  

                                   Object obj = null;

                                  

                                   //proceed() 타켓을 호출하라!

                                   try {

                                                     //before

                                                     //여기서 리턴하면  이후가 안됨.타겟이 실행안됨..

                                                     //매개변수가 잘못됐으면 그냥 실행하지 않게 할수있다

                                                     obj = joinPoint.proceed();

                                                     //after-returning

                                   } catch (Throwable e) {

                                                     //after-throwing

                                                     e.printStackTrace();

                                   } finally {

                                                     //after

                                   }

                                  

                                   return obj;

                                  

                  }//end aroundLogging()


<!-- <aop:pointcut expression="execution(* say*(..))" id="sayPointcut"/> -->

<aop:pointcut expression="execution(* com.gorakgarak.sample1.xml..*(java.lang.String))" id="sayPointcut"/>

                  <aop:aspect ref="logAspect">

                  <!-- <aop:before method="beforeLogging" pointcut-ref="sayPointcut"/> -->

                  <aop:around method="aroundLogging" pointcut="execution(* sayHello(..))"/>

                  <!-- ref가없으면 한번만 쓰고말고한번지정한 포인트컷을 여기저기서 쓰고싶으면 ref로쓴다 -->

                  </aop:aspect>

 

</aop:config>



결과------------------------------------------------------------------------

before
안녕하소~~~~김수현
안녕하소~~~~김수현
after-returning
after