Package org.keycloak.common.util
Class ResponseSessionTask
- java.lang.Object
-
- org.keycloak.common.util.ResponseSessionTask
-
- All Implemented Interfaces:
KeycloakSessionTaskWithResult<javax.ws.rs.core.Response>
public abstract class ResponseSessionTask extends Object implements KeycloakSessionTaskWithResult<javax.ws.rs.core.Response>
AKeycloakSessionTaskWithResultthat is aimed to be used by endpoints that want to produce aResponsein 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
WebApplicationExceptionwhen it is thrown by the task.- Author:
- Stefan Guilhen
-
-
Constructor Summary
Constructors Constructor Description ResponseSessionTask(KeycloakSession originalSession)Constructs a new instance of this task.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description javax.ws.rs.core.Responserun(KeycloakSession session)Computes a result.abstract javax.ws.rs.core.ResponserunInternal(KeycloakSession session)Builds the response that is to be returned.
-
-
-
Constructor Detail
-
ResponseSessionTask
public ResponseSessionTask(KeycloakSession originalSession)
Constructs a new instance of this task.- Parameters:
originalSession- the originalKeycloakSessionthat was active when the task was created.
-
-
Method Detail
-
run
public javax.ws.rs.core.Response run(KeycloakSession session)
Description copied from interface:KeycloakSessionTaskWithResultComputes a result.- Specified by:
runin interfaceKeycloakSessionTaskWithResult<javax.ws.rs.core.Response>- Parameters:
session- a reference to theKeycloakSession.- Returns:
- the computed result.
-
runInternal
public abstract javax.ws.rs.core.Response runInternal(KeycloakSession session)
Builds the response that is to be returned.- Parameters:
session- a reference theKeycloakSession.- Returns:
- the constructed
Response.
-
-