It's my annotation class:
@Target(AnnotationTarget.FUNCTION)
@Retention(AnnotationRetention.RUNTIME)
annotation class ExternalCallMonitor(val system: String, val function: String)
Using SpEL to set annotation value as follows;
@ExternalCallMonitor(system = "#{@url.getHost()}", function = "#{@url.getPath()}")
fun methodWithUrlParameter(url: URL) {
// Do nothing
}
Trying to get value in the Aspect as follows
@Around("@annotation(aspect.external.ExternalCallMonitor)")
@Throws(Throwable::class)
fun externalCallMonitor(joinPoint: ProceedingJoinPoint): Any? {
val methodName = joinPoint.signature.name
val signature = joinPoint.signature as MethodSignature
val method = joinPoint.target.javaClass.getMethod(signature.method.name, URL::class.java)
val annotation = method.getAnnotation(ExternalCallMonitor::class.java)
val host = annotation.system
host
should be localhost
here but I am getting "#{@url.getHost()}"
question from:
https://stackoverflow.com/questions/65842885/using-spel-as-annotation-value 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…