Class HelidonRestCdiExtension<T extends RestServiceSupport>
- java.lang.Object
-
- io.helidon.servicecommon.restcdi.HelidonRestCdiExtension<T>
-
- Type Parameters:
T
- type ofRestServiceSupport
used
- All Implemented Interfaces:
Extension
- Direct Known Subclasses:
MetricsCdiExtension
,MicrometerCdiExtension
public abstract class HelidonRestCdiExtension<T extends RestServiceSupport> extends Object implements Extension
Abstract superclass of service-specific, REST-based CDI extensions.This class implements a substantial amount of the work many extensions must do to process annotated types for REST-based services.
Each CDI extension is presumed to layer on an SE-style service support class which itself is a subclass of
HelidonRestServiceSupport
with an associatedBuilder
class. The service support base class and its builder are both type parameters to this class.Each concrete implementation should:
- Invoke
recordAnnotatedType(javax.enterprise.inject.spi.ProcessAnnotatedType<?>)
for each class which bears an annotation of interest to the extension, often from aProcessAnnotatedType
observer method. - Implement
processManagedBean(ProcessManagedBean)
which this base class invokes to notify the implementation class of each managed bean type that was reported by the concrete extension but not vetoed by some other extension. Each extension can interpret "process" however it needs to. Metrics, for example, creates metrics and registers them with the appropriate metrics registry.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
HelidonRestCdiExtension.WorkItemsManager<W>
Manages a very simple multi-map ofExecutable
toClass<? extends Annotation>
to aSet
of typed work items.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
clearAnnotationInfo(AfterDeploymentValidation adv)
Cleans up any data structures created during annotation processing but which are not needed once the CDI container has started.protected boolean
isConcreteNonInterceptor(ProcessAnnotatedType<?> pat)
Checks to make sure the annotated type is not abstract and is not an interceptor.protected boolean
isOwnProducerOrNonDefaultQualified(Bean<?> bean, Class<?> ownProducerClass)
protected void
observeManagedBeans(ProcessManagedBean<?> pmb)
Observes all managed beans but immediately dismisses ones for which the Java class was not previously noted by theProcessAnnotatedType
observer (which recorded only classes with selected annotations).protected abstract void
processManagedBean(ProcessManagedBean<?> processManagedBean)
Deals with a managed bean that survived vetoing, provided by concrete extension implementations.protected Map<Bean<?>,AnnotatedMember<?>>
producers()
protected void
recordAnnotatedType(ProcessAnnotatedType<?> pat)
Records the Java class underlying an annotated type.protected void
recordProducerField(ProcessProducerField<?,?> ppf)
Records a producer field defined by the application.protected void
recordProducerMethod(ProcessProducerMethod<?,?> ppm)
Records a producer method defined by the application.protected Routing.Builder
registerService(Object adv, BeanManager bm, ServerCdiExtension server)
Registers the service-related endpoint, after security and as CDI initializes the app scope, returning the default routing for optional use by the caller.protected T
serviceSupport()
-
-
-
Constructor Detail
-
HelidonRestCdiExtension
protected HelidonRestCdiExtension(Logger logger, Function<Config,T> serviceSupportFactory, String configPrefix)
Common initialization for concrete implementations.- Parameters:
logger
- Logger instance to use for logging messagesserviceSupportFactory
- function from config to the corresponding SE-style service support objectconfigPrefix
- prefix for retrieving config related to this extension
-
-
Method Detail
-
clearAnnotationInfo
protected void clearAnnotationInfo(@Observes AfterDeploymentValidation adv)
Cleans up any data structures created during annotation processing but which are not needed once the CDI container has started.- Parameters:
adv
- theAfterDeploymentValidation
event
-
observeManagedBeans
protected void observeManagedBeans(@Observes ProcessManagedBean<?> pmb)
Observes all managed beans but immediately dismisses ones for which the Java class was not previously noted by theProcessAnnotatedType
observer (which recorded only classes with selected annotations).- Parameters:
pmb
- event describing the managed bean being processed
-
processManagedBean
protected abstract void processManagedBean(ProcessManagedBean<?> processManagedBean)
Deals with a managed bean that survived vetoing, provided by concrete extension implementations.The meaning of "process" varies among the concrete implementations. At this point, this base implementation has managed the annotation processing in a general way (e.g., only non-vetoed beans survive) and now delegates to the concrete implementations to actually respond appropriately to the bean and whichever of its members are annotated.
- Parameters:
processManagedBean
- the managed bean, with at least one annotation of interest to the extension
-
isConcreteNonInterceptor
protected boolean isConcreteNonInterceptor(ProcessAnnotatedType<?> pat)
Checks to make sure the annotated type is not abstract and is not an interceptor.- Parameters:
pat
-ProcessAnnotatedType
event- Returns:
- true if the annotated type should be kept for potential processing later; false otherwise
-
recordAnnotatedType
protected void recordAnnotatedType(ProcessAnnotatedType<?> pat)
Records the Java class underlying an annotated type.- Parameters:
pat
-ProcessAnnotatedType
event
-
isOwnProducerOrNonDefaultQualified
protected boolean isOwnProducerOrNonDefaultQualified(Bean<?> bean, Class<?> ownProducerClass)
-
recordProducerField
protected void recordProducerField(ProcessProducerField<?,?> ppf)
Records a producer field defined by the application. Ignores producers with non-default qualifiers and library producers.- Parameters:
ppf
- Producer field.
-
recordProducerMethod
protected void recordProducerMethod(ProcessProducerMethod<?,?> ppm)
Records a producer method defined by the application. Ignores producers with non-default qualifiers and library producers.- Parameters:
ppm
- Producer method.
-
producers
protected Map<Bean<?>,AnnotatedMember<?>> producers()
-
registerService
protected Routing.Builder registerService(@Observes @Priority(1010) @Initialized(javax.enterprise.context.ApplicationScoped.class) Object adv, BeanManager bm, ServerCdiExtension server)
Registers the service-related endpoint, after security and as CDI initializes the app scope, returning the default routing for optional use by the caller.- Parameters:
adv
- app-scoped initialization eventbm
- BeanManagerserver
- the ServerCdiExtension- Returns:
- default routing
-
serviceSupport
protected T serviceSupport()
-
-