BeanManager

The core piece in extending CDI with extensions is the BeanManager, as it provides programmatic access to a CDI container via an API. BeanManager provides many useful operations for developers writing an extension, some of which include the ability to obtain beans, interceptors, decorators, observers, and contexts.

Accessing the BeanManager is not restricted to injection into extension observer methods; we are able to inject it into any bean or other Java EE component that supports injection.

@Inject
BeanManager beanManager;

Note

There is no restriction on when the BeanManager methods can be called during the life of an application.

Get JBoss Weld CDI for Java Platform now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.