Skip to content

Instantly share code, notes, and snippets.

@edburns
Created February 18, 2025 20:13
Show Gist options
  • Save edburns/681a98d1d584cef83455b7d077839bbf to your computer and use it in GitHub Desktop.
Save edburns/681a98d1d584cef83455b7d077839bbf to your computer and use it in GitHub Desktop.
20250218-cdi-portable-extension.md

A CDI (Contexts and Dependency Injection) Portable Extension is a feature in CDI that allows developers to extend the CDI container's functionality in a portable, container-independent way. Portable extensions can leverage the CDI SPI (Service Provider Interface) to interact with the CDI container at various lifecycle events such as initialization, shutdown, and during the processing of beans.

Key characteristics of CDI Portable Extensions:

  • Portability: They are designed to work across different CDI implementations and containers.
  • Integration: They can interact with the CDI container lifecycle and modify the behavior of the CDI environment.
  • Customization: They allow adding custom behavior, such as registering new beans, interceptors, decorators, and observers.

In contrast, a non-portable CDI extension would typically be specific to a particular CDI implementation or container and may use non-standard APIs, making it less portable and reusable across different environments.

Summary:

  • Portable Extensions: Work across different CDI implementations, use the standard CDI SPI, and are container-independent.
  • Non-portable Extensions: Tied to a specific CDI implementation, may use non-standard APIs, and are not container-independent.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment