private Media getMethodAnnotation(ProceedingJoinPoint pjp)
throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
MethodInvocationProceedingJoinPoint methodPjp = (MethodInvocationProceedingJoinPoint) pjp;
Field field = methodPjp.getClass().getDeclaredField("methodInvocation");
field.setAccessible(true);
ProxyMethodInvocation invocation = (ProxyMethodInvocation) field.get(methodPjp);
Media media = invocation.getMethod().getAnnotation(Media.class);
return media;
}get
此處 Media 是自定義註解it
拿到方法io
Signature signature = pjp.getSignature();
MethodSignature methodSignature = (MethodSignature) signature;
Method targetMethod = methodSignature.getMethod();class