
Conforming to the official specification, a producer field can be used:
• instead of a simple getter method
• for declaring Java EE resources
Moreover, a producer method can be used – producer methods acts as sources of bean instances:
• to inject non-beans objects (expose any JDK class as a bean)
• to inject objects that have type that vary at runtime (vary the implementation of a bean type at runtime)
• to inject objects that requires some custom initialization that the bean constructor does not perform (define multiple beans, with different scopes or initialization, for the same implementation class).
No comments:
Post a Comment