Interface PersistenceHookProvider

All Known Implementing Classes:
DefaultPersistenceHookRegistry, SpringBeanPersistenceHookProvider

public interface PersistenceHookProvider
A provider of persistence hooks. Each provider implementation decides what the persistence hooks are and how they can be resolved by the context. For example, some providers may look in the Spring application context, some providers may use dynamic scripts for the hooks, some providers may use external microservices for the hooks, etc.

Implementations are recommended to use a very specific schema for the hook name, that is not used by any other provider, e.g. "bean://", "script://", "http://", etc., so that the provider could be addressed specifically, if the same hook exists in mulitple providers. Also, the implementations may choose to support a hook name without a schema at all. In this case a provider placed first in the executor (see DefaultPersistenceHookExecutor.setHookProviders(List)) will override hooks with the same name in the providers following it in the list.

  • Method Details

    • getPrePersistHook

      Optional<PrePersistHook> getPrePersistHook(@NotNull @NotNull PersistenceContext context)
      Retrieves a PrePersistHook by the hook name.
      Parameters:
      context - context of the data being persisted.
      Returns:
      a hook matching the persistence context or an Optional.empty(), if there is no hook for the provided context.
    • getPostPersistHook

      Optional<PostPersistHook> getPostPersistHook(@NotNull @NotNull PersistenceContext context)
      Retrieves a PostPersistHook by the hook name.
      Parameters:
      context - context of the data being persisted.
      Returns:
      a hook matching the persistence context or an Optional.empty(), if there is no hook for the provided context..