Class HelidonRestCdiExtension
- All Implemented Interfaces:
Extension
- Direct Known Subclasses:
HealthCdiExtension,MetricsCdiExtension,MicrometerCdiExtension,OpenApiCdiExtension
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
HelidonFeatureSupport with an associated Builder class.
The service support base class and its builder are both type parameters to this class.
Each concrete implementation should:
- Invoke
recordAnnotatedType(jakarta.enterprise.inject.spi.ProcessAnnotatedType<?>)for each class which bears an annotation of interest to the extension, often from aProcessAnnotatedTypeobserver 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 ClassesModifier and TypeClassDescriptionprotected static classManages a very simple multi-map ofExecutabletoClass<? extends Annotation>to aSetof typed work items. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedHelidonRestCdiExtension(System.Logger logger, String... configPrefixes) Common initialization for concrete implementations. -
Method Summary
Modifier and TypeMethodDescriptionvoidCleans up any data structures created during annotation processing but which are not needed once the CDI container has started.protected ConfigSE Configuration of the current compoennt.protected booleanChecks to make sure the annotated type is not abstract and is not an interceptor.protected booleanisOwnProducerOrNonDefaultQualified(Bean<?> bean, Class<?> ownProducerClass) protected static StringnestedConfigKey(String suffix) Returns the config key for settings for the specified suffix nested within the server config tree.voidObserves all managed beans but immediately dismisses ones for which the Java class was not previously noted by theProcessAnnotatedTypeobserver (which recorded only classes with selected annotations).voidprepareRuntime(Config config) Configure with runtime config.protected voidprocessManagedBean(ProcessManagedBean<?> processManagedBean) Deals with a managed bean that survived vetoing, provided by concrete extension implementations.protected Map<Bean<?>, AnnotatedMember<?>> protected voidRecords the Java class underlying an annotated type.protected voidrecordProducerField(ProcessProducerField<?, ?> ppf) Records a producer field defined by the application.protected voidrecordProducerMethod(ProcessProducerMethod<?, ?> ppm) Records a producer method defined by the application.protected ConfigSE Configuration, root.protected HttpRouting.BuilderroutingBuilder(ServerCdiExtension server) Find routing builder to use for this component to be registered on.
-
Constructor Details
-
HelidonRestCdiExtension
Common initialization for concrete implementations.- Parameters:
logger- Logger instance to use for logging messagesconfigPrefixes- prefixes for retrieving config related to this extension
-
-
Method Details
-
clearAnnotationInfo
Cleans up any data structures created during annotation processing but which are not needed once the CDI container has started.- Parameters:
adv- theAfterDeploymentValidationevent
-
observeManagedBeans
Observes all managed beans but immediately dismisses ones for which the Java class was not previously noted by theProcessAnnotatedTypeobserver (which recorded only classes with selected annotations).- Parameters:
pmb- event describing the managed bean being processed
-
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
Checks to make sure the annotated type is not abstract and is not an interceptor.- Parameters:
pat-ProcessAnnotatedTypeevent- Returns:
- true if the annotated type should be kept for potential processing later; false otherwise
-
recordAnnotatedType
Records the Java class underlying an annotated type.- Parameters:
pat-ProcessAnnotatedTypeevent
-
isOwnProducerOrNonDefaultQualified
-
recordProducerField
Records a producer field defined by the application. Ignores producers with non-default qualifiers and library producers.- Parameters:
ppf- Producer field.
-
recordProducerMethod
Records a producer method defined by the application. Ignores producers with non-default qualifiers and library producers.- Parameters:
ppm- Producer method.
-
producers
-
rootConfig
SE Configuration, root.- Returns:
- config instance
-
componentConfig
SE Configuration of the current compoennt.- Returns:
- component configuration
-
routingBuilder
Find routing builder to use for this component to be registered on. Uses theroutingkey on the service level to choose the correct routing (listener).- Parameters:
server- server CDI extension- Returns:
- routing builder to use
-
nestedConfigKey
Returns the config key for settings for the specified suffix nested within the server config tree.- Parameters:
suffix- the config key suffix (typically the name of the component: e.g., health)- Returns:
- full nested config key for the specified suffix
-
prepareRuntime
Configure with runtime config.- Parameters:
config- config to use
-