Package civitas.celestis
Class Application
java.lang.Object
civitas.celestis.Application
Defines the contract for a generic application using the Plains library.
All modules are configured to use
System.out as its print stream
unless the module instances are specified using the protected constructor
by a customized subclass.
Using this class directly should only be done for testing and debugging purposes, and the final application should be a subclass which properly handles the lifecycle of its specific implementation.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final EventManagerThe event manager instance.static final intThe exit code for forceful termination of the application caused by a fatal error, which makes the application no longer operable.static final intThe exit code for normal graceful termination of the application.static final intThe exit code for forceful termination of the application by means of directly callingterminate(int).protected final StringThe name of this application.protected final SchedulerThe scheduler instance.protected final StringThe version of this application. -
Constructor Summary
ConstructorsModifierConstructorDescriptionApplication(String name, String version) Creates a new application with the default module configuration.protectedApplication(String name, String version, EventManager eventManager, Scheduler scheduler) Creates a new application. -
Method Summary
Modifier and TypeMethodDescriptionReturns the event manager of this application.getName()Returns the name of this application.Returns the scheduler of this application.Returns the version of this application.voidstart()Initiates this application, initializing all modules and starting the program.voidstop()Gracefully stops the application, giving modules time to finalize their operations.voidterminate(int exitCode) Forcefully terminates the application, regardless of its current state.toString()Serializes this application into a string for debugging purposes.
-
Field Details
-
EXIT_CODE_NORMAL
public static final int EXIT_CODE_NORMALThe exit code for normal graceful termination of the application.- Since:
- 0.4
- See Also:
-
EXIT_CODE_TERMINATED
public static final int EXIT_CODE_TERMINATEDThe exit code for forceful termination of the application by means of directly callingterminate(int). (without proper exit procedure)- Since:
- 0.4
- See Also:
-
EXIT_CODE_FATAL_ERROR
public static final int EXIT_CODE_FATAL_ERRORThe exit code for forceful termination of the application caused by a fatal error, which makes the application no longer operable.- Since:
- 0.4
- See Also:
-
name
The name of this application. -
version
The version of this application. -
eventManager
The event manager instance. -
scheduler
The scheduler instance.
-
-
Constructor Details
-
Application
Creates a new application with the default module configuration.- Parameters:
name- The name of this applicationversion- The version of this application
-
Application
protected Application(@Nonnull String name, @Nonnull String version, @Nonnull @ApplicationCritical EventManager eventManager, @Nonnull @ApplicationCritical Scheduler scheduler) Creates a new application.- Parameters:
name- The name of this applicationversion- The version of this applicationeventManager- The event manager instance of this applicationscheduler- The scheduler instance of this application
-
-
Method Details
-
start
Initiates this application, initializing all modules and starting the program. -
stop
Gracefully stops the application, giving modules time to finalize their operations.- See Also:
-
terminate
Forcefully terminates the application, regardless of its current state. This is a destructive action, and only should be called when a fatal error occurs.- Parameters:
exitCode- The exit code to send toSystem.exit(int)- See Also:
-
getName
Returns the name of this application.- Returns:
- The name of this application
-
getVersion
Returns the version of this application.- Returns:
- The version of this application
-
getEventManager
Returns the event manager of this application.- Returns:
- The event manager of this application
-
getScheduler
Returns the scheduler of this application.- Returns:
- The scheduler of this application
-
toString
Serializes this application into a string for debugging purposes.
-