All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.phasetwo.keycloak.events.RunnableTransaction Maven / Gradle / Ivy

There is a newer version: 0.37
Show newest version
package io.phasetwo.keycloak.events;

import java.util.LinkedList;
import java.util.List;
import lombok.extern.jbosslog.JBossLog;
import org.keycloak.models.AbstractKeycloakTransaction;

@JBossLog
public class RunnableTransaction extends AbstractKeycloakTransaction {

  protected final List runnables;

  public RunnableTransaction() {
    this.runnables = new LinkedList();
  }

  public void addRunnable(Runnable r) {
    runnables.add(r);
  }

  @Override
  protected void commitImpl() {
    try {
      runnables.forEach(
          task -> {
            try {
              task.run();
            } catch (Exception e1) {
              log.warn("Error running Runnable", e1);
            }
          });
    } catch (Exception e2) {
      log.warn("Error running RunnableTransaction", e2);
    }
  }

  @Override
  protected void rollbackImpl() {
    runnables.clear();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy