Skip to content
Ameen Abozaid
Planned lessonMID-009-L06

Demo: building a mini @Timed with a proxy

  • Lesson 6 of 6
  • Mid-level
On This Lesson 3 topics

This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.

In this lesson

build an annotation-driven interceptor; prepares MID-009-LAB1.

Draft outline details

Step by step

  1. Define @Timed (RUNTIME, METHOD) and an interface PriceService with an implementation.
  2. Write a Proxy.newProxyInstance handler that checks the annotation on the target method and logs elapsed time.
  3. Call through the proxy; see the timing log.
  4. Planned mistake: annotate only the interface method and read the annotation from the implementation class (not found). Fix: look up the annotation on the target class method (and note Spring's own lookup rules).
  5. Add an internal call between two methods; show it is not timed (self-invocation).
  6. Discuss reflection cost and caching Method lookups.

Practice

Apply this lesson with the module's lab, exercises and quiz.

Lab and exercises Quiz

Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.

Type to search levels, phases, modules and lessons.