Class DynTabDiscoveryExtension
- All Implemented Interfaces:
jakarta.enterprise.inject.spi.Extension
@DynTab annotations during bootstrap.
This eliminates the need for manual registration in a DynTabConfig subclass.
The developer just places the @DynTab annotation on the bean and that's it!
How it works:
- During CDI bootstrap,
processDynTabAnnotation(jakarta.enterprise.inject.spi.ProcessAnnotatedType<T>)is called for each class that has a@DynTabannotation (one or more, thanks to@Repeatable) - Tab information is stored in the static list
discoveredTabs - After deployment,
afterDeploymentValidation(jakarta.enterprise.inject.spi.AfterDeploymentValidation, jakarta.enterprise.inject.spi.BeanManager)only logs the result DynTabRegistryin its@PostConstructcallsgetDiscoveredTabs()and registers all discovered tabs
IMPORTANT: The Extension does NOT access CDI beans (does not use CDI.current()).
Reason: during the Extension lifecycle, the EE environment is not yet fully started,
and accessing CDI beans causes a SEVERE error on GlassFish:
"No valid EE environment for injection of..."
Instead, the Extension only collects data, and DynTabRegistry retrieves it later.
@Repeatable support:
A class can have one or more @DynTab annotations. When there are multiple,
the Java compiler automatically wraps them in a @DynTabs container annotation.
This Extension handles both cases using getAnnotationsByType().
Registration:
The Extension is automatically loaded because it is registered in
META-INF/services/jakarta.enterprise.inject.spi.Extension
- Author:
- DynTabs
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classPublic class that holds data about a single discovered@DynTab. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidafterDeploymentValidation(jakarta.enterprise.inject.spi.AfterDeploymentValidation adv, jakarta.enterprise.inject.spi.BeanManager bm) Called after CDI deployment is complete.Returns the list of all discovered@DynTabannotations.<T> voidprocessDynTabAnnotation(jakarta.enterprise.inject.spi.ProcessAnnotatedType<T> pat) Called for each class that has a@DynTabor@DynTabsannotation during CDI scanning.
-
Constructor Details
-
DynTabDiscoveryExtension
public DynTabDiscoveryExtension()
-
-
Method Details
-
getDiscoveredTabs
Returns the list of all discovered@DynTabannotations. Called fromDynTabRegistry.init()for tab registration.- Returns:
- an unmodifiable list of discovered tabs
-
processDynTabAnnotation
public <T> void processDynTabAnnotation(@Observes jakarta.enterprise.inject.spi.ProcessAnnotatedType<T> pat) Called for each class that has a@DynTabor@DynTabsannotation during CDI scanning.Uses
getAnnotationsByType(DynTab.class)instead ofgetAnnotation(DynTab.class)to cover both a single@DynTaband multiple@DynTab(wrapped in@DynTabs).getAnnotationsByType()works for both cases:- Single
@DynTabannotation -> returns an array with one element - Multiple
@DynTab(wrapped in@DynTabs) -> returns an array with all elements
- Type Parameters:
T- the class type- Parameters:
pat- ProcessAnnotatedType event with class information
- Single
-
afterDeploymentValidation
public void afterDeploymentValidation(@Observes jakarta.enterprise.inject.spi.AfterDeploymentValidation adv, jakarta.enterprise.inject.spi.BeanManager bm) Called after CDI deployment is complete.Does not access CDI beans - only logs the scanning result. Actual tab registration happens in
DynTabRegistry.init().- Parameters:
adv- AfterDeploymentValidation eventbm- BeanManager
-