Allow for disabling automatic subsystem init
This commit is contained in:
parent
5697522641
commit
85bff3b14d
2 changed files with 49 additions and 29 deletions
|
@ -135,26 +135,21 @@ public final class Engine implements SubsystemMainClass {
|
||||||
new EngineConfiguration();
|
new EngineConfiguration();
|
||||||
EngineConfiguration.getInstance().loadConfiguration();
|
EngineConfiguration.getInstance().loadConfiguration();
|
||||||
|
|
||||||
// Initialize classes
|
initializeClasses(); // Initialize classes
|
||||||
initializeClasses();
|
populateCrashContent(); // Populate crash content
|
||||||
|
precomputeEventListeners(); // Precompute event listeners
|
||||||
|
startThreads(); // Start threads
|
||||||
|
|
||||||
// Populate crash content
|
// Perform automatic subsystem initialization
|
||||||
populateCrashContent();
|
if (EngineConfiguration.getInstance().isOptimizeSubsystemInitialization()) {
|
||||||
|
collectSubsystems(); // Collect subsystems
|
||||||
|
|
||||||
// Precompute event listeners
|
// Initialize subsystems
|
||||||
precomputeEventListeners();
|
try {
|
||||||
|
initializeSubsystems();
|
||||||
// Start threads
|
} catch (Exception exception) {
|
||||||
startThreads();
|
logger.crash("Subsystem dependency resolution failed", exception);
|
||||||
|
}
|
||||||
// Collect subsystems
|
|
||||||
collectSubsystems();
|
|
||||||
|
|
||||||
// Initialize subsystems
|
|
||||||
try {
|
|
||||||
initializeSubsystems();
|
|
||||||
} catch (Exception exception) {
|
|
||||||
logger.crash("Subsystem dependency resolution failed", exception);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,7 @@ public final class EngineConfiguration implements SubsystemConfiguration {
|
||||||
* @since v1-alpha0
|
* @since v1-alpha0
|
||||||
*
|
*
|
||||||
* -- GETTER --
|
* -- GETTER --
|
||||||
* Gets the value for {@code debug}.
|
* Gets the value for {@link #debug}.
|
||||||
*
|
*
|
||||||
* @return variable value
|
* @return variable value
|
||||||
* @see EngineConfiguration#debug
|
* @see EngineConfiguration#debug
|
||||||
|
@ -102,7 +102,7 @@ public final class EngineConfiguration implements SubsystemConfiguration {
|
||||||
* @since v1-alpha0
|
* @since v1-alpha0
|
||||||
*
|
*
|
||||||
* -- GETTER --
|
* -- GETTER --
|
||||||
* Gets the value for {@code debugEvents}.
|
* Gets the value for {@link #debugEvents}.
|
||||||
*
|
*
|
||||||
* @return variable value
|
* @return variable value
|
||||||
* @see EngineConfiguration#debugEvents
|
* @see EngineConfiguration#debugEvents
|
||||||
|
@ -118,7 +118,7 @@ public final class EngineConfiguration implements SubsystemConfiguration {
|
||||||
* @since v1-alpha0
|
* @since v1-alpha0
|
||||||
*
|
*
|
||||||
* -- GETTER --
|
* -- GETTER --
|
||||||
* Gets the value for {@code debugShortcodeConverter}.
|
* Gets the value for {@link #debugShortcodeConverter}.
|
||||||
*
|
*
|
||||||
* @return variable value
|
* @return variable value
|
||||||
* @see EngineConfiguration#debugShortcodeConverter
|
* @see EngineConfiguration#debugShortcodeConverter
|
||||||
|
@ -135,7 +135,7 @@ public final class EngineConfiguration implements SubsystemConfiguration {
|
||||||
* @since v1-alpha0
|
* @since v1-alpha0
|
||||||
*
|
*
|
||||||
* -- GETTER --
|
* -- GETTER --
|
||||||
* Gets the value for {@code errorShortcodeConverter}.
|
* Gets the value for {@link #errorShortcodeConverter}.
|
||||||
*
|
*
|
||||||
* @return variable value
|
* @return variable value
|
||||||
* @see EngineConfiguration#errorShortcodeConverter
|
* @see EngineConfiguration#errorShortcodeConverter
|
||||||
|
@ -150,7 +150,7 @@ public final class EngineConfiguration implements SubsystemConfiguration {
|
||||||
* @since v1-alpha0
|
* @since v1-alpha0
|
||||||
*
|
*
|
||||||
* -- GETTER --
|
* -- GETTER --
|
||||||
* Gets the value for {@code loggerLevel}.
|
* Gets the value for {@link #loggerLevel}.
|
||||||
*
|
*
|
||||||
* @return variable value
|
* @return variable value
|
||||||
* @see EngineConfiguration#loggerLevel
|
* @see EngineConfiguration#loggerLevel
|
||||||
|
@ -165,7 +165,7 @@ public final class EngineConfiguration implements SubsystemConfiguration {
|
||||||
* @since v1-alpha0
|
* @since v1-alpha0
|
||||||
*
|
*
|
||||||
* -- GETTER --
|
* -- GETTER --
|
||||||
* Gets the value for {@code loggerTemplate}
|
* Gets the value for {@link #loggerTemplate}
|
||||||
*
|
*
|
||||||
* @return variable value
|
* @return variable value
|
||||||
* @see EngineConfiguration#loggerTemplate
|
* @see EngineConfiguration#loggerTemplate
|
||||||
|
@ -181,7 +181,7 @@ public final class EngineConfiguration implements SubsystemConfiguration {
|
||||||
* @since v1-alpha0
|
* @since v1-alpha0
|
||||||
*
|
*
|
||||||
* -- GETTER --
|
* -- GETTER --
|
||||||
* Gets the value for {@code loggerImmediateShutdown}.
|
* Gets the value for {@link #loggerImmediateShutdown}.
|
||||||
*
|
*
|
||||||
* @return variable value
|
* @return variable value
|
||||||
* @see EngineConfiguration#loggerImmediateShutdown
|
* @see EngineConfiguration#loggerImmediateShutdown
|
||||||
|
@ -196,7 +196,7 @@ public final class EngineConfiguration implements SubsystemConfiguration {
|
||||||
* @since v1-alpha0
|
* @since v1-alpha0
|
||||||
*
|
*
|
||||||
* -- GETTER --
|
* -- GETTER --
|
||||||
* Gets the value for {@code loggerForceStandardOutput}.
|
* Gets the value for {@link #loggerForceStandardOutput}.
|
||||||
*
|
*
|
||||||
* @return variable value
|
* @return variable value
|
||||||
* @see EngineConfiguration#loggerForceStandardOutput
|
* @see EngineConfiguration#loggerForceStandardOutput
|
||||||
|
@ -212,7 +212,7 @@ public final class EngineConfiguration implements SubsystemConfiguration {
|
||||||
* @since v1-alpha1
|
* @since v1-alpha1
|
||||||
*
|
*
|
||||||
* -- GETTER --
|
* -- GETTER --
|
||||||
* Gets the value for {@code loggerForceStandardOutput}.
|
* Gets the value for {@link #loggerForceStandardOutput}.
|
||||||
*
|
*
|
||||||
* @return variable value
|
* @return variable value
|
||||||
* @see EngineConfiguration#loggerForceStandardOutput
|
* @see EngineConfiguration#loggerForceStandardOutput
|
||||||
|
@ -229,7 +229,7 @@ public final class EngineConfiguration implements SubsystemConfiguration {
|
||||||
* @since v1-alpha0
|
* @since v1-alpha0
|
||||||
*
|
*
|
||||||
* -- GETTER --
|
* -- GETTER --
|
||||||
* Gets the value for {@code optimizeLogging}.
|
* Gets the value for {@link #optimizeLogging}.
|
||||||
*
|
*
|
||||||
* @return variable value
|
* @return variable value
|
||||||
* @see EngineConfiguration#optimizeLogging
|
* @see EngineConfiguration#optimizeLogging
|
||||||
|
@ -245,7 +245,7 @@ public final class EngineConfiguration implements SubsystemConfiguration {
|
||||||
* @since v1-alpha0
|
* @since v1-alpha0
|
||||||
*
|
*
|
||||||
* -- GETTER --
|
* -- GETTER --
|
||||||
* Gets the value for {@code optimizeEvents}.
|
* Gets the value for {@link #optimizeEvents}.
|
||||||
*
|
*
|
||||||
* @return variable value
|
* @return variable value
|
||||||
* @see EngineConfiguration#optimizeEvents
|
* @see EngineConfiguration#optimizeEvents
|
||||||
|
@ -253,6 +253,26 @@ public final class EngineConfiguration implements SubsystemConfiguration {
|
||||||
*/
|
*/
|
||||||
private boolean optimizeEvents;
|
private boolean optimizeEvents;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If enabled, will try to automatically initialize every subsystem found though reflection.
|
||||||
|
* <p>
|
||||||
|
* This however may fail in certain situation, where manual subsystem initialization may be required.
|
||||||
|
* For this reason, this can be turned off before the engine initializes.
|
||||||
|
* Please note though that dependency resolution between subsystems will not be done, be careful when
|
||||||
|
* initializing subsystems manually.
|
||||||
|
*
|
||||||
|
* @see Engine
|
||||||
|
* @since v1-alpha2
|
||||||
|
*
|
||||||
|
* -- GETTER --
|
||||||
|
* Gets the value for {@link #optimizeSubsystemInitialization}.
|
||||||
|
*
|
||||||
|
* @return variable value
|
||||||
|
* @see EngineConfiguration#optimizeSubsystemInitialization
|
||||||
|
* @since v1-alpha2
|
||||||
|
*/
|
||||||
|
private boolean optimizeSubsystemInitialization;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs this class.
|
* Constructs this class.
|
||||||
*
|
*
|
||||||
|
@ -306,6 +326,7 @@ public final class EngineConfiguration implements SubsystemConfiguration {
|
||||||
|
|
||||||
case "optimizeLogging" -> optimizeLogging = parser.getBoolean(group + property);
|
case "optimizeLogging" -> optimizeLogging = parser.getBoolean(group + property);
|
||||||
case "optimizeEvents" -> optimizeEvents = parser.getBoolean(group + property);
|
case "optimizeEvents" -> optimizeEvents = parser.getBoolean(group + property);
|
||||||
|
case "optimizeSubsystemInitialization" -> optimizeSubsystemInitialization = parser.getBoolean(group + property);
|
||||||
}
|
}
|
||||||
} catch (NullPointerException ignored) {}
|
} catch (NullPointerException ignored) {}
|
||||||
}
|
}
|
||||||
|
@ -338,6 +359,7 @@ public final class EngineConfiguration implements SubsystemConfiguration {
|
||||||
|
|
||||||
optimizeLogging = true;
|
optimizeLogging = true;
|
||||||
optimizeEvents = true;
|
optimizeEvents = true;
|
||||||
|
optimizeSubsystemInitialization = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
|
@ -380,6 +402,9 @@ public final class EngineConfiguration implements SubsystemConfiguration {
|
||||||
case "optimizeEvents" -> {
|
case "optimizeEvents" -> {
|
||||||
return optimizeEvents;
|
return optimizeEvents;
|
||||||
}
|
}
|
||||||
|
case "optimizeSubsystemInitialization" -> {
|
||||||
|
return optimizeSubsystemInitialization;
|
||||||
|
}
|
||||||
default -> {
|
default -> {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue