Module jakarta.cdi

Interface RequestContextController


public interface RequestContextController
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.
Since:
2.0