aop 中joinpoint的使用方法
一.簡述下joinpoint在不同情況下的不同:
1.在around中可以用,此時可以執行被包裹的代碼,可以根據情況來判斷是否執行被包裹的代碼,以實現控制的作用。
- public void around(ProceedingJoinPoint joinpoint) {
- joinpoint.proceed();
- }
public void around(ProceedingJoinPoint joinpoint) {
joinpoint.proceed();
}
2.別的用,常用於做記錄之用,不能控制被包裹的代碼是否執行。
- public void before(JoinPoint joinpoint) {
- }
public void before(JoinPoint joinpoint) {
}
主要區別:在於是否能控制被包裹的代碼。
二.joinpoint如何查看類調用情況:
- joinpoint.getArgs();//輸入的參數列表
- joinpoint.getTarget().getClass().getName();//類全路徑
- joinpoint.getSignature().getDeclaringTypeName();//接口全路徑
- joinpoint.getSignature().getName();//調用的方法
joinpoint.getArgs();//輸入的參數列表 joinpoint.getTarget().getClass().getName();//類全路徑 joinpoint.getSignature().getDeclaringTypeName();//接口全路徑 joinpoint.getSignature().getName();//調用的方法
三.什麼是Signature
public interface Signature
Represents the signature at a join point. This interface parallels java.lang.reflect.Member.
This interface is typically used for tracing or logging applications to obtain reflective information about the join point, i.e. using the j2se 1.4java.util.logging API
aspect Logging {
Logger logger = Logger.getLogger("MethodEntries");
before(): within(com.bigboxco..*) && execution(public * *(..)) {</br>
Signature sig = thisJoinPoint.getSignature();</br>
logger.entering(sig.getDeclaringType().getName(),</br>
sig.getName());</br>
}</br>
}
aop 中joinpoint的使用方法的更多相关文章
- Spring AOP中JoinPoint的用法
Spring JoinPoint的用法 JoinPoint 对象 JoinPoint对象封装了SpringAop中切面方法的信息,在切面方法中添加JoinPoint参数,就可以获取到封装了该方法信息的 ...
- SpringBoot AOP中JoinPoint的用法和通知切点表达式
前言 上一篇文章讲解了springboot aop 初步完整的使用和整合 这一篇讲解他的接口方法和类 JoinPoint和ProceedingJoinPoint对象 JoinPoint对象封装了Spr ...
- Aop 中 JoinPoint等对象的用法Api
@Aspect 定义类为切入类 @Pointcut 声明一个切入策略供 @Before @After @ Around @ AfterReturning选择 @Before 被切入方法执行前执行 @A ...
- AOP中ProceedingJoinPoint获取目标方法,参数,注解
private void saveLog(ProceedingJoinPoint jp,long time)throws Throwable { package com.cy.pj.common.as ...
- SpringBoot中使用AOP打印接口日志的方法(转载)
前言 AOP 是 Aspect Oriented Program (面向切面)的编程的缩写.他是和面向对象编程相对的一个概念.在面向对象的编程中,我们倾向于采用封装.继承.多态等概念,将一个个的功能在 ...
- Spring AOP中使用args表达式访问目标方法的参数
Spring AOP 的使用过程理解 首先,aop的使用场景介绍: 1.处理一些通用的非功能性的需求,不影响业务流程,比如说打印日志.性能统计.推送消息等: 2.aop无法拦截static.final ...
- Spring AOP基于配置文件的面向方法的切面
Spring AOP基于配置文件的面向方法的切面 Spring AOP根据执行的时间点可以分为around.before和after几种方式. around为方法前后均执行 before为方法前执行 ...
- Spring AOP中定义切点(PointCut)和通知(Advice)
如果你还不熟悉AOP,请先看AOP基本原理,本文的例子也沿用了AOP基本原理中的例子.切点表达式 切点的功能是指出切面的通知应该从哪里织入应用的执行流.切面只能织入公共方法.在Spring AOP中, ...
- spring Aop中aop:advisor 与 aop:aspect的区别
转载:http://blog.csdn.net/u011710466/article/details/52888277 在spring的配置中,会用到这两个标签.那么他们的区别是什么呢? ...
随机推荐
- 使用PXE+NFS EFI引导安装RHEL6/7以及Kickstart安装
PXE引导的步骤: 1.开机后选择网络启动,client端向server端的dhcpd发起获取IP地址的dhcp请求. 2.server端分配IP后,dhcpd会同时根据其配置文件,通过TFTP协议发 ...
- docker操作大全
docker 常用操作方法 查看docker版本docker version 搜索镜像docker serach 镜像名称 拉去镜像docker pull 镜像名称 查看本地镜像仓库信息docker ...
- PHP -Casbin: 支持 ACL、RBAC、ABAC 多种模型的 PHP 权限管理框架
PHP-Casbin 是一个用 PHP 语言打造的轻量级开源访问控制框架( https://github.com/php-casbin... ),目前在 GitHub 开源.PHP-Casbin 采用 ...
- POJ——T 1470 Closest Common Ancestors
http://poj.org/problem?id=1470 Time Limit: 2000MS Memory Limit: 10000K Total Submissions: 20830 ...
- [Recompose] Stream Props to React Children with RxJS
You can decouple the parent stream Component from the mapped React Component by using props.children ...
- 灵活的运用Model类
1.定义接口 using System; using System.Collections.Generic; using System.Linq; using System.Web; namespac ...
- Gym - 100685F Flood BFS
Gym - 100685F 题意:n个水池之间流水,溢出多少流出多少,多个流出通道的话平均分配,给你每个水池中的水量和容量,问到最后目标水池中水量. 思路:直接用队列扩展,不过这里有一个优化,就是统计 ...
- Weka中数据挖掘与机器学习系列之Weka3.7和3.9不同版本共存(七)
不多说,直接上干货! 为什么,我要写此博客,原因是(以下,我是weka3.7.8) 以下是,weka3.7.8的安装版本. Weka中数据挖掘与机器学习系列之Weka系统安装(四) 基于此,我安装最新 ...
- How Blink works
How Blink works Author: haraken@ Last update: 2018 Aug 14 Status: PUBLIC Working on Blink is not eas ...
- 网络爬虫与web之间的访问授权协议——Robots
网站的管理者们通常会有这样一种心态:一方面期待百度.Google这样的搜索引擎来抓取网站的内容,另一方面又很厌恶其他来路不明的网络爬虫抓取自己的信息.正是因为这样,才有“好爬虫”.“坏爬虫”这样的说法 ...