Package com.globalmentor.application
Interface Application
-
- All Superinterfaces:
io.clogr.Clogged,com.globalmentor.model.Named<java.lang.String>,java.lang.Runnable
- All Known Implementing Classes:
AbstractApplication,BaseCliApplication
public interface Application extends java.lang.Runnable, com.globalmentor.model.Named<java.lang.String>, io.clogr.CloggedA general application.To start an application, call the static
start(Application)method, passing it an application instance.- Author:
- Garret Wilson
- API Note:
- Although an application implements
Runnable, it should usually be started usingstart(), which will eventually (depending on the implementation) callRunnable.run().
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String[]NO_ARGUMENTSAn array containing no arguments.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description booleancanStart()Checks requirements, permissions, and expirations before starting.voiddisplayError(java.lang.String message)Deprecated.voiddisplayError(java.lang.String message, java.lang.Throwable throwable)Deprecated.default voidexit()Exits the application with no status.voidexit(int status)Exits the application with the given status.java.lang.String[]getArgs()java.util.Optional<com.globalmentor.net.Authenticable>getAuthenticator()java.util.Optional<java.time.LocalDate>getExpirationDate()java.util.prefs.PreferencesgetPreferences()Returns the application user preferences.java.lang.StringgetVersion()voidinitialize()Initializes the application.booleanisDebug()Returns whether debug mode is enabled.default intstart()Starts the applicationstatic intstart(Application application)Starts an application.
-
-
-
Method Detail
-
getAuthenticator
java.util.Optional<com.globalmentor.net.Authenticable> getAuthenticator()
- Returns:
- The authenticator object used to retrieve client authentication.
-
getArgs
java.lang.String[] getArgs()
- Returns:
- The command-line arguments of the application.
-
getVersion
java.lang.String getVersion()
- Returns:
- The application version string .
-
isDebug
boolean isDebug()
Returns whether debug mode is enabled.- API Note:
- Debug mode enables debug level logging and may also enable other debug functionality.
- Returns:
- The state of debug mode.
-
getPreferences
java.util.prefs.Preferences getPreferences() throws java.lang.SecurityExceptionReturns the application user preferences.- Returns:
- The default user preferences for this application.
- Throws:
java.lang.SecurityException- if a security manager is present and it deniesRuntimePermission("preferences").
-
getExpirationDate
java.util.Optional<java.time.LocalDate> getExpirationDate()
- Returns:
- The expiration date of the application, if there is one.
-
initialize
void initialize() throws java.lang.ExceptionInitializes the application. This method is called after construction but before application execution.- Throws:
java.lang.Exception- if anything goes wrong.
-
start
default int start()
Starts the application- Implementation Specification:
- The default implementation delegates to
Runnable.run()and returns a status code of0. - Returns:
- The application status.
-
canStart
boolean canStart()
Checks requirements, permissions, and expirations before starting.- Returns:
trueif the checks succeeded.
-
displayError
@Deprecated void displayError(@Nonnull java.lang.String message, @Nonnull java.lang.Throwable throwable)Deprecated.Displays an error message to the user for an exception.- Parameters:
message- The message to display.throwable- The condition that caused the error.
-
displayError
@Deprecated void displayError(java.lang.String message)
Deprecated.Displays the given error to the user- Parameters:
message- The error to display.
-
exit
default void exit()
Exits the application with no status.
-
exit
void exit(int status)
Exits the application with the given status. This method first checks to see if exit can occur.- Parameters:
status- The exit status.
-
start
static int start(Application application)
Starts an application.- Parameters:
application- The application to start.- Returns:
- The application status.
-
-