Package io.hypersistence.optimizer
Class HypersistenceOptimizer
java.lang.Object
io.hypersistence.optimizer.HypersistenceOptimizer
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 Summary
ConstructorsConstructorDescriptionHypersistenceOptimizer(Config config) Instantiate aHypersistenceOptimizerobject using the provided configuration. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close theHypersistenceOptimizer, just likestop().config()Get the currentConfigobject.Get theEventPersistenceContext, if the event persistence feature is active.Get the URL of the embedded Event Persistence Web App, when it has been started successfully, either automatically (viaConfig.EventPersistence#setWebAppEnabled(true)) or on demand (viastartWebApp()).voidStart the embedded Event Persistence Web App on demand, reusing the host application'sSessionFactory.voidstop()Stop theHypersistenceOptimizer, flushing and releasing the event persistence resources when the feature is active.voidStop the embedded Event Persistence Web App, if it is running, while keeping the event persistence feature active.
-
Constructor Details
-
HypersistenceOptimizer
Instantiate aHypersistenceOptimizerobject using the provided configuration.- Parameters:
config-Configobject
-
-
Method Details
-
config
Get the currentConfigobject.- Returns:
- current
Configobject
-
getEvents
-
getEventPersistenceContext
Get theEventPersistenceContext, if the event persistence feature is active.- Returns:
- the
EventPersistenceContext, ornullif the feature is not active
-
getWebAppUrl
Get the URL of the embedded Event Persistence Web App, when it has been started successfully, either automatically (viaConfig.EventPersistence#setWebAppEnabled(true)) or on demand (viastartWebApp()).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
nullif the web app is not running
-
startWebApp
public void startWebApp()Start the embedded Event Persistence Web App on demand, reusing the host application'sSessionFactory. This is useful when the web app is not started automatically (viaConfig.EventPersistence#setWebAppEnabled(true)), e.g. to open it from a management endpoint only when needed. The host, port, and Basic authentication settings of theConfig.EventPersistenceare 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 theHypersistenceOptimizer, flushing and releasing the event persistence resources when the feature is active. -
close
public void close()Close theHypersistenceOptimizer, just likestop(). Frameworks that manage theHypersistenceOptimizerlifecycle call it automatically, e.g., Spring inferscloseas the destroy method of a@Bean, so the runtime events are flushed and the web app is stopped when the application context is closed.
-