Package io.jmix.audit

Interface EntityLog

All Known Implementing Classes:
EntityLogImpl

public interface EntityLog
Logs lifecycle events (create, modify, delete) of JPA entities.

Configured by LoggedEntity and LoggedAttribute entities.

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    flush(String storeName)
    Flush records accumulated by invocations of registerCreate(Object) and other registration methods to the database.
    void
    Invalidates configuration cache.
    boolean
     
    boolean
     
    void
    Disables/enables entity logging for the current thread.
    void
    Logs creation of an entity which is configured for manual logging (LoggedEntity.auto == false).
    void
    registerCreate(Object entity, boolean auto)
    Logs creation of an entity which is configured for auto or manual logging.
    void
    Logs deletion of an entity which is configured for manual logging (LoggedEntity.auto == false).
    void
    registerDelete(Object entity, boolean auto)
    Logs deletion of an entity which is configured for auto or manual logging Should be called within an active transaction.
    void
    Logs modification of an entity which is configured for manual logging (LoggedEntity.auto == false).
    void
    registerModify(Object entity, boolean auto)
    Logs modification of an entity which is configured for auto or manual logging.
    void
    registerModify(Object entity, boolean auto, AttributeChanges changes)
    Logs modification of an entity which is configured for auto or manual logging.
    void
    setEnabled(boolean enabled)
    Enables/disables entity logging globally.
  • Method Details

    • isEnabled

      boolean isEnabled()
      Returns:
      whether entity logging is enabled globally and for the current thread (see processLoggingForCurrentThread(boolean))
    • setEnabled

      void setEnabled(boolean enabled)
      Enables/disables entity logging globally. By default, takes the value from the jmix.audit.enabled application property.
    • registerCreate

      void registerCreate(Object entity)
      Logs creation of an entity which is configured for manual logging (LoggedEntity.auto == false). Should be called within an active transaction.
      Parameters:
      entity - entity instance
    • registerCreate

      void registerCreate(Object entity, boolean auto)
      Logs creation of an entity which is configured for auto or manual logging. Should be called within an active transaction.
      Parameters:
      entity - entity instance
      auto - should match the entity configuration for auto (true) or manual (false) logging
    • registerModify

      void registerModify(Object entity)
      Logs modification of an entity which is configured for manual logging (LoggedEntity.auto == false). Should be called within an active transaction.
      Parameters:
      entity - entity instance in managed state
    • registerModify

      void registerModify(Object entity, boolean auto)
      Logs modification of an entity which is configured for auto or manual logging. Should be called within an active transaction.
      Parameters:
      entity - entity instance in managed state
      auto - should match the entity configuration for auto (true) or manual (false) logging
    • registerModify

      void registerModify(Object entity, boolean auto, @Nullable AttributeChanges changes)
      Logs modification of an entity which is configured for auto or manual logging. Should be called within an active transaction.
      Parameters:
      entity - entity instance in managed state
      auto - should match the entity configuration for auto (true) or manual (false) logging
      changes - attribute changes provided by caller
    • registerDelete

      void registerDelete(Object entity)
      Logs deletion of an entity which is configured for manual logging (LoggedEntity.auto == false). Should be called within an active transaction.
    • registerDelete

      void registerDelete(Object entity, boolean auto)
      Logs deletion of an entity which is configured for auto or manual logging Should be called within an active transaction.
      Parameters:
      entity - entity instance
      auto - should match the entity configuration for auto logging (true) or manual logging (false)
    • invalidateCache

      void invalidateCache()
      Invalidates configuration cache. The configuration will be recreated from the database on next lifecycle event.
    • processLoggingForCurrentThread

      void processLoggingForCurrentThread(boolean enabled)
      Disables/enables entity logging for the current thread. Enabled by default.
      Parameters:
      enabled - entity logging disabled if false, enabled otherwise.
    • isLoggingForCurrentThread

      boolean isLoggingForCurrentThread()
      Returns:
      whether logging for the current thread is enabled
      See Also:
    • flush

      void flush(String storeName)
      Flush records accumulated by invocations of registerCreate(Object) and other registration methods to the database.