Class RingBufferAuditSink
java.lang.Object
com.svenruppert.jsentinel.audit.RingBufferAuditSink
- All Implemented Interfaces:
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final intDefault capacity if no explicit size is configured. -
Constructor Summary
ConstructorsConstructorDescriptionBuilds a ring buffer withDEFAULT_CAPACITYslots.RingBufferAuditSink(int capacity) -
Method Summary
Modifier and TypeMethodDescriptionvoidaccept(AuditEvent event) Records the given event.intcapacity()Returns the configured maximum number of retained events.voidclear()Drops every retained event.query(AuditQuery query) Returns a snapshot of retained events that matchquery, oldest first.intsize()Returns the current number of retained events.
-
Field Details
-
DEFAULT_CAPACITY
public static final int DEFAULT_CAPACITYDefault capacity if no explicit size is configured.- See Also:
-
-
Constructor Details
-
RingBufferAuditSink
public RingBufferAuditSink()Builds a ring buffer withDEFAULT_CAPACITYslots. -
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
Description copied from interface:AuditSinkRecords the given event. -
query
Returns a snapshot of retained events that matchquery, oldest first.- Parameters:
query- filter, nevernull- Returns:
- defensive copy of matching events
-
clear
public void clear()Drops every retained event.
-