Spring AOP

对AOP的概念一直是蒙蒙融融的。而且看Spring的文档上面对AOP的叙述还是不够清楚。 甚至看了文档还是不知道怎样使用Spring AOP, 直到我看了这篇文章。 http://www.javalobby.com/forums/thread.jspa?messageID=91951283㚄。 AOP重要的两个概念, Advice和PointCut。Advice --> what       你做的事情。PointCut --> where   你想在什么地方做事情。 也就是类中的那些方法(注意:现在Spring AOP还只支持Method  Interceptor)。 看看Spring中Advice的类的层次。

看看Pointcut的层次

Spring 提供了整合Advice和Pointcut的接口。

 这样我们只要提供PointcutAdvisor, 就能够知道在那个类的那些方法里面做什么事情了。

现在我们还需要另外一个类帮助我们实现AOP。( org.springframework.aop.framework.ProxyFactoryBean)

 

 

 
这样我们就对所有方法上面实现了beforeAdviceA,beforeAdviceA拦截。如果我们需要对这个类的特定方法进行拦截,如下
 
 
 
 
我们就实现了对myRawController的handleRequestInternal方法进行拦截。

If you don&apost need direct (non-AOP&aposd) access to your bean, then it may be better for the simplicity of the file to just use an anonymous inner bean, rather than declaring the bean seperately to the proxy:

 

 

 详情请参考那篇文章。

    
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值