Package org.keycloak.transaction
Class AsyncResponseTransaction
- java.lang.Object
-
- org.keycloak.transaction.AsyncResponseTransaction
-
- All Implemented Interfaces:
KeycloakTransaction
public class AsyncResponseTransaction extends Object implements KeycloakTransaction
When usingAsyncResponse.resume(Object)
directly in the code, the response is returned before all changes done withing this execution are committed. Therefore we need some mechanism that resumes the AsyncResponse after all changes are successfully committed. This can be achieved by enlisting an instance of AsyncResponseTransaction into the main transaction usingKeycloakTransactionManager.enlistAfterCompletion(KeycloakTransaction)
.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
begin()
void
commit()
static void
finishAsyncResponseInTransaction(KeycloakSession session, javax.ws.rs.container.AsyncResponse responseToFinishInTransaction, javax.ws.rs.core.Response responseToSend)
This method creates a new AsyncResponseTransaction instance that resumes provided AsyncResponseresponseToFinishInTransaction
with given ResponseresponseToSend
.boolean
getRollbackOnly()
boolean
isActive()
void
rollback()
void
setRollbackOnly()
-
-
-
Method Detail
-
finishAsyncResponseInTransaction
public static void finishAsyncResponseInTransaction(KeycloakSession session, javax.ws.rs.container.AsyncResponse responseToFinishInTransaction, javax.ws.rs.core.Response responseToSend)
This method creates a new AsyncResponseTransaction instance that resumes provided AsyncResponseresponseToFinishInTransaction
with given ResponseresponseToSend
. The transaction is enlisted toKeycloakTransactionManager
.- Parameters:
session
- Current KeycloakSessionresponseToFinishInTransaction
- AsyncResponse to be resumed onKeycloakTransactionManager
commit/rollback.responseToSend
- Response to be sent
-
begin
public void begin()
- Specified by:
begin
in interfaceKeycloakTransaction
-
commit
public void commit()
- Specified by:
commit
in interfaceKeycloakTransaction
-
rollback
public void rollback()
- Specified by:
rollback
in interfaceKeycloakTransaction
-
setRollbackOnly
public void setRollbackOnly()
- Specified by:
setRollbackOnly
in interfaceKeycloakTransaction
-
getRollbackOnly
public boolean getRollbackOnly()
- Specified by:
getRollbackOnly
in interfaceKeycloakTransaction
-
isActive
public boolean isActive()
- Specified by:
isActive
in interfaceKeycloakTransaction
-
-