Class ResteasyParamCdiExtension

java.lang.Object
org.jboss.resteasy.cdi.ResteasyParamCdiExtension
All Implemented Interfaces:
jakarta.enterprise.inject.spi.Extension

public class ResteasyParamCdiExtension extends Object implements jakarta.enterprise.inject.spi.Extension
A CDI Extension that enables Jakarta REST parameter annotations (@CookieParam, @FormParam, @HeaderParam, @MatrixParam, @PathParam, @QueryParam, and @BeanParam) to function as CDI qualifiers. This allows Jakarta REST resource classes to receive parameter values via CDI constructor injection rather than requiring a public no-arg constructor.

The extension operates in four CDI lifecycle phases:

  1. BeforeBeanDiscovery — registers each @*Param annotation as a CDI qualifier
  2. ProcessAnnotatedType — adds @Inject to @*Param-annotated fields, setter methods, and constructors so that CDI resolves parameter values automatically. RESTEasy-specific annotations (org.jboss.resteasy.annotations.jaxrs.*Param) are also handled by adding the corresponding Jakarta REST annotation alongside @Inject.
  3. ProcessInjectionPoint — collects the types of all @*Param-annotated injection points
  4. AfterBeanDiscovery — registers synthetic beans that produce parameter values at request time by delegating to ParameterExtractors
Author:
James R. Perkins
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    <T> void
    observeParamResources(jakarta.enterprise.inject.spi.ProcessAnnotatedType<T> event)
    Observes Jakarta REST resource types and adds @Inject to fields, setter methods, and constructors annotated with @*Param annotations so that CDI can resolve parameter values via the synthetic beans registered by this extension.
    <T,X> void
    processInjectionPoint(jakarta.enterprise.inject.spi.ProcessInjectionPoint<T,X> pip)
    Observes each injection point during bean discovery and records the types of any injection points annotated with a @*Param qualifier.
    void
    registerParamQualifiers(jakarta.enterprise.inject.spi.AfterBeanDiscovery afd)
    Registers the @*Param annotations as CDI qualifiers with producers.
    void
    registerQualifiers(jakarta.enterprise.inject.spi.BeforeBeanDiscovery event)
    Registers each @*Param annotation as a CDI qualifier, marking all annotation members as Nonbinding so that qualifier resolution matches on presence alone rather than on member values.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ResteasyParamCdiExtension

      public ResteasyParamCdiExtension()
  • Method Details

    • registerQualifiers

      public void registerQualifiers(@Observes jakarta.enterprise.inject.spi.BeforeBeanDiscovery event)
      Registers each @*Param annotation as a CDI qualifier, marking all annotation members as Nonbinding so that qualifier resolution matches on presence alone rather than on member values.
      Parameters:
      event - the before bean discovery event
    • observeParamResources

      public <T> void observeParamResources(@Observes jakarta.enterprise.inject.spi.ProcessAnnotatedType<T> event)
      Observes Jakarta REST resource types and adds @Inject to fields, setter methods, and constructors annotated with @*Param annotations so that CDI can resolve parameter values via the synthetic beans registered by this extension. This covers both Jakarta REST annotations (jakarta.ws.rs.*Param) and RESTEasy-specific annotations (org.jboss.resteasy.annotations.jaxrs.*Param).
      Type Parameters:
      T - the type being processed
      Parameters:
      event - the annotated type being processed
    • registerParamQualifiers

      public void registerParamQualifiers(@Observes jakarta.enterprise.inject.spi.AfterBeanDiscovery afd)
      Registers the @*Param annotations as CDI qualifiers with producers.
      Parameters:
      afd - the after bean discovery event
    • processInjectionPoint

      public <T,X> void processInjectionPoint(@Observes jakarta.enterprise.inject.spi.ProcessInjectionPoint<T,X> pip)
      Observes each injection point during bean discovery and records the types of any injection points annotated with a @*Param qualifier. These types are later used to register synthetic producer beans.
      Type Parameters:
      T - the bean class of the bean that declares the injection point
      X - the declared type of the injection point
      Parameters:
      pip - the process injection point event