从JBoss Seam 2.x迁移到JavaEE 7之二:组件的有效范围Scope

JBoss Seam 2.x提供了预置的几种Scope,如@Scope(ScopeType.SESSION)等,但不能扩展。

JavaEE 7 CDI也提供了预置的几种Scope,如@SessionScoped。此外,还可以扩展实现新的Scope。


两者内置的Scope的对比:

Seam 2 Scope

CDI Scope

Event

@RequestScoped

Session

@SessionScoped

Stateless

No exact match. 

The stateless scope is used primarily for Stateless Session Beans (EJB) in Seam 2. A Stateless session bean can be bound to the @Dependent context in a CDI application.

No exact match

@Dependent

Means creating a new instance for each injection point.

Page

No exact match.

Conversation

No exact match. 

There are several alternatives which help to maintain conversational state:
CDI @ConversationScoped — keeps conversational state between many requests, needs to be programmatically started and stopped.
JSF Flash scope — keeps state between two requests and possibly different views.
DeltaSpike Grouped Conversation scope — keeps state per-window, is started automatically when a grouped-conversation-scoped bean is accessed, maintains separate conversations for each bean or groups of beans.


你可能感兴趣的:(CDI,seam,scope)