扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
public class LogingAspect { public void logMethod(JoinPoint jp){ System.err.println(jp.getTarget().getClass()); System.err.println(jp.getSignature().getName()); } } |
< bean id = " logAspectTarget " class = " hibernatesample.service.util.LogingAspect " > </ bean > < aop:config > < aop:aspect id = " logAspect " ref = " logAspectTarget " > < aop:pointcut id = " businessService " expression = " execution(* hibernatesample.service.*.*(..)) " /> < aop:after pointcut - ref = " businessService " method = " logMethod " /> </ aop:aspect > </ aop:config > |
< tx:advice id = " txAdvice " transaction - manager = " transactionManager " > < tx:attributes > < tx:method name = " get* " read - only = " true " /> < tx:method name = " find* " read - only = " true " /> < tx:method name = " * " /> </ tx:attributes > </ tx:advice > < aop:config > < aop:pointcut id = " demoServiceMethods " expression = " execution(* hibernatesample.service.*.*(..)) " /> < aop:advisor advice - ref = " txAdvice " pointcut - ref = " demoServiceMethods " /> < aop:aspect id = " logAspect " ref = " logAspectTarget " > < aop:pointcut id = " businessService " expression = " execution(* hibernatesample.service.*.*(..)) " /> < aop:after pointcut - ref = " businessService " method = " logMethod " /> </ aop:aspect > </ aop:config > |
< bean id ="accountService" class ="hibernatesample.service.impl.AccountServiceImpl" > < property name ="accountDAO" ref ="accountDAO" ></ property > </ bean > |
@Aspect public class LogingAspect { @Pointcut( " execution(* hibernatesample.service.*.*(..)) " ) public void businessService(){} @After( " businessService() " ) public void logMethod(JoinPoint jp){ System.err.println(jp.getTarget().getClass()); System.err.println(jp.getSignature().getName()); } } |
< aop:aspect id ="logAspect" ref ="logAspectTarget" > < aop:pointcut id ="businessService" expression ="execution(* hibernatesample.service.*.*(..))" /> < aop:after pointcut-ref ="businessService" method ="logMethod" /> </ aop:aspect > < bean id ="logAspectTarget" class ="hibernatesample.service.util.LogingAspect" ></ bean > |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者