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:
BeforeBeanDiscovery— registers each@*Paramannotation as a CDI qualifierProcessAnnotatedType— adds@Injectto@*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.ProcessInjectionPoint— collects the types of all@*Param-annotated injection pointsAfterBeanDiscovery— registers synthetic beans that produce parameter values at request time by delegating toParameterExtractors
- Author:
- James R. Perkins
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> voidobserveParamResources(jakarta.enterprise.inject.spi.ProcessAnnotatedType<T> event) Observes Jakarta REST resource types and adds@Injectto fields, setter methods, and constructors annotated with@*Paramannotations 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@*Paramqualifier.voidregisterParamQualifiers(jakarta.enterprise.inject.spi.AfterBeanDiscovery afd) Registers the@*Paramannotations as CDI qualifiers with producers.voidregisterQualifiers(jakarta.enterprise.inject.spi.BeforeBeanDiscovery event) Registers each@*Paramannotation as a CDI qualifier, marking all annotation members asNonbindingso that qualifier resolution matches on presence alone rather than on member values.
-
Constructor Details
-
ResteasyParamCdiExtension
public ResteasyParamCdiExtension()
-
-
Method Details
-
registerQualifiers
public void registerQualifiers(@Observes jakarta.enterprise.inject.spi.BeforeBeanDiscovery event) Registers each@*Paramannotation as a CDI qualifier, marking all annotation members asNonbindingso 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@Injectto fields, setter methods, and constructors annotated with@*Paramannotations 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@*Paramannotations 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@*Paramqualifier. These types are later used to register synthetic producer beans.- Type Parameters:
T- the bean class of the bean that declares the injection pointX- the declared type of the injection point- Parameters:
pip- the process injection point event
-