public class EventPersistenceContext extends Object
EventPersistenceContext wires together the collaborators of the event persistence
feature (EventStore, RuntimeEventAggregator and
PersistentEventHandler) and manages their lifecycle.
All failures are contained: if the feature cannot be started (e.g. the database is unreachable), it disables itself and logs a warning, but never propagates the failure into the host application.
| Constructor and Description |
|---|
EventPersistenceContext(EventPersistenceSettings settings) |
| Modifier and Type | Method and Description |
|---|---|
void |
flushRuntimeEvents()
Flush all currently buffered runtime rollups to the database, regardless of whether their
time window has closed.
|
EventHandler |
getEventHandler()
Get the
EventHandler that persists runtime events. |
RuntimeEventAggregator |
getRuntimeEventAggregator()
Get the
RuntimeEventAggregator. |
EventPersistenceSettings |
getSettings()
Get the resolved
EventPersistenceSettings. |
String |
getWebAppUrl()
Get the URL the web app is available at, or
null if it is not running. |
boolean |
isActive()
Check whether the feature is currently active.
|
void |
persistBootstrapEvents(String hibernateVersion,
List<Event> bootstrapEvents)
Persist the configuration and mapping events collected during scanning, as a single run.
|
boolean |
start()
Start the runtime aggregator after the bootstrap scanner has prepared the schema.
|
void |
startWebApp()
Start the web app, reusing the host application's
SessionFactory. |
void |
stop()
Stop the feature, flushing any pending runtime rollups.
|
void |
stopWebApp()
Stop the web app, if it is running, while keeping the event persistence feature active.
|
public EventPersistenceContext(EventPersistenceSettings settings)
public boolean start()
startWebApp().true if the feature started successfully, false otherwisepublic void persistBootstrapEvents(String hibernateVersion, List<Event> bootstrapEvents)
hibernateVersion - the current Hibernate versionbootstrapEvents - the collected configuration and mapping eventspublic EventHandler getEventHandler()
EventHandler that persists runtime events.EventHandlerpublic void flushRuntimeEvents()
public RuntimeEventAggregator getRuntimeEventAggregator()
RuntimeEventAggregator.RuntimeEventAggregatorpublic EventPersistenceSettings getSettings()
EventPersistenceSettings.public boolean isActive()
true if the feature is activepublic void startWebApp()
SessionFactory. The bootstrap calls
it automatically when Config.EventPersistence#setWebAppEnabled(true) is set, but it can
also be called programmatically, regardless of that setting. It has no effect if the feature is not active or
the web app is already running. Since the web app requires Java 8, it is not started on Java 6 and 7,
while the events are still persisted. Never throws.public void stopWebApp()
public String getWebAppUrl()
null if it is not running.nullpublic void stop()
Copyright © 2026. All rights reserved.