Package org.keycloak.common.util
Class ResponseSessionTask
java.lang.Object
org.keycloak.common.util.ResponseSessionTask
- All Implemented Interfaces:
KeycloakSessionTaskWithResult<jakarta.ws.rs.core.Response>
public abstract class ResponseSessionTask
extends Object
implements KeycloakSessionTaskWithResult<jakarta.ws.rs.core.Response>
A
KeycloakSessionTaskWithResult
that is aimed to be used by endpoints that want to produce a Response
in
a retriable transaction. It takes care of the boilerplate code that is common to be seen in this scenario, allowing the
endpoint to focus on the actual code that has to be executed in a retriable manner.
More specifically, this task:
- pushes the task's session into the resteasy context, restoring the original value after the task is over. This allows
for endpoints to create new instances of themselves and inject the resteasy properties correctly;
- sets up the task's session context, based on model values found in the original session's context;
- handles
WebApplicationException
when it is thrown by the task.- Author:
- Stefan Guilhen
-
Constructor Summary
ConstructorDescriptionResponseSessionTask
(KeycloakSession originalSession) Constructs a new instance of this task. -
Method Summary
Modifier and TypeMethodDescriptionjakarta.ws.rs.core.Response
run
(KeycloakSession session) Computes a result.abstract jakarta.ws.rs.core.Response
runInternal
(KeycloakSession session) Builds the response that is to be returned.
-
Constructor Details
-
ResponseSessionTask
Constructs a new instance of this task.- Parameters:
originalSession
- the originalKeycloakSession
that was active when the task was created.
-
-
Method Details
-
run
Description copied from interface:KeycloakSessionTaskWithResult
Computes a result.- Specified by:
run
in interfaceKeycloakSessionTaskWithResult<jakarta.ws.rs.core.Response>
- Parameters:
session
- a reference to theKeycloakSession
.- Returns:
- the computed result.
-
runInternal
Builds the response that is to be returned.- Parameters:
session
- a reference theKeycloakSession
.- Returns:
- the constructed
Response
.
-