Context and Dependency Injection (CDI) Advanced (Java EE 6)
Topics
- Producer
- Events
- Alternatives
- Interceptor
- Decorator
- Stereotype T
Producer
Producer Method (@Produces)
- Producer methods allow control over the production of the dependency objects
- Runtime polymorphism – Producer can return different object depending on runtime condition (business logic, time of the day, etc)
- Creation of Non-bean instance - Objects to be injected are not required to be instances of beans
- Custom setup - Objects require some custom initialization that is not performed by the bean constructor
- Enables decoupling of a “producer” from the “consumer” (of dependency objects)
- Enables type-safe programming model for injecting Java EE resources