Class ResteasyCdiExtension
java.lang.Object
org.jboss.resteasy.cdi.ResteasyCdiExtension
- All Implemented Interfaces:
jakarta.enterprise.inject.spi.Extension
This Extension handles default scopes for discovered JAX-RS components. It
also observes ProcessInjectionTarget event and wraps InjectionTargets
representing JAX-RS components within JaxrsInjectionTarget. Furthermore, it
builds the sessionBeanInterface map which maps Session Bean classes to a
local interface. This map is used in CdiInjectorFactory during lookup of
Sesion Bean JAX-RS components.
- Author:
- Jozef Hartinger
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addContextProducer
(jakarta.enterprise.inject.spi.AfterTypeDiscovery event, jakarta.enterprise.inject.spi.BeanManager beanManager) If theContextProducers
were not discovered, we need to add the type for the producers.static boolean
<T extends jakarta.ws.rs.core.Application>
voidobserveApplications
(jakarta.enterprise.inject.spi.ProcessAnnotatedType<T> event, jakarta.enterprise.inject.spi.BeanManager beanManager) Set a default scope for each CDI bean which is a JAX-RS Application subclass.void
observeBeforeBeanDiscovery
(jakarta.enterprise.inject.spi.BeforeBeanDiscovery event) Obtain BeanManager reference for future use.void
observeContextProducer
(jakarta.enterprise.inject.spi.ProcessAnnotatedType<ContextProducers> event) A simple observer to indicate theContextProducers
should not be dynamically registered.<T> void
observeInjectionTarget
(jakarta.enterprise.inject.spi.ProcessInjectionTarget<T> event) Wrap InjectionTarget of JAX-RS components within JaxrsInjectionTarget which takes care of JAX-RS property injection.<T> void
observeProviders
(jakarta.enterprise.inject.spi.ProcessAnnotatedType<T> event, jakarta.enterprise.inject.spi.BeanManager beanManager) Set a default scope for each CDI bean which is a JAX-RS Provider.<T> void
observeResources
(jakarta.enterprise.inject.spi.ProcessAnnotatedType<T> event, jakarta.enterprise.inject.spi.BeanManager beanManager) Set a default scope for each CDI bean which is a JAX-RS Resource.<T> void
observeSessionBeans
(jakarta.enterprise.inject.spi.ProcessSessionBean<T> event) Observes ProcessSessionBean events and creates a (Bean class -> Local interface) map for Session beans with local interfaces.void
processClientBean
(jakarta.enterprise.inject.spi.ProcessBean<?> pb) Process any client beans.void
registerClientProducer
(jakarta.enterprise.inject.spi.AfterBeanDiscovery event) Registers a producer and disable for aREST client
.protected <T> jakarta.enterprise.inject.spi.InjectionTarget
<T> wrapInjectionTarget
(jakarta.enterprise.inject.spi.ProcessInjectionTarget<T> event)
-
Constructor Details
-
ResteasyCdiExtension
public ResteasyCdiExtension()
-
-
Method Details
-
isCDIActive
public static boolean isCDIActive() -
observeBeforeBeanDiscovery
public void observeBeforeBeanDiscovery(@Observes jakarta.enterprise.inject.spi.BeforeBeanDiscovery event) Obtain BeanManager reference for future use.- Parameters:
event
- event
-
processClientBean
public void processClientBean(@Observes jakarta.enterprise.inject.spi.ProcessBean<?> pb) Process any client beans.- Parameters:
pb
- the bean being processed
-
registerClientProducer
public void registerClientProducer(@Observes jakarta.enterprise.inject.spi.AfterBeanDiscovery event) Registers a producer and disable for aREST client
.- Parameters:
event
- the after bean discovery event
-
observeContextProducer
public void observeContextProducer(@Observes jakarta.enterprise.inject.spi.ProcessAnnotatedType<ContextProducers> event) A simple observer to indicate theContextProducers
should not be dynamically registered.- Parameters:
event
- the event
-
addContextProducer
public void addContextProducer(@Observes jakarta.enterprise.inject.spi.AfterTypeDiscovery event, jakarta.enterprise.inject.spi.BeanManager beanManager) If theContextProducers
were not discovered, we need to add the type for the producers.- Parameters:
event
- the eventbeanManager
- the bean manager
-
observeResources
public <T> void observeResources(@Observes jakarta.enterprise.inject.spi.ProcessAnnotatedType<T> event, jakarta.enterprise.inject.spi.BeanManager beanManager) Set a default scope for each CDI bean which is a JAX-RS Resource.- Type Parameters:
T
- type- Parameters:
event
- eventbeanManager
- bean manager
-
observeProviders
public <T> void observeProviders(@Observes jakarta.enterprise.inject.spi.ProcessAnnotatedType<T> event, jakarta.enterprise.inject.spi.BeanManager beanManager) Set a default scope for each CDI bean which is a JAX-RS Provider.- Type Parameters:
T
- type- Parameters:
event
- eventbeanManager
- bean manager
-
observeApplications
public <T extends jakarta.ws.rs.core.Application> void observeApplications(@Observes jakarta.enterprise.inject.spi.ProcessAnnotatedType<T> event, jakarta.enterprise.inject.spi.BeanManager beanManager) Set a default scope for each CDI bean which is a JAX-RS Application subclass.- Type Parameters:
T
- type- Parameters:
event
- eventbeanManager
- bean manager
-
observeInjectionTarget
public <T> void observeInjectionTarget(@Observes jakarta.enterprise.inject.spi.ProcessInjectionTarget<T> event) Wrap InjectionTarget of JAX-RS components within JaxrsInjectionTarget which takes care of JAX-RS property injection.- Type Parameters:
T
- type- Parameters:
event
- event
-
wrapInjectionTarget
protected <T> jakarta.enterprise.inject.spi.InjectionTarget<T> wrapInjectionTarget(jakarta.enterprise.inject.spi.ProcessInjectionTarget<T> event) -
observeSessionBeans
public <T> void observeSessionBeans(@Observes jakarta.enterprise.inject.spi.ProcessSessionBean<T> event) Observes ProcessSessionBean events and creates a (Bean class -> Local interface) map for Session beans with local interfaces. This map is necessary since RESTEasy identifies a bean class as JAX-RS components while CDI requires a local interface to be used for lookup.- Type Parameters:
T
- type- Parameters:
event
- event
-
getSessionBeanInterface
-