官术网_书友最值得收藏!

Scope of producer methods

By default, producer methods run in the @Dependent scope; this means that each time an instance is requested to be injected within any context, a new instance of the bean will be created. However, you can customize this, by annotating your producer method with a scope annotation, as in the following example:

@SessionScoped 
public class Preferences implements Serializable { 
    ... 
    @Produces 
    @Preferred 
    @RequestScoped 
    public PaymentStrategy getPaymentStrategy() { ... } 
} 

In this example, only one instance of the PaymentStrategy bean will be instantiated per user request.

主站蜘蛛池模板: 上高县| 吉林市| 呼图壁县| 来宾市| 盐源县| 汾西县| 加查县| 当雄县| 双峰县| 永泰县| 黄龙县| 江门市| 图片| 门源| 大余县| 老河口市| 定安县| 缙云县| 株洲县| 贞丰县| 珲春市| 郑州市| 株洲县| 中方县| 秭归县| 台东市| 和硕县| 文安县| 麻阳| 贞丰县| 开平市| 乌兰察布市| 麻栗坡县| 新民市| 阿图什市| 峨眉山市| 海淀区| 郸城县| 定州市| 苍山县| 东源县|