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>
AKeycloakSessionTaskWithResult
that is aimed to be used by endpoints that want to produce aResponse
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
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.Response
run(KeycloakSession session)
Computes a result.abstract javax.ws.rs.core.Response
runInternal(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 originalKeycloakSession
that was active when the task was created.
-
-
Method Detail
-
run
public javax.ws.rs.core.Response run(KeycloakSession session)
Description copied from interface:KeycloakSessionTaskWithResult
Computes a result.- Specified by:
run
in 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
.
-
-