springboot之JoinPoint的getSignature方法

在使用springboot寫aop的時候,有個JoinPoint類,用來獲取代理類和被代理類的信息。

這個文章記錄一下JoinPoint的getSignature方法返回的是什麼格式。

不廢話,貼代碼

package org.aspectj.lang;

public interface Signature {
    String toString();

    String toShortString();

    String toLongString();

    String getName();

    int getModifiers();

    Class getDeclaringType();

    String getDeclaringTypeName();
}

打印輸出,getString是測試類的方法名,TestController是類名

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

冒號前面是使用的方法,後面是本次測試輸出的結果。

附上被測試的類:

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);
    }
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章