Java Spring AOP研究之Joint Point
Created by Wang, Jerry on Jul 25, 2016
http://blog.itpub.net/10294527/viewspace-122076/
Joint Point
A join point is an identifiable point in the execution of a program. It could be a call to a method or an assignment to a member of an object.
join point 是程序执行过程中可以被识别的点。它可以是对一个函数的调用或是对象的一个属性。(注:spring的AOP只能做到对函数调用的拦截)
例子:
Public class Account{
void credit(float amount){
_balance += amount;
}
}
这个例子中的join point包括Account类中执行credit()方法和对_balance的操作。
Pointcut
A pointcut is a program construct that selects join points and collects context at those points. For example, a pointcut can select a join point that is a call to a method, and it could also capture the method’s context, such as the target object on which the method was called and the method’s arguments.
We can write a pointcut that will capture the execution of the credit() method in the Account class shown earlier:
execution(void Account.credit(float))
To understand the difference between a join point and pointcut, think of pointcuts as specifying the weaving rules and join points as situations satisfying those rules.
pointcut 是一种程序结构,它用于选取join point并收集这些point的上下文信息。举例来说,pointcut可以是一个调用方法的join point,并且它能捕获这个方法的上下文信息,例如调用这个方法的目标对象和该方法的属性。
我们可以写一个pointcut,它将可以捕获前面Account类中credit()方法的执行:
execution(void Account.credit(float))
要想理解join point和pointcut的不同,可以把pointcut想成明确了织入的规则,而join point则声明了符合这些规则的情况(即什么情况下运用织入的规则)。
相关文章
- 用命令行编译java并生成可执行的jar包
- java 显示透明背景png图片
- Java实现 蓝桥杯 算法提高 Monday-Saturday质因子
- Java实现LeetCode_0028_ImplementStrStr
- Java实现台阶问题
- Java实现 蓝桥杯 基础练习 杨辉三角形
- Java的注解机制——Spring自动装配的实现原理
- [Java Spring] Validations for Entity
- [Java Spring MVC] @GetMapping, @PostMapping, @PutMapping, @PatchMapping & @DeleteMapping
- Java动态代理(Spring Aop原理)
- Java的JDBC事务详解
- Java反射机制在Spring IOC中的应用
- [Java Spring] Error Handling with @ExceptionHandler
- 【收藏】Spring Boot项目中使用最新版HBase Java API操作HBase 2.x详解
- Spring 基于 Java 的配置
- Java Spring源代码研究之Bean的名称是大小写相关吗?
- Java面试题 对spring IOC和AOP的理解
- 包含内部类的.java文件编译后生成几个.class文件
- Java-Spring-获取Request,Response对象
- mysql创建 存储过程 并通过java程序调用该存储过程
- Java语言中两种异常的差别
- 【Java】Spring 教程
- 【java】Spring Cloud --Spring Cloud Alibaba 微服务解决方案
- 【面试题系列|Java】spring boot 11问,你能答出几问?