Skip to content

Day 02 — Qualifiers, Producers, Interceptors & Decoupled Events

Daily Time Investment: 2.5 hours | Week: 1 | Phase: 3


Daily Schedule

Segment Duration Activity
Core Theory 45 min Custom @Qualifier, @Produces/@Disposes, @AroundInvoke, @Observes/@ObservesAsync
Book Reading 30 min EE8 AppDev Ch5 (Qualifiers & Events) + EE Patterns Ch5 (Interceptors)
Hands-On Lab 75 min @Monitored interceptor with ThreadMXBean; decoupled audit event bus

Files in This Day

  • EE8 AppDev Ch5 — Qualifiers & CDI Events


    Qualifiers, @Produces, @Disposes, synchronous vs async events, event ordering with @Priority.

    Chapter 5 scopes & injection are in Day 01 — this page focuses on the advanced wiring section.

    Read Ch5 Advanced Section

  • EE Patterns Ch5 — Infrastructural Patterns


    Adam Bien's patterns: Service Starter (@Startup @Singleton), Singleton caching, Thread Tracker (@AroundInvoke), Context Holder (TransactionSynchronizationRegistry), Bean Locator, Payload Extractor, Dependency Injection Extender.

    Read EE Patterns Ch5

  • Lab Guide — CDI Advanced Wiring


    Build enum-backed qualifiers, @Produces/@Disposes resource factories, @AroundInvoke performance interceptors, and sync+async CDI event bus using Weld SE.

    Start Lab


Prerequisites to Continue

New concepts in Phase 3 not seen in Phase 1 or Phase 2

  • InvocationContext — CDI passes this to @AroundInvoke methods; gives access to getMethod(), getParameters(), getTarget(), and critically proceed() (calls the actual method)
  • ManagementFactory.getThreadMXBean() — returns ThreadMXBean for per-thread CPU time; bridges Phase 2 JVM internals into Phase 3 interceptors
  • Record types as event payloads — Java 16+ records (record AuditEvent(String id, Instant time) {}) are ideal CDI event payloads — immutable, value-based, no boilerplate
  • CompletionStage — returned by event.fireAsync() — the same CompletionStage/CompletableFuture from Phase 1 concurrency
  • @InterceptorBinding vs @Qualifier — both are meta-annotations but serve different purposes: qualifiers disambiguate injection, interceptor bindings attach cross-cutting behavior

Back to Week 1