public interface Context
NormalScope
annotation. Webbeans components
that are contained in the context are managed by the webbeans container.
Every context has a well-defined lifecycle. It means that in some time, context is active and some other time context may be passive. Moreover, each context is created and destroyed by the container according to the timing requirements. For example, request context is started by every http request and destroyed at the end of the http response. According to the current thread, active context is called an thread current context.
Context is responsible for creating and destroying the Contextual
instances of the
webbeans components.
Modifier and Type | Method and Description |
---|---|
<T> T |
get(Contextual<T> component)
Returns the instance of the webbeans in this context if exist otherwise return null.
|
<T> T |
get(Contextual<T> component,
CreationalContext<T> creationalContext)
If the context is not active, throws
ContextNotActiveException . |
Class<? extends Annotation> |
getScope()
Returns the scope type of the context.
|
boolean |
isActive()
Returns true if context is active according to the current thread,
returns false otherwise.
|
Class<? extends Annotation> getScope()
<T> T get(Contextual<T> component, CreationalContext<T> creationalContext)
ContextNotActiveException
.
Otherwise, it looks for the given component instance in the context map. If
this context contains the given webbeans component instance, it returns the component.
If the component is not found in this context map, it looks for the creationalContext
argument. If it is null, it returns null, otherwise new webbeans instance is created
and puts into the context and returns it.T
- type of the webbeans componentcomponent
- webbeans componentcreationalContext
- CreationalContext
instance<T> T get(Contextual<T> component)
T
- type of the webbeans componentcomponent
- webbeans componentboolean isActive()
Copyright © 2019. All rights reserved.