@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.
| Modifier and Type | Method and Description |
|---|---|
| public boolean | Returns: true if the context was activated by this invocation, false if not.Activates a RequestContext for the current thread if one is not already active. |
| public void |
| activate | back to summary |
|---|---|
| public boolean activate() Activates a RequestContext for the current thread if one is not already active.
| |
| deactivate | back 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.
| |