Cuando se usa springboot para escribir aop, se usa una clase JoinPoint para obtener información sobre la clase de proxy y la clase de proxy.
Este artículo registra el formato devuelto por el método getSignature de JoinPoint.
Primero veamos el código interno del método getSignature:
package org.aspectj.lang;
public interface Signature {
String toString();
String toShortString();
String toLongString();
String getName();
int getModifiers();
Class getDeclaringType();
String getDeclaringTypeName();
}
Mire nuevamente el punto de conexión, que es la clase que se está probando:
package com.fast.web.controller;
import com.fast.framework.dao.TestDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class TestController {
@Autowired
private TestDao testDao;
@RequestMapping("/test")
public String getString() {
int i = testDao.selectBase();
return String.valueOf(i);
}
}
Finalmente, mire la impresión: getString es el nombre del método de la clase de prueba y TestController es el nombre de la clase.
joinPoint.getSignature().toString():---》String com.fast.web.controller.TestController.getString()
joinPoint.getSignature().toShortString():---》TestController.getString()
joinPoint.getSignature().toLongString():---》public java.lang.String com.fast.web.controller.TestController.getString()
joinPoint.getSignature().getName():---》getString
joinPoint.getSignature().getModifiers():---》1
joinPoint.getSignature().getDeclaringType():---》class com.fast.web.controller.TestController
joinPoint.getSignature().getDeclaringTypeName():---》com.fast.web.controller.TestController
:—》El anverso es el método utilizado y el reverso es el resultado de salida de esta prueba.