Top Description Methods
javax.enterprise.context.control

public Interface RequestContextController

Imports
javax.enterprise.context.ContextNotActiveException

The CDI container provides a built in instance of RequestContextController that is dependent scoped for the purposes of activating and deactivating. For example:
   @Inject
   private RequestContextController requestContextController;

   public void doRequest(String body) {
      // activate request context
      requestContextController.activate();

      // do work in a request context.

      // deactivate the request context
      requestContextController.deactivate();
   }
Once the request context has been deactivated, you may activate it once again, creating a brand new request context. The activated request context is bound to the current thread, any injection points targeting a request scoped bean will be satisfied with the same request scoped objects.
Author
John D. Ament
Since
2.0

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if the context was activated by this invocation, false if not.
activate
()

Activates a RequestContext for the current thread if one is not already active.

public void
deactivate()

Deactivates the current Request Context if it was activated by this context controller.

Method Detail

activateback to summary
public boolean activate()

Activates a RequestContext for the current thread if one is not already active.

Returns:boolean

true if the context was activated by this invocation, false if not.

deactivateback to summary
public void deactivate() throws ContextNotActiveException

Deactivates the current Request Context if it was activated by this context controller. If the context is active but was not activated by this controller, then it may not be deactivated by this controller, meaning this method will do nothing. If the context is not active, a ContextNotActiveException is thrown.

Exceptions
ContextNotActiveException:
if the context is not active
See Also
ContextNotActiveException