我有这样一个需要,我是想拦截所有类的所有方法,但是要屏蔽掉其中的一个类该怎么做。
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">

<bean id="securityHandler" class="com.bjsxt.spring.SecurityHandler"/>           
<bean id="userManager" class="com.bjsxt.spring.UserManagerImpl"/>
<bean id="test" class="com.bjsxt.spring.ITestImpl"/>

<aop:config>
<aop:aspect id="security" ref="securityHandler">
<aop:pointcut id="allAddMethod" expression="execution(* *.*(..))"/>
<aop:after method="checkSecurity" pointcut-ref="allAddMethod"/>
</aop:aspect>
</aop:config>
</beans>
这样配置会拦截所有的方法,但是我想屏蔽掉其中一个类的所有方法不知道有什么好的方法嘛,希望高手指教

解决方案 »

  1.   

    首先 你理解有问题把, 这叫拦截? 这是切入点把,  你这里是指 所有的类的所有方法都要被植入你所要的业务<aop:pointcut id="allAddMethod" expression="execution(public * org.lc.serviceImp.YourClass.*(..))"/> org.lc.serviceImp.YourClass把这里改成你的 完整类名就可以了, 
      

  2.   

    是 横切问题吧切入点什么的aop 就是啊这个需求很怪异呵呵
      

  3.   

    execution表达式中你可以拦截所有的类
    但是在Aspect中可以判断类名,如果是不想处理的类,直接返回public void checkSecurity(JoinPoint jp) {
                     String className = jp.getTarget().getClass().getName()
    System.out.println();
                     if(className.equals(..)) {
                     return ;
    }
    }
      

  4.   

    代码帖快了
    public void checkSecurity(JoinPoint jp) {
                     String className = jp.getTarget().getClass().getName();
                     System.out.println(className );
                     if(className.equals(..)) {
                     return ;
    }
    }
      

  5.   

    <aop:pointcut id="allAddMethod" expression="execution(* *.*(..))"/> 
    execution(包名 类名.方法名(参数..)) 在这里配置你的切入点
      

  6.   

    execution(返回类型 类名.方法名(..))
    将类名改为需要切入的类名就可以了。