- Mastering JavaServer Faces 2.2
- Anghel Leonard
- 268字
- 2021-12-08 12:41:31
Dependent pseudo-scope
This is the default scope of a CDI bean (@Named
) when nothing is specified. In this case, an object exists to serve exactly one bean and has the same life cycle as that bean; an instance of a dependent scoped bean is not shared between different users or different points of injection. It can also be explicitly specified by annotating the bean with the @Dependent
annotation and importing javax.enterprise.context.Dependent
. This scope is available only in CDI and is the only non-contextual scope.
Note
All CDI scopes, except this one, are known as normal scopes. More details about normal scopes versus pseudo-scopes can be found in the Normal scopes and pseudo-scopes section at http://docs.jboss.org/cdi/spec/1.0/html/contexts.html.
If you put the PlayersBean
in the dependent scope, then the current extracted player and the list of randomly extracted players (which will be empty or will contain this player) is available only inside the bean, as shown in the following code:
import javax.enterprise.context.Dependent; import javax.inject.Named; @Named @Dependent public class PlayersBean { ... }
Note
A method annotated with @PostConstruct
will be called for each request. Actually, it might be called multiple times during the same request, if the bean is used in several EL expressions. Initially, there is one instance of the bean, and this instance is reused if the bean EL name appears multiple times in the EL expression, but is not reused in the case of another EL expression or in the case of a re-evaluation of the same EL expression.
This example is wrapped into the application named ch3_5
that is available in the code bundle of this chapter.
- Instant uTorrent
- 龍芯應(yīng)用開發(fā)標(biāo)準(zhǔn)教程
- 網(wǎng)絡(luò)服務(wù)器配置與管理(第3版)
- 辦公通信設(shè)備維修
- The Applied AI and Natural Language Processing Workshop
- Getting Started with Qt 5
- The Deep Learning with Keras Workshop
- Visual Media Processing Using Matlab Beginner's Guide
- 單片機(jī)系統(tǒng)設(shè)計與開發(fā)教程
- 微型計算機(jī)系統(tǒng)原理及應(yīng)用:國產(chǎn)龍芯處理器的軟件和硬件集成(基礎(chǔ)篇)
- LPC1100系列處理器原理及應(yīng)用
- WebGL Hotshot
- 電腦橫機(jī)使用與維修
- STM32自學(xué)筆記
- Istio實戰(zhàn)指南