Spring Certified Professional 2023 · Free Practice Question Medium

Question 14

______ is linking aspects with other application types or objects to create an advised object.

  • A

    Deferring

  • B

    Threading

  • C

    Pooling

  • D

    Weaving

Reveal correct answer

Correct answer: D

Explanation

Weaving: linking aspects with other application types or objects to create an advised object. This can be done at compile time (using the AspectJ compiler, for example), load time, or runtime. Spring AOP, like other pure Java AOP frameworks, performs weaving at runtime.

https://docs.spring.io/spring-framework/docs/3.0.x/spring-framework-reference/html/aop.html#aop-introduction-defn


Here's an example code snippet that demonstrates AOP weaving in Spring:

In the above code, the LoggingAspect class is an aspect that defines a @Before advice. It intercepts the execution of methods in the com.example.service package and logs a message before the method execution. This is achieved through AOP weaving, where the aspect is woven into the target object (in this case, MyService class) at runtime.

Discussion

Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.

You must be logged in to post a comment.

Preparing For

Your Certification?

255+ certifications
Detailed explanations
Free PDF samples

Has All The Questions You Need