spring4中文技术手册.docx
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_1.gif)
![资源得分’ title=](/images/score_05.gif)
《spring4中文技术手册.docx》由会员分享,可在线阅读,更多相关《spring4中文技术手册.docx(5页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、spring4 中文技术手册在静态代理和动态代理中提到了面对方面编程,主要就是基于动态代理。单独抽象出非业务的功能,效劳于某些业务方法。Spring 供给了四种很有用的 Advice,分别为:Before Advice, After Returning Advice, Around Advice, After throwing Advice。都是方法级别的,就是在某个方法执行前后插入一些非业务的操作,如打日志或者推断权限等。对于这四种 advice 的实现,spring 都供给了三种方法,分别为基于接口、基于 xml 和基于 annotation(注释)。Before Advice 会在目标对
2、象的方法执行之前被调用; After Advice 会在目标方法执行之后被调用; Around Advice 则可以在目标方法执行前后同时加上相关效劳;Throw Advice 是在特别发生后执行某些操作。1.基于接口的 Advice这个就需要自定义的 Aspect 实现 Spring 接口。BeforeAdvice 需要实现 org.springframework.aop.MethodBeforeAdvice 接口:1./*2.* Advice invoked before a method is invoked. Such advices cannot3.* prevent the met
3、hod call proceeding, unless they throw a Throwable.4.*/5.public interface MethodBeforeAdvice extends BeforeAdvice 6.7./*8.* Callback before a given method is invoked.9.* param method method being invoked10.* param args arguments to the method11.* param target target of the method invocation. May be
4、null.12.* throws Throwable if this object wishes to abort the call.13.* Any exception thrown will be returned to the caller if it”s14.* allowed by the method signature. Otherwise the exception15.* will be wrapped as a runtime exception.16.*/17.void before(Method method, Object args, Object target) t
5、hrows Throwable;18. After Advice 实现 org.springframework.aop.AfterReturningAdvice 接口:1./*2.* After returning advice is invoked only on normal method return, not if an3.* exception is thrown. Such advice can see the return value, but cannot change it.4.*/5.public interface AfterReturningAdvice extends
6、 AfterAdvice 6./*7.* Callback after a given method successfully returned.8.* param returnValue the value returned by the method, if any9.* param method method being invoked10.* param args arguments to the method11.* param target target of the method invocation. May be null.12.* throws Throwable if t
7、his object wishes to abort the call.13.* Any exception thrown will be returned to the caller if it”s14.* allowed by the method signature. Otherwise the exception15.* will be wrapped as a runtime exception.16.*/17.void afterReturning(Object returnValue, Method method, Object args, Object target) thro
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- spring4 中文 技术 手册
![提示](https://www.taowenge.com/images/bang_tan.gif)
限制150内