Save This Page
Home » apache-openwebbeans-1.0.0-incubating-M3-sources » javax.enterprise.context.spi » [javadoc | source]
public interface: Context [javadoc | source] Every webbeans component has an associated context that are defined by the 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.

Method from javax.enterprise.context.spi.Context Summary:
get,   get,   getScope,   isActive
Method from javax.enterprise.context.spi.Context Detail:
 public T get(Contextual<T> component)
    Returns the instance of the webbeans in this context if exist otherwise return null.
 public T get(Contextual<T> component,
    CreationalContext<T> creationalContext)
    If the context is not active, throws 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.
 public Class<Annotation> getScope()
    Returns the scope type of the context.
 public boolean isActive()
    Returns true if context is active according to the current thread, returns false otherwise.