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

org.molgenis.data.transaction.TransactionExceptionTranslatorRegistrar Maven / Gradle / Ivy

There is a newer version: 8.4.5
Show newest version
package org.molgenis.data.transaction;

import static java.util.Objects.requireNonNull;

import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

/**
 * Discovers {@link TransactionExceptionTranslator TransactionExceptionTranslators} beans and
 * registers them with the {@link TransactionExceptionTranslatorRegistry}.
 */
@Component
public class TransactionExceptionTranslatorRegistrar {
  private final TransactionExceptionTranslatorRegistry transactionExceptionTranslatorRegistry;

  public TransactionExceptionTranslatorRegistrar(
      TransactionExceptionTranslatorRegistry transactionExceptionTranslatorRegistry) {
    this.transactionExceptionTranslatorRegistry =
        requireNonNull(transactionExceptionTranslatorRegistry);
  }

  /**
   * Registers all {@link TransactionExceptionTranslator TransactionExceptionTranslators} in the
   * given application context with the {@link TransactionExceptionTranslatorRegistry}.
   *
   * @param applicationContext application context
   */
  public void register(ApplicationContext applicationContext) {
    applicationContext
        .getBeansOfType(TransactionExceptionTranslator.class)
        .values()
        .forEach(transactionExceptionTranslatorRegistry::register);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy