CDI defines two different scope types, normal scope and pseudo scope, which define how a scope will function within CDI. All the built-in scopes are specified with one of these scope types, and they can also be used to create our own scope, which we will see later in the chapter.
A normal scope is declared with @NormalScope
to indicate to the container that a client proxy is required. It has a single attribute, which specifies whether the scope is passivating or not; that is, whether a bean that uses this scope is able to be passivated to secondary storage. @RequestScoped
, @SessionScoped
, @ApplicationScoped
, and @ConversationScoped
are all examples of scopes with a normal scope type.
A pseudo scope is declared with @Scope
to indicate that no client proxy is required by the container. @Dependent
is a scope with a pseudo scope type as instances are never proxied or shared.