A portable extension is a Java Service Provider that is retrieved during container startup by Weld and notified at each stage of the container lifecycle, based on which events our portable extension needs to observe.
What a portable extension can achieve within CDI is only limited by our imagination and the current SPI that is available in a particular release!
As stated in the specification:
A portable extension may integrate with the container by:
Providing its own beans, interceptors, and decorators to the container
Injecting dependencies into its own objects using the dependency injection service
Providing a context implementation for a custom scope
Augmenting or overriding the annotation-based metadata with metadata from some other source
To create a portable extension, we only need to complete two steps:
Write a Java class that implements
javax.enterprise.inject.spi.Extension
as follows:public class OurExtension implements Extension { ... }
Register the...