- @Model = @Named + @RequestScoped
- The @Named annotation just makes it possible to reference the bean from the EL
- it isn’t necessary to create a getter or setter method to inject one bean into another. CDI can access an injected field directly (even if it’s private!)
- Bean could be invoked by Unified EL.
- A bean type is a user-defined class or interface.
- Bean types may be restricted to an explicit set by annotating the bean with the @Typed annotation
- If an injection point does not explicitly specify a qualifier, it has the default qualifier, @Default.
- Don’t assign a scope other than @Dependent to an entity class
- @Produces used in factory method.
- @Alternative usually used in testing and must be enabled by config
Fixing unsatisfied and ambiguous dependencies
To fix an unsatisfied dependency, either:
- create a bean which implements the bean type and has all the qualifier types of the injection point,
- make sure that the bean you already have is in the classpath of the module with the injection point, or
- explicitly enable an @Alternative bean that implements the bean type and has the appropriate qualifier types, using beans.xml.
To fix an ambiguous dependency, either:
- introduce a qualifier to distinguish between the two implementations of the bean type,
- disable one of the beans by annotating it @Alternative,
- move one of the implementations to a module that is not in the classpath of the module with the injection point, or
- disable one of two @Alternative beans that are trying to occupy the same space, using beans.xml.