Class HypersistenceOptimizer

java.lang.Object
io.hypersistence.optimizer.HypersistenceOptimizer

public final class HypersistenceOptimizer extends Object
The HypersistenceOptimizer represents the main class of this project.

It takes a Config object and provides a way to initialize the optimization analysis process.

Since:
1.0.0
Author:
Vlad Mihalcea
  • Constructor Details

    • HypersistenceOptimizer

      public HypersistenceOptimizer(Config config)
      Instantiate a HypersistenceOptimizer object using the provided configuration.
      Parameters:
      config - Config object
  • Method Details

    • config

      public Config config()
      Get the current Config object.
      Returns:
      current Config object
    • getEvents

      public List<Event> getEvents()
      Get the List of incoming Event objects that have been recorded.
      Returns:
      List of incoming Event objects that have been recorded
    • getEventPersistenceContext

      public EventPersistenceContext getEventPersistenceContext()
      Get the EventPersistenceContext, if the event persistence feature is active.
      Returns:
      the EventPersistenceContext, or null if the feature is not active
    • getWebAppUrl

      public String getWebAppUrl()
      Get the URL of the embedded Event Persistence Web App, when it has been started successfully, either automatically (via Config.EventPersistence#setWebAppEnabled(true)) or on demand (via startWebApp()).

      This is the reliable way to discover the address when the web app binds a dynamically allocated port, without having to rely on the startup log line: the host application can read it and, for example, re-log it through its own logging framework or expose it via a management endpoint.

      Returns:
      the web app URL, or null if the web app is not running
    • startWebApp

      public void startWebApp()
      Start the embedded Event Persistence Web App on demand, reusing the host application's SessionFactory. This is useful when the web app is not started automatically (via Config.EventPersistence#setWebAppEnabled(true)), e.g. to open it from a management endpoint only when needed. The host, port, and Basic authentication settings of the Config.EventPersistence are still applied.

      It has no effect if the event persistence feature is not active or the web app is already running, and it never throws; call getWebAppUrl() to find out whether it started.

    • stopWebApp

      public void stopWebApp()
      Stop the embedded Event Persistence Web App, if it is running, while keeping the event persistence feature active.
    • stop

      public void stop()
      Stop the HypersistenceOptimizer, flushing and releasing the event persistence resources when the feature is active.
    • close

      public void close()
      Close the HypersistenceOptimizer, just like stop(). Frameworks that manage the HypersistenceOptimizer lifecycle call it automatically, e.g., Spring infers close as the destroy method of a @Bean, so the runtime events are flushed and the web app is stopped when the application context is closed.