joinpoint可以打开excel

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了joinpoint可以打开excel相关的知识,希望对你有一定的参考价值。

2.1、joinPoint

在AOP中,我们知道描述切面的术语有通知(advice),切点(pointcut),连接点(join point)。
连接点(joinPoint)就是在应用执行过程中能够插入切面的一个点。这个点可以是调用方法时、抛出异常时、甚至修改一个字段时。切面代码可以利用这些点插入到应用的正常流程之中,并添加新的行为。
这个类的主要作用就是可以让我们在Advice中获取被增强方法相关的所有信息。通过JoinPoint可以获取被代理方法的各种信息,如方法参数,方法所在类的class对象,然后执行反射操作
它的主要方法及相关解释如下表格:
方法名 功能
Signature getSignature(); 获取封装了署名信息的对象,在该对象中可以获取到目标方法名,所属类的Class等信息
Object[] getArgs(); 获取传入目标方法的参数对象
Object getTarget(); 获取被代理的对象
Object getThis(); 获取代理对象
其中关键方法就是这个getSignature(),该方法返回Signature对象,而通过该对象我们可以获得被增强方法的信息。
2.2、ProceedingJoinPoint

ProceedingJoinPoint继承JoinPoint,是它的子接口,在joinPoint的基础上对其增强功能。其实主要是在JoinPoint的基础上暴露出 proceed 这个方法。proceed很重要,这个是aop代理链执行的方法。

public interface ProceedingJoinPoint extends JoinPoint
public Object proceed() throws Throwable;
public Object proceed(Object[] args) throws Throwable;

1
2
3
4
1
2
3
4
环绕通知=前置+目标方法执行+后置通知,proceed方法就是用于启动目标方法执行的
暴露出这个方法,就能支持 aop:around 这种切面(而其他的几种切面只需要用到JoinPoint,,这也是环绕通知和前置、后置通知方法的一个最大区别。这跟切面类型有关), 能决定是否走代理链还是走自己拦截的其他逻辑。建议看一下 JdkDynamicAopProxy的invoke方法,了解一下代理链的执行原理。
注:ProceedingJoinPoint is only supported for around advice
典型的用法如下:
public Object around(ProceedingJoinPoint point) throws Throwable
Signature signature = point.getSignature();
// AopUtils.getTargetClass(point.getTarget())获取原始对象,例如对于Mapper而言,它获取的是具体代理的Mapper如com.b.mapper.DefaultDsMapper(如果前者继承了后者的话)而不是定义该方法的Mapper如com.b.base.BaseMapper<Info, InfoExample, InfoKey>,如下图
Type[] types = AopUtils.getTargetClass(point.getTarget()).getGenericInterfaces(); // getGenericInterfaces方法能够获取类/接口实现的所有接口
Annotation nologgingAnno = ((Class)types[0]).getAnnotation(Nologging.class); // type是所有类型的父接口
MethodSignature methodSignature = (MethodSignature)signature;
Method targetMethod = methodSignature.getMethod();

1
2
3
4
5
6
7
8
1
2
3
4
5
6
7
8
三、Signature对象

3.1、Signature

此接口通常用于跟踪或记录应用程序以获取有关连接点的反射信息,下面是官方给的一个使用的例子

aspect Logging
Logger logger = Logger.getLogger("MethodEntries");

before(): within(com.bigboxco..*) && execution(public * *(..))
Signature sig = thisJoinPoint.getSignature();
logger.entering(sig.getDeclaringType().getName(),
sig.getName());


1
2
3
4
5
6
7
8
9
1
2
3
4
5
6
7
8
9
源码:

//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package org.aspectj.lang;

public interface Signature
String toString();
//返回此签名的缩写字符串表示形式
String toShortString();
//返回此签名的扩展字符串表示形式
String toLongString();
//返回此签名的标识符部分。对于方法,这将返回方法名称。
String getName();
//返回表示为 int 的此签名上的修饰符。使用 java.lang.reflect.Modifier 上定义的常量和辅助方法来操作它,
// 检查此签名是否公开 java.lang.reflect.Modifier.isPublic(sig.getModifiers());
// 打印出修饰符 java.lang.reflect.Modifier.toString(sig.getModifiers());
int getModifiers();
//返回一个 java.lang.Class 对象,表示声明此成员的类、接口或方面。对于成员内声明,这将是声明成员的类型,而不是按词法写入声明的类型。使用 SourceLocation.getWithinType() 获取在词法上出现声明的类型。
//为了与 java.lang.reflect.Member 保持一致,这个方法应该被命名为 getDeclaringClass()
Class getDeclaringType();
//返回声明类型的完全限定名称。这等效于调用 getDeclaringType().getName(),但是为了更高的效率缓存了结果
String getDeclaringTypeName();

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
HttpClient请求

GET http://localhost:8080/test/testAnno?name=Indian frends
Accept: application/json
1
2
1
2
运行结果

I'm fine ,thank you
toString; String com.mz.testSpring.controler.testSpringControler.sayHello(String)
toShortString; testSpringControler.sayHello(..)
toLongString; public java.lang.String com.mz.testSpring.controler.testSpringControler.sayHello(java.lang.String)
getName; sayHello
getModifiers; 1
getDeclaringType; com.mz.testSpring.controler.testSpringControler
getDeclaringTypeName; com.mz.testSpring.controler.testSpringControler
1
2
3
4
5
6
7
8
1
2
3
4
5
6
7
8
可以看出,Signature 也是为了获取原始方法的各种信息而存在的,并且信息更加的简洁,方便我们截取,他与JoinPoint合作可以让我们更方便的获取原始方法的各种信息

3.2、MethodSignature

当然我们通过Signature上面的方法还是不能很方便达成我们获取方法上的注解等操作。因为我们获取不了方法本身这个Method类。
那么这时MethodSignature就出现了,顾名思义,它就是方法签名,可以看下它的源码:

public interface MethodSignature extends CodeSignature
Class getReturnType(); /* name is consistent with reflection API */
Method getMethod();

1
2
3
4
1
2
3
4
它就提供了两个方法,其中关键点就在于getMethod()方法,它可以获取被增强的方法本身Method这个类,通过该类就类似反射操作了,可以通过它的API完成获取注解等操作。
那怎么通过Signature得到MethodSignature呢
其实很简单,可以看一下它的依赖关系图:

所以你应该就明白了,强转即可。
那么我们就可以完成通过Signature获取注解的操作,方法如下:

private Optional<Operation> getAnnotationLog(JoinPoint joinPoint)
MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
Method method = methodSignature.getMethod();
if(method != null)
return Optional.ofNullable(method.getAnnotation(Operation.class));

return Optional.empty();

1
2
3
4
5
6
7
8
1
2
3
4
5
6
7
8
四、参考链接

https://blog.csdn.net/M_amazing/article/details/121747188
https://blog.csdn.net/qq_46940224/article/details/125960508
https://blog.csdn.net/qq_15037231/article/details/80624064
参考技术A joinpoint可以打开excel步骤如下:
1.打开PPT,点击“插入—对象”按钮。
2.PPT编辑状态链接打开Excel操作步骤,在新弹界面中选择“由文件创建”,并单击“浏览”按钮。
3.加载对应的Excel文件之后,单击“显示为图标”,甚至可以点击“更改图标”去修改图标样子和名称。
4.插入完毕后,会出现类似下图风格的图标,在编辑状态下,双击该图标即可跳转打开对应Excel文件。
5.总结:插入对象的这个技巧,是PPT链接任何其他文件或应用程序(对象)的方法,可以很方便的将其显示成为一个图标。不过需要注意的,该图标只在PPT编辑状态下双击有效。
参考技术B 可以打开excel
在AOP中,我们知道描述切面的术语有通知(advice),切点(pointcut),连接点(join point)。
连接点(joinPoint)就是在应用执行过程中能够插入切面的一个点。这个点可以是调用方法时、抛出异常时、甚至修改一个字段时。切面代码可以利用这些点插入到应用的正常流程之中,并添加新的行为。
这个类的主要作用就是可以让我们在Advice中获取被增强方法相关的所有信息。通过JoinPoint可以获取被代理方法的各种信息,如方法参数,方法所在类的class对象
参考技术C 打开PPT,点击“插入—对象”按钮。(如下图1处)

在新弹界面中选择“由文件创建”,并单击“浏览”按钮。(下图2处)

加载对应的Excel文件之后,单击“显示为图标”(下图3处),您甚至可以点击“更改图标”去修改图标样子和名称。

插入完毕后,会出现类似下图风格的图标,在编辑状态下,双击该图标即可跳转打开对应Excel文件。

总结:插入对象的这个技巧,是PPT链接任何其他文件或应用程序(对象)的方法,可以很方便的将其显示成为一个图标。不过需要注意的,该图标只在PPT编辑状态下双击有效。

上面就是小编为大家带来的PPT编辑状态链接打开Excel的操作步骤,一起来学习学习吧。相信是可以帮助到一些新用户的。

1
2
3
郑重提醒:本文转载自互联网,此文内容不代表本站观点,如内容牵扯到投资、贷款、理财、股票、兼职、赚钱、网赚的项目尤其需要注意保护自己的财产安全,不要轻易相信,由此产生的损失跟本站无关,请慎重!

网友评论
评论
参考技术D 打开PPT,点击“插入—对象”按钮
2
/4
在新弹界面中选择“由文件创建”,并单击“浏览”按钮
3
/4
加载对应的Excel文件之后,单击“显示为图标”(下图3处),您甚至可以点击“更改图标”去修改图标样子和名称
4
/4
插入完毕后,会出现类似下图风格的图标,在编辑状态下,双击该图标即可跳转打开对应Excel文件

SpringAop环绕通知和JoinPoint and ProceedingJoinPoint


Proceedingjoinpoint 和JoinPoint的区别:
Proceedingjoinpoint 继承了JoinPoint,proceed()这个是aop代理链执行的方法。并扩充实现了proceed()方法,用于继续执行连接点。JoinPoint仅能获取相关参数,无法执行连接点。JoinPoint的方法
1.java.lang.Object[] getArgs():获取连接点方法运行时的入参列表;
2.Signature getSignature() :获取连接点的方法签名对象;
3.java.lang.Object getTarget() :获取连接点所在的目标对象;
4.java.lang.Object getThis() :获取代理对象本身;

proceed()有重载,有个带参数的方法,可以修改目标方法的的参数

这几天学习这一块我们应该可以很快写出来下面的代码没有难点

package com.wfg.aop2.dao;

/**
* @author wufagang
* @description
* @date 2021年04月24日 3:03 下午
*/
public interface IndexDao
public void saveUser(String user);
package com.wfg.aop2.dao;


import org.springframework.stereotype.Service;

/**
* @author wufagang
* @description
* @date 2021年04月24日 3:03 下午
*/
@Service
public class IndexDaoImpl implements IndexDao
@Override
public void saveUser(String user)
System.out.println("save user" + user);

package com.wfg.aop2;

import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;

/**
* @author wufagang
* @description
* @date 2021年04月24日 3:08 下午
*/
@Configuration
@ComponentScan("com.wfg.aop2")
@EnableAspectJAutoProxy(proxyTargetClass=false)
public class AppConfig
package com.wfg.aop2;

import com.wfg.aop2.dao.IndexDao;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;

/**
* @author wufagang
* @description
* @date 2021年04月24日 3:06 下午
*/
@Aspect
@Component
public class IndexAspect

@Before("this(com.wfg.aop2.dao.IndexDaoImpl)")
public void before()
System.out.println("before==============");


@After("target(com.wfg.aop2.dao.IndexDaoImpl)")
public void after()
System.out.println("after==============");

@Around("target(com.wfg.aop2.dao.IndexDaoImpl)")
public void around(ProceedingJoinPoint joinPoint)
System.out.println("around start");
Object[] args = joinPoint.getArgs();
//修改参数
for (int i = 0; i <args.length ; i++)
args[i]=args[i]+" update";

String thisname = joinPoint.getThis().getClass().getName();
System.out.println(thisname);
String targetName = joinPoint.getTarget().getClass().getName();
System.out.println(targetName);
Signature signature = joinPoint.getSignature();
System.out.println(signature.getName());
try
joinPoint.proceed(args);
catch (Throwable throwable)
throwable.printStackTrace();

System.out.println("around end ");

package com.wfg.aop2;

import com.wfg.aop2.dao.IndexDao;
import com.wfg.aop2.dao.IndexDaoImpl;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.lang.reflect.Proxy;

/**
* @author wufagang
* @description
* @date 2021年04月24日 3:09 下午
*/

public class Test2
public static void main(String[] args)
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class);
IndexDao bean = context.getBean(IndexDao.class);
System.out.println("类名称:"+bean.getClass().getName());
System.out.println("bean instanceof IndexDao :"+(bean instanceof IndexDao));
System.out.println("bean instanceof IndexDaoImpl :"+(bean instanceof IndexDaoImpl));
System.out.println("bean instanceof Proxy :"+(bean instanceof Proxy));
bean.saveUser("zhangsan");

主要代码:

@Around("target(com.wfg.aop2.dao.IndexDaoImpl)")
public void around(ProceedingJoinPoint joinPoint)
System.out.println("around start");
Object[] args = joinPoint.getArgs();
//修改参数
for (int i = 0; i <args.length ; i++)
args[i]=args[i]+" update";

String thisname = joinPoint.getThis().getClass().getName();
System.out.println(thisname);
String targetName = joinPoint.getTarget().getClass().getName();
System.out.println(targetName);
Signature signature = joinPoint.getSignature();
System.out.println(signature.getName());
try
joinPoint.proceed(args);
catch (Throwable throwable)
throwable.printStackTrace();

System.out.println("around end ");

运行结果:

SpringAop环绕通知和JoinPoint


SpringAop环绕通知和JoinPoint


以上是关于joinpoint可以打开excel的主要内容,如果未能解决你的问题,请参考以下文章

Aop 中 JoinPoint等对象的用法Api

spring aop 利用JoinPoint获取参数的值和方法名称

AOP JoinPoint

SpringAop环绕通知和JoinPoint and ProceedingJoinPoint

Spring之Joinpoint类详解

spring14-----AOP之通知参数