AOP

----------------------------------------------------------------------/n two distinct types of AOP: • static AOP : AspectJ’s AOP : the crosscutting logic is applied to your code at compile time,and you cannot change it without modifying the code and recompiling. In static AOP, the weaving process forms another step in the build process for an application. • dynamic AOP:Spring’s AOP :crosscutting logic is applied dynamically, at runtime. This allows you to make changes in the distribution of crosscutting without recompiling the application.the weaving process is performed dynamically at runtime. Spring’s approach is to create proxies for all advised objects,allowing for advice to be invoked as required. Spring AOP is only a subset of the full AOP feature set found in other implementations like AspectJ. ----------------------------------------------------------------------/n two different kinds of proxies of Spring AOP • JDK dynamic proxy • CGLIB proxy ----------------------------------------------------------------------/n AOP Concepts: • Joinpoint: A joinpoint is a well-defined point during the execution of your application. Typical examples of joinpoints include a call to a method, the method invocation itself, class initialization, and object instantiation. Joinpoints are a core concept of AOP and define the points in your application at which you can insert additional logic using AOP. • Advice: The code that is executed at a particular joinpoint is called the advice. There are many different types of advice, including before advice, which executes before the joinpoint, and after advice, which executes after it. • Pointcuts: A pointcut is a collection of joinpoints that you use to define when advice should be executed. By creating pointcuts, you gain fine-grained control over how you apply advice to the components in your application. As mentioned previously, a typical joinpoint is a method invocation. A typical pointcut is the collection of all method invocations in a particular class. Often, you can compose pointcuts in complex relationships to further constrain when advice is executed. We discuss pointcut composition in more detail in the next chapter. • Aspects: An aspect is the combination of advice and pointcuts. This combination results in a definition of the logic that should be included in the application and where it should execute. • Weaving: This is the process of actually inserting aspects into the application code at the appropriate point. For compile-time AOP solutions, this is, unsurprisingly, done at compile time, usually as an extra step in the build process. Likewise, for runtime AOP solutions, the weaving process is executed dynamically at runtime. • Target: An object whose execution flow is modified by some AOP process is referred to as the target object. Often, you see the target object referred to as the advised object. • Introduction: Introduction is the process by which you can modify the structure of an object by introducing additional methods or fields to it. You can use introduction to make any object implement a specific interface without needing the object’s class to implement that interface explicitly. ---------------------------------------------------/n in Spring AOP at least, is that you can’t advise final classes, because they cannot be overridden and therefore cannot be proxied.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值