Spring AOP Basic Concepts

Source: Internet
Author: User

Spring AOP Basic Concepts1. What is AOP:
aspect oriented programming:面向切面编程。即通过预编译方式和运行期动态代理实现程序功能的统一维护的一种技术。主要功能是:日志记录,性能统计,安全控制,事务处理,异常处理等。
The 2.AOP implementation method:
 (1)预编译:AspectJ (2)运行期动态代理(JDK动态代理、CGLIB动态代理):SpringAOP、JbossAOP
Concept of 3.AOP:
 (1)切面(aspect):一个关注点的模块化,这个关注点可能会横切多个对象。 (2)连接点(joinPoint):程序连接过程中的某个特定的点。 (3)通知(Advice):在切面的某个特定的连接点上执行的动作。 (4)切入点(PointCut):匹配连接点的断言,在AOP中通知和一个切入点表达式关联。 (5)引入(Introduction):在不类代码的前提下,为类添加新的方法和属性。 (6)目标对象(Target Object):被一个或多个切面通知的对象。  (7)AOP代理(AOP Proxy):AOP框架创建的对象,用来实现这样的契约(aspect contract)(包括通知方法执行等功能) (8)织入(weaving):把切面连接到其他的应用程序类型或者对象上,并创建一个被通知的对象,分为:编译时织入、类加载时织入、执行时织入。
Type of 4.Advice:
 (1)前置通知(Before advice):在某连接点之前执行的通知,但不能阻止连接点前的执行(除非抛出异常)。 (2)返回后通知(After returning advice):在某连接点正常完成后执行的通知。 (3)抛出异常后通知(After throwing advice):在方法抛出异常退出时执行的通知。 (4)后通知(After(final) advice):当某连接点退出的时候执行的通知(无论是正常返回还是异常退出)。 (5)环绕通知(Around Advice):包围一个点的通知。
Uses of AOP in 5.Spring:
 (1)提供了声明式的企业服务,特别是EJB的替代服务的声明。 (2)允许用户提供自己的方面,以完成oop和AOP 的互补的使用。
AOP Implementations of 6.Spring:
 (1)纯Java实现,无需特殊的编译过程,不需要控制类加载器层次。 (2)目前只支持方法执行的连接点(通知spring bean的方法的执行)。 (3)不是为了提供最完整的AOP的实现(尽管它特别的强大);而是侧重于提供一种AOP实现和spring IOC容器之间的整合,用于帮助解决企业应用中常见的问题。 (4)spring AOP不会与aspectJ竞争,从而提供综合全面的AOP解决方案。
7. The difference between a spring AOP implementation with an interface and no interface
 (1)Spring AOP默认使用标准的JavaSE动态代理作为AOP代理,这使得任何接口都可以被代理。 (2)Spring AOP也可以使用CGLIB代理(如果一个业务对象并没有实现一个接口)。

Spring AOP Basic Concepts

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.