Class PersistentAuditEventRepository<T extends AuditEventRecordBase>

java.lang.Object
io.leandev.appfuse.audit.PersistentAuditEventRepository<T>
Type Parameters:
T - 應用宣告的具體稽核 entity(繼承 AuditEventRecordBase
All Implemented Interfaces:
org.springframework.boot.actuate.audit.AuditEventRepository

public class PersistentAuditEventRepository<T extends AuditEventRecordBase> extends Object implements org.springframework.boot.actuate.audit.AuditEventRepository

Actuator AuditEventRepository持久實作:把稽核事件寫入應用宣告的稽核表,取代消費端 可選的 in-memory ring buffer(易失)。領域無關的框架 opt-in 服務(見 ADR-013「界線修訂 R1」)。

ADR-017 泛型化於 AuditEventRecordBase:應用注入具體 repository 與 entity 工廠(如 new PersistentAuditEventRepository<>(auditEventJpaRepository, AuditEventRecord::new))。

應用以 @Bean 宣告本類別(plain class,對齊框架「app 接線」慣例)即:Spring Boot 的 AuditAutoConfiguration 退讓(不再用 InMemory 版)、AuditListener(收 AuditApplicationEventadd(AuditEvent))與 /actuator/auditevents 端點皆改用本持久 sink——登入/授權/應用自訂(如代行)事件 全部落表可查。

  • Constructor Details

    • PersistentAuditEventRepository

      public PersistentAuditEventRepository(AuditEventJpaRepositoryBase<T> repository, Supplier<T> recordFactory)
      Parameters:
      repository - 稽核事件 repository(應用宣告的具體型別)
      recordFactory - 稽核 entity 工廠(通常為具體類的建構子參考)
  • Method Details

    • add

      @Transactional public void add(org.springframework.boot.actuate.audit.AuditEvent event)
      Specified by:
      add in interface org.springframework.boot.actuate.audit.AuditEventRepository
    • find

      @Transactional(readOnly=true) public List<org.springframework.boot.actuate.audit.AuditEvent> find(String principal, Instant after, String type)
      Specified by:
      find in interface org.springframework.boot.actuate.audit.AuditEventRepository