click below
click below
Normal Size Small Size show me how
Spring AOP
Question | Answer |
---|---|
What is AspectJ? | AspectJ refers to a style of declaring aspects using annotated classes. Spring AOP implements a simple type of AspectJ. |
What is the difference between joinpoint and pointcut? | A joinpoint is a selectable point in the execution of an application. A pointcut is an expression targetting one or more join points. |
What is a Pointcut in regard to Spring AOP? | A Pointcut is a set of one or more join points where an advice should be executed. They can be specified by using an expression or patterns. You specificy a point cut as a parameter to an advice annotation. |
What is a join point in Spring AOP? 1 of 2 | A point during the execution of a program, such as the execution of a method or the handling of an exception. In Spring AOP, a join point ALWAYS represents a method execution. |
What is a join point in Spring AOP? 2 of 2 | An object version of a JoinPoint is given to an advice when it is called. This object contains information about the current state of the program's execution; like the method's signature or arguments. |
What are the types of Advice? 1 of 3 | ● @Before: Advice that executes before a join point. ● @AfterReturning: Advice to be executed after a join point completes normally: for example, if a method returns without throwing an exception. |
What are the types of Advice? 2 of 3 | ● @AfterThrowing: Advice to be executed if a method exits by throwing an exception. ● @After: Advice to be executed regardless of the means by which the method exits (normal or exceptional return). |
What are the types of Advice? 3 of 3 | ● @Around: Advice that surrounds a join point. This is the most powerful kind of advice. Around advice can perform custom behavior before and after the method invocation. It can also return its own return value or throwing an exception |
What do you mean by Advice? 1 of 2 | An action taken by an aspect at a particular point in the execution of the application (join point). An Advice takes the form of a method, in Spring. |
What do you mean by Advice? 2 of 2 | The method will be annotated with an annotation representing types of advice. The annotation is given a pointcut as a parameter. |
What is an Aspect ? | An aspect is a modularization of a concern that cuts across multiple objects. In Spring AOP, aspects are implemented using classes annotated with the @Aspect annotation. Inside of an aspect you'll find a collection of advice. |
What is AOP? 1 of 2 | AOP stands for Aspect Oriented Programming. AOP helps programmers manage cross-cutting concerns. |
What is AOP? 2 of 2 | It allows programmers to modularize crosscutting concerns. The core construct of AOP is the aspect, which encapsulates behaviors affecting multiple classes into reusable modules. |
What are cross-cutting concerns? 1 of 3 | Cross-cutting concerns are operations that take place frequently across a program. These necessary actions are boiler plate code, spread throughout the application. Some examples include exception handling, logging, transaction management, and caching. |
What are cross-cutting concerns? 2 of 3 | Two types of cross-cutting concerns are: code tangling and code scattering. Code tangling is when you have multiple CCCs (eg a single method needing to log and cache). |
What are cross-cutting concerns? 3 of 3 | Code scattering is when CCCs are needed in many places in your application (eg. many methods needs to log and create transactions). |