Spring AOP

             AOP面向切面编程是spring框架中的一个重要内容,能够实现在不改变原型的基础上动态修改模型以满足新的需求。常用于添加日志,异常处理等与业务逻辑关系疏离的部分。利用AOP可以对业务逻辑的各个部分进行隔离,从而使得业务逻辑各部分之间的耦合度降低,提高程序的可重用性,同时提高了开发的效率。


public interface IAOP{
    public void executeAOP();
  }
  
  public class AOP Implements IAOP{
    public void executeAOP(){
      system.out.println("AOP:executeAOP");
    }
  }

  
<beans>
        <bean id="AOPBean"  class="org.springframework.aop.framework.ProxyFactoryBean" >
        
          <property name="target">
            
              <bean class="aop" singleton="false">
      
          </property>
       </bean>      
</beans>




public class TestAOP{


   public void dosomething(){
  
    ApplicationContext xtx = new FileSystemXMLApplicationContext("配置文件名称");
    IAOP s =(IAOP)ctx.getBean("AOPBean");
    s.executeAOP();
   }
}


  需要对executeAOP进行跟踪时,可以使用AOP;

public class AOP Implements IAOP{
     public void executeAOP(){
      system.out.println("beginCall executeAOP")
      system.out.println("AOP:executeAOP");
      system.out.println("endCall executeAOP")
    }
  }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 8
    评论
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值