Package io.deephaven.util.process
Interface ProcessEnvironment
- All Known Implementing Classes:
BaseProcessEnvironment
,DefaultProcessEnvironment
public interface ProcessEnvironment
Interface for installation-specific environment. Processes that use instances of this interface are responsible for
determining when to call the various methods.
All implementations must setup a ShutdownManager and an implementation of FatalErrorReporter.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
Factory interface for constructing instances of ProcessEnvironment implementations.static class
State and private methods for maintaining a shared global instance of ProcessEnvironment. -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull ProcessEnvironment
basicInteractiveProcessInitialization
(@NotNull Configuration configuration, @NotNull String mainClassName, @NotNull Logger log) Do the basic installation most interactive (usually client) processes need: (1) instantiateFromConfiguration (2) set (3) Invoke onStartup()static @NotNull ProcessEnvironment
basicServerInitialization
(@NotNull Configuration configuration, @NotNull String mainClassName, @NotNull Logger log) Do the basic installation most server processes need: (1) basicInteractiveProcessInitialization (as a subset of what servers need) (2) Set current thread name asmainClassName
.main (3) Install the fatal error reporter as default uncaught exception handlerstatic void
clear()
Set the global instance to null, and reset its shutdown manager.static ProcessEnvironment
get()
Accessor the for the global instance.Access a shared fatal error reporter.static FatalErrorReporter
static String
static ShutdownManager
Access the main class name.Access a shared manager for tasks to be executed on shutdown.static @NotNull ProcessEnvironment
instantiateFromConfiguration
(@NotNull Configuration configuration, @NotNull String mainClassName, @NotNull Logger log) Instantiate (and set as the global instance) a ProcessEnvironment specified according to the following factory class name properties, in descending order of precedence:mainClassName
.processEnvironmentFactory default.processEnvironmentFactory Checked exceptions thrown in this process always result in process termination.void
Hook for shutting down an installation-specific environment for a given process.void
Hook for setting up an installation-specific environment for a given process.static ProcessEnvironment
set
(@NotNull ProcessEnvironment instance, boolean allowReplace) Setter for the global instance.static ProcessEnvironment
tryGet()
Accessor the for the global instance.
-
Method Details
-
getShutdownManager
ShutdownManager getShutdownManager()Access a shared manager for tasks to be executed on shutdown.- Returns:
- The ShutdownManager
-
getFatalErrorReporter
FatalErrorReporter getFatalErrorReporter()Access a shared fatal error reporter.- Returns:
- The FatalErrorReporter
-
getMainClassName
String getMainClassName()Access the main class name.- Returns:
- The main class name
-
onStartup
void onStartup()Hook for setting up an installation-specific environment for a given process. -
onShutdown
void onShutdown()Hook for shutting down an installation-specific environment for a given process. This is intended for controlled invocation, rather than as part of a shutdown hook -onStartup()
should setup any mandatory shutdown hooks, and code in said shutdown hooks should be idempotent w.r.t. onShutdown(). -
get
Accessor the for the global instance. Fails if the instance is null, in order to make programming errors clear.- Returns:
- The global instance
-
tryGet
Accessor the for the global instance.- Returns:
- The global instance, or null if it is not set.
-
getGlobalShutdownManager
-
getGlobalFatalErrorReporter
-
getGlobalMainClassName
-
set
Setter for the global instance. It is an error to invoke this without allowReplace if the global instance may already have been set.- Parameters:
instance
- The new global instanceallowReplace
- Whether to allow replacing an existing global instance- Returns:
- The global instance
-
clear
static void clear()Set the global instance to null, and reset its shutdown manager. Intended for use in unit tests, only. -
instantiateFromConfiguration
@NotNull static @NotNull ProcessEnvironment instantiateFromConfiguration(@NotNull @NotNull Configuration configuration, @NotNull @NotNull String mainClassName, @NotNull @NotNull Logger log) Instantiate (and set as the global instance) a ProcessEnvironment specified according to the following factory class name properties, in descending order of precedence:mainClassName
.processEnvironmentFactory default.processEnvironmentFactory Checked exceptions thrown in this process always result in process termination.- Parameters:
configuration
- The configurationmainClassName
- The main class namelog
- The log- Returns:
- The new ProcessEnvironment
-
basicInteractiveProcessInitialization
@NotNull static @NotNull ProcessEnvironment basicInteractiveProcessInitialization(@NotNull @NotNull Configuration configuration, @NotNull @NotNull String mainClassName, @NotNull @NotNull Logger log) Do the basic installation most interactive (usually client) processes need: (1) instantiateFromConfiguration (2) set (3) Invoke onStartup()- Parameters:
configuration
- The configurationmainClassName
- The main class namelog
- The log- Returns:
- The ProcessEnvironment
-
basicServerInitialization
@NotNull static @NotNull ProcessEnvironment basicServerInitialization(@NotNull @NotNull Configuration configuration, @NotNull @NotNull String mainClassName, @NotNull @NotNull Logger log) Do the basic installation most server processes need: (1) basicInteractiveProcessInitialization (as a subset of what servers need) (2) Set current thread name asmainClassName
.main (3) Install the fatal error reporter as default uncaught exception handler- Parameters:
configuration
- The configurationmainClassName
- The main class namelog
- The log- Returns:
- The ProcessEnvironment
-