Q: Which advice combines all advices into one?
Solution: It gains full control of a join point, so you can combine all the actions of the preceding advices into one single advice. You can even control when, and whether, to proceed with the original join point execution.
Q: An advice can access the current join point information by declaring an argument of type org.aspectj.lang.AdvicePoint in the advice method signature.
Solution: An advice can access the current join point information by declaring an argument of type org.aspectj.lang.JoinPoint in the advice method signature.
Q: Which interface is implemented to specify precedence of aspects?
Solution: The precedence of aspects can be specified either by implementing the Ordered interface.
Q: Alternative annotative way to specify precedence of aspects?
Solution: The precedence of aspects can be specified either by implementing the Ordered interface or @Order Annotation.
Q: Method which returns the highest priority of aspect’s join point?
Solution: The lower value returned by the getOrder() method represents higher priority.
Q: Which instantiation model is supported by AspectJ?
Solution: Spring supports AspectJ perthis and pertarget instantiation models.
Q: Which instantiation model is supported by AspectJ?
Solution: percflow, percflowbelow, and pertypewithin are not currently supported.
Q: Which tag in XML is used to declare @Before advice’s method?
Solution: Before advice runs before a matched method execution. It is declared inside an aop:aspect using the aop:before element.
Q: Which tag in XML is used to declare @Before advice’s method?
Solution: After returning advice runs when a matched method execution completes normally. It is declared inside an aop:aspect in the same way as before advice.
Q: What will be the output of the code snippet? import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.AfterThrowing; @Aspect public class AfterThrowingExample { @AfterThrowing( pointcut="com.xyz.myapp.SystemArchitecture.dataAccessOperation()", throwing="ex") public void doRecoveryActions(DataAccessException e) { throw new IllegalArgumentException(); // ... } }
Solution: The throwing keyword in pointcut annotation doesn’t matches with the method’s parameter exception.
You Have Score    | /10 |