Class RingBufferAuditSink

java.lang.Object
com.svenruppert.jsentinel.audit.RingBufferAuditSink
All Implemented Interfaces:
AuditSink

public final class RingBufferAuditSink extends Object implements AuditSink
Bounded in-memory ring buffer of AuditEvents. New events are appended at the tail; when the configured capacity() is reached the oldest event is dropped.

Intended to back the Vaadin /audit-route with a recent-events view without paying for a persistent backend. Production deployments typically combine this with a long-term sink (file, SIEM) inside a CompositeAuditService.

Thread-safe via intrinsic locking on the internal buffer.

  • Field Details

    • DEFAULT_CAPACITY

      public static final int DEFAULT_CAPACITY
      Default capacity if no explicit size is configured.
      See Also:
  • Constructor Details

    • RingBufferAuditSink

      public RingBufferAuditSink()
      Builds a ring buffer with DEFAULT_CAPACITY slots.
    • RingBufferAuditSink

      public RingBufferAuditSink(int capacity)
      Parameters:
      capacity - maximum retained events; must be ≥ 1
  • Method Details

    • capacity

      public int capacity()
      Returns the configured maximum number of retained events.
    • size

      public int size()
      Returns the current number of retained events.
    • accept

      public void accept(AuditEvent event)
      Description copied from interface: AuditSink
      Records the given event.
      Specified by:
      accept in interface AuditSink
      Parameters:
      event - non-null event
    • query

      public List<AuditEvent> query(AuditQuery query)
      Returns a snapshot of retained events that match query, oldest first.
      Parameters:
      query - filter, never null
      Returns:
      defensive copy of matching events
    • clear

      public void clear()
      Drops every retained event.