java用语cdi_java – 命名CDI bean的默认范围是什么?

默认范围是依赖的伪范围@Dependent,如

weld documentation中所述:

CDI features the so-called dependent pseudo-scope. This is the default

scope for a bean which does not explicitly declare a scope type. […]

An instance of a dependent bean is never shared between different

clients or different injection points. It is strictly a dependent

object of some other object. It is instantiated when the object it

belongs to is created, and destroyed when the object it belongs to is

destroyed.

Beans declared with scope @Dependent behave differently to beans with

other built-in scope types. When a bean is declared to have scope

@Dependent:

No injected instance of the bean is ever shared between multiple injection points.

Any instance of the bean injected into an object that is being created by the container is bound to the lifecycle of the newly

created object.

When a Unified EL expression in a JSF or JSP page that refers to the bean by its EL name is evaluated, at most one instance of the

bean is instantiated. This instance exists to service just a single

evaluation of the EL expression. It is reused if the bean EL name

appears multiple times in the EL expression, but is never reused when

the EL expression is evaluated again, or when another EL expression

is evaluated.

Any instance of the bean that receives a producer method, producer field, disposer method or observer method invocation exists to

service that invocation only.

Any instance of the bean injected into method parameters of a disposer method or observer method exists to service the method invocation only.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值