zoukankan      html  css  js  c++  java
  • SPRING IN ACTION 第4版笔记-第四章ASPECT-ORIENTED SPRING-003-Spring对AOP支持情况的介绍

    一、

    不同的Aop框架在支持aspect何时、如何织入到目标中是不一样的。如AspectJ和Jboss支持在构造函数和field被修改时织入,但spring不支持,spring只支持一般method的织入。spring通过以下四种方式支持AOP:

     Classic Spring proxy-based AOP
     Pure- POJO aspects
     @AspectJ annotation-driven aspects
     Injected AspectJ aspects (available in all versions of Spring)

    前三种是Spring自己的对AOP的实现,即运行时织入,第四种是直接调用AspectJ。

    二、Sping的AOP的几个特点

    1.Advice都是写在java中

    2.SPRING ADVISES OBJECTS AT RUNTIME

    In Spring, aspects are woven into Spring-managed beans at runtime by wrapping them with a proxy class. As illustrated in figure 4.3, the proxy class poses as the target bean,intercepting advised method calls and forwarding those calls to the target bean.Between the time when the proxy intercepts the method call and the time when it invokes the target bean’s method, the proxy performs the aspect logic.

    Spring doesn’t create a proxied object until that proxied bean is needed by the application. If you’re using an ApplicationContext , the proxied objects will be created when it loads all the beans from the BeanFactory . Because Spring creates proxies at runtime, you don’t need a special compiler to weave aspects in Spring’s AOP

    3.SPRING ONLY SUPPORTS METHOD JOIN POINTS

    Because it’s based on dynamic proxies, Spring only supports method join points.If you find yourself in need of more than method interception, you’ll want to complement Spring AOP with AspectJ.

  • 相关阅读:
    创建可按比例调整的布局的 Windows 窗体
    Visual C# 2010 实现资源管理器
    Visual C# 2010 实现菜单项和状态栏
    使用异步事件在后台进行计算并报告进度
    A Byte of Python(简明Python教程) for Python 3.0 下载
    面向对象思想
    封装变化(二)
    好玩,看你的博客价值几何?
    基于消息与.Net Remoting的分布式处理架构
    设计之道
  • 原文地址:https://www.cnblogs.com/shamgod/p/5238679.html
Copyright © 2011-2022 走看看