Spring中基于aop命名空间的AOP 一(一点准备工作和一个例子) |
(2008年08月23日)发表于BlogJava-首页技术区 |
| 阅读全文... |
本站相关内容: |
|
spring aop在使用spring aop的时候碰到一个问题,在一个aop:config里面可以配多个切点表达式,在另外的aop:config里也是可以引用.配切面的时候,一个切面里面怎么不可以配多个通知,比如在记录日志的时候,有个logaspt类把它配置为切面,在这个切面里面配了一个前置的通知,是可以正常工作但是在配一个后置通知怎么就可以了,会出异常代码如下: <!-- 日志aspectbean--> <!-- 声明aop --> </aop:aspect> </aop:config> 难道一个切面不可以声明多个通知吗? 如果一个切面里不可以声明如一个前置或一个环绕的是一个理解的,怎么不可以声明一个前置和一个后置的?不解 已有 0 人发表留言,猛击->> 这里<<-参与讨论 JavaEye推荐
Spring AOP Advice typesBefore advice: Advice that executes before a join point, but which does not have the ability to prevent execution flow proceeding to the join point (unless it throws an exception). After returning advice: Advice to be executed after a join point completes normally: for example, if a method returns without throwing an exception
Spring AOP 起步其实我的个人表达能力不是很好……估计小时候语文没学好~也可能是aop这个概念本身意会的程度很大吧!呵呵寒暄一下! 正式进入主题:AOP 即 Aspect Oriented Programming 的缩写,中文译为"面向切面编程"。本篇没那么学术化,只是为了快速入门了解真实的使用方式!我们不用那么早去想这个名词的意义,fellow me,用真实的代码透析AOP的含义。 不知各位有没有项目开发的经验,如果有的话你应该可以清楚地了解到我们的代码中常常充斥着大量的日志记录代码,我们用log4j等日志记录工具一段一段地记录程序运行的信息。也许有个别是十分特殊的,但是似乎大部分都是例行公事吧!或者在丢出exception的时候捕获其message然后记入日志对吗?这样的代码难道不觉得碍眼?修改起来是不是也很麻烦?要是我们换了一个日志记录工具怎么办?呵呵,别吓到了,没这么严重啦,这些都是极端情况,平时我们还是很开心地写着这些东西。但是今天要说到的这个aop可以将一些特别的操作提取出来,作为我们的"通知-advice",在运行时加载到对象中。就是说,我们可以在代码中不写日志记录段,但是
Spring AOP - Designating PointcutsPointcut designators (PCD) allow flexible constraints on AOP pointcut match criteria for pointcut expressions. Here is a list of the AspectJ PCD’s which Spring AOP supports which limit the matching of join points to - execution - the primary pointcut designator you will use when working with Spring AOP within - within certain types (simply the execution of a method declared within a matching type when using Spring AOP) this - where the bean reference (Spring AOP proxy) is an instance of the
Spring AOP DocsIf this were a book the pages of mine would be well worn: http://static.springframework.org/spring/docs/2.5.x/reference/aop.html#aop-introduction
Spring AOP 起步其实我的个人表达能力不是很好……估计小时候语文没学好~也可能是aop这个概念本身意会的程度很大吧!呵呵寒暄一下! 正式进入主题:AOP 即 Aspect Oriented Programming 的缩写,中文译为”面向切面编程”。本篇没那么学术化,只是为了快速入门了解真实的使用方式!我们不用那么早去想这个名词的意义,fellow me,用真实的代码透析AOP的含义。 不知各位有没有项目开发的经验,如果有的话你应该可以清楚地了解到我们的代码中常常充斥着大量的日志记录代码,我们用log4j等日志记录工具一段一段地记录程序运行的信息。也许有个别是十分特殊的,但是似乎大部分都是例行公事吧!或者在丢出exception的时候捕获其message然后记入日志对吗?这样的代码难道不觉得碍眼?修改起来是不是也很麻烦?要是我们换了一个日志记录工具怎么办?呵呵,别吓到了,没这么严重啦,这些都是极端情况,平时我们还是很开心地写着这些东西。但是今天要说到的这个aop可以将一些特别的操作提取出来,作为我们的”通知-advice”,在运行时加载到对象中。就是说,我们可以在代码中不写日志记录段,但是在运行时加 |
互联网相关内容: |
| spring aop (2009年06月03日) |
| Spring AOP Advice types (2007年10月18日) |
| Spring AOP 起步 (2007年12月07日) |
| Spring AOP - Designating Pointcuts (2008年01月10日) |
| Spring AOP Docs (2008年01月13日) |
| Spring AOP 起步 (2008年01月13日) |
| JSF and Spring AOP (2008年02月02日) |
| Spring + DWR namespaces + AOP (2008年02月16日) |
| DWR, Spring and AOP (2008年02月20日) |
| DWR, Spring and AOP (2008年02月20日) |




