I have created 2 custom spring @annotations
. I need to define the order of these annotations, on method-level, not on class-level. Does @order
, work on the method level, too?
@Aspect
@Component
public class ABC {
private ThreadLocal<logDTO> myThreadLocal;
@Before("@annotation(CommunicationLogInit)")
public void CampaignLogsInit(){
myThreadLocal = new ThreadLocal<logDTO>();
myThreadLocal.set(new logDTO());
}
@Around("@annotation(CommunicationAudit)")
public Object generateLog(ProceedingJoinPoint joinPoint) throws Throwable {
MethodSignature signature = (MethodSignature)joinPoint.getSignature();
Method method = signature.getMethod();
int counter = 0;
for(Parameter parameter : method.getParameters()){
Annotation eventName = parameter.getAnnotation(EventName.class);
Annotation rtnInfo = parameter.getAnnotation(RtnInfo.class);
if(eventName!=null){
System.out.println(joinPoint.getArgs()[counter]);
myThreadLocal.get().setName("ABC");
}
}
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…