1:下面<value>.*save.*</value>处的正则表达式要怎么写,我要拦截userManager类中所有带save的方法,现在没起到拦截的作用,也几是说没有进到拦截的方法里。<bean id="userManager" parent="baseTxService">
<property name="target">
<bean class="bc.engine.isec.biz.UserManager"/>
</property>
</bean><bean id="regexpAdvisor" class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
<property name="patterns">
<list>
<value>.*save.*</value>
</list>
</property>
<property name="advice" ref="saveMethodInterceptor" />
</bean> 
<bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator" />2:或者我用下面的方法,使用MethodInterceptor(环绕增强),但是他会拦截到userManager里所有的方法,并使具体的业务方法失效。 该拦截的没拦截,不该拦截的,让他搞的不起作用了<bean id="methodInterceptor" parent="baseTxService" >
<property name="target">
<bean class="bc.engine.isec.advice.MethodInterceptor"/>
</property>
</bean>


<bean id="saveProxy" class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
<property name="beanNames">
<list>
<value>userManager</value>
</list>
</property>
<property name="proxyTargetClass">
<value>true</value>
</property>
<property name="interceptorNames">
<list>
<value>methodInterceptor</value>
</list>
</property>
</bean>以上2个问题,谁知道怎么解决啊?搞定一个就好!

解决方案 »

  1.   

    1:下面 <value>.*save.* </value>处的正则表达式要怎么写,我要拦截userManager类中所有带save的方法,现在没起到拦截的作用,也几是说没有进到拦截的方法里。    <bean id="fooService" class="x.y.service.DefaultFooService"/>   <!-- this is the actual advice itself -->
       <bean id="testAOP" class="x.y.YourAOP"/>   <aop:config>
          <aop:aspect ref="testAOP">         <aop:pointcut id="pointcut1"
                        expression="execution(* x.y.userManager.save(..))"/>         <aop:around pointcut-ref="pointcut1"
                      method="aopMethod"/>      </aop:aspect>
       </aop:config>具体请参见spring2.x开发参考手册  核心技术--使用spring进行面向切面编程--基于Schema的AOP支持