javax.enterprise.context.spi
Interface Context


public interface Context

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.

Version:
$Rev: 815435 $ $Date: 2009-09-15 20:18:44 +0200 (Tue, 15 Sep 2009) $

Method Summary
<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.
 

Method Detail

getScope

Class<? extends Annotation> getScope()
Returns the scope type of the context.

Returns:
the scope type of the context

get

<T> 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.

Type Parameters:
T - type of the webbeans component
Parameters:
component - webbeans component
creationalContext - CreationalContext instance
Returns:
the contextual instance or null

get

<T> T get(Contextual<T> component)
Returns the instance of the webbeans in this context if exist otherwise return null.

Type Parameters:
T - type of the webbeans component
Parameters:
component - webbeans component
Returns:
the instance of the webbeans in this context if exist otherwise return null

isActive

boolean isActive()
Returns true if context is active according to the current thread, returns false otherwise.

Returns:
true if context is active according to the current thread, return false otherwise


Copyright © 2003-2012 The Apache Software Foundation. All Rights Reserved.