[cdi-dev] scope vs scope type vs context

Todor Boev rinsvind at gmail.com
Mon Oct 9 07:17:23 EDT 2017


I am looking for formal definitions of scope, scope type, context

The closest seem to be in  http://docs.jboss.org/cdi/spec
/2.0/cdi-spec.html#scopes

Scope:
The scope of a bean determines the lifecycle of its instances, and which
instances of the bean are visible to instances of other beans,

Scope type:
A scope type is represented by an annotation type.

Context:
Scoped objects, exist in a well-defined lifecycle context:
...
Custom scopes are normally defined by portable extensions, which must also
provide a context object, as defined in The Context interface, that
implements the custom scope.

These seem vague.

Specifically it seems that the spec prefers to talk about "contextual
instances" rather that about a uniform set of objects that represent the
current "context".

Intuitively to me "scope" relates to "context", as "class" relates to
"object". The scope seems like a composite type, consisting of all beans
(not bean instances) marked with the same scope annotation. The context is
an object cache that collects the bean instances of that scope created
during a dependency injection pass.

Can someone clarify these terms?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/cdi-dev/attachments/20171009/d60f9cbc/attachment.html 


More information about the cdi-dev mailing list