Mixing Different Parameters
Mixing Different Parameters Besides the previous examples, you can write overloaded advices using different return types and annotated parameters. Look at the following overloaded advice: public int overloadedAdvice(@Target POJO target) { System.out.println(">>> overloadedAdvice: int(Target POJO)"); return 0; } public void overloadedAdvice(@JoinPoint ConstructorExecution joinPoint) { System.out.println(">>> overloadedAdvice: (JoinPoint ConstructorExecution)"); } public void overloadedAdvice(@Target Object target) { System.out.println(">>> overloadedAdvice: (Target Object)"); } public void overloadedAdvice(@JoinPoint MethodCall joinPoint, @Caller Driver driver) { System.out.println(">>> overloadedAdvice: (JoinPoint MethodCall, Caller Driver)"); } public void overloadedAdvice(@JoinPoint JoinPointBean joinPoint, @Arg String arg) { System.out.println(">>> overloadedAdvice: JoinPoint JoinPointBean, Arg String"); } MixedParametersAspect.overloadedAdvice() has five different versions, and each one receives different parameter types. In this scenario, JBoss AOP will select the most appropriate version for each case. Run the example to see how this advice is applied to the different POJO joinpoints. To see all rules JBoss AOP uses to pick an overloaded advice version, please, read the corresponding chapter of the Reference Manual.