From 5c9a3a730c14f08d174b94efb9fcca9aea610981 Mon Sep 17 00:00:00 2001 From: Bill Burke Date: Thu, 1 Aug 2013 19:16:07 -0400 Subject: [PATCH] upgrade picketlink --- .../services/resources/Transaction.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/services/src/main/java/org/keycloak/services/resources/Transaction.java b/services/src/main/java/org/keycloak/services/resources/Transaction.java index e80692f04f..03bb3b750d 100755 --- a/services/src/main/java/org/keycloak/services/resources/Transaction.java +++ b/services/src/main/java/org/keycloak/services/resources/Transaction.java @@ -2,9 +2,12 @@ package org.keycloak.services.resources; import org.jboss.resteasy.spi.ResteasyProviderFactory; import org.keycloak.services.models.KeycloakSession; +import org.keycloak.services.models.KeycloakSessionFactory; import org.keycloak.services.models.KeycloakTransaction; /** + * Meant to be used as an inner class wrapper (I forget the pattern name, its been awhile). + * * @author Bill Burke * @version $Revision: 1 $ */ @@ -13,10 +16,21 @@ public class Transaction { protected KeycloakTransaction transaction; protected boolean closeSession; + /** + * Pull KeycloakSession from @Context + * + * Will close session after finished + * + */ public Transaction() { this(true); } + /** + * Pull KeycloakSession from @Context + * + * @param close whether to close the session or not after completion + */ public Transaction(boolean close) { this.session = ResteasyProviderFactory.getContextData(KeycloakSession.class); transaction = session.getTransaction(); @@ -24,10 +38,25 @@ public class Transaction { } + /** + * Creates and manages its own session. + * + * @param factory + */ + public Transaction(KeycloakSessionFactory factory) { + this.closeSession = true; + this.session = factory.createSession(); + this.transaction = session.getTransaction(); + } + protected void runImpl() { } + /** + * Will not begin or end a transaction or close a session if the transaction was already active when called + * + */ public void run() { boolean wasActive = transaction.isActive(); if (!wasActive) transaction.begin(); @@ -46,6 +75,10 @@ public class Transaction { return null; } + /** + * Will not begin or end a transaction or close a session if the transaction was already active when called + * + */ public T call() { boolean wasActive = transaction.isActive(); if (!wasActive) transaction.begin();