public abstract class AbstractApplication extends Object implements Application
Every application provides a default preference node based upon the implementing application class.
NO_ARGUMENTS| Constructor and Description |
|---|
AbstractApplication(URI uri,
String name)
URI constructor.
|
AbstractApplication(URI uri,
String name,
String[] args)
URI and arguments constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
canExit()
Determines whether the application can exit.
|
boolean |
canStart()
Checks requirements, permissions, and expirations before starting.
|
void |
displayError(String message)
Displays the given error to the user
|
void |
displayError(Throwable throwable)
Displays an error message to the user for an exception.
|
void |
exit()
Exits the application with no status.
|
void |
exit(int status)
Exits the application with the given status.
|
String[] |
getArgs() |
com.globalmentor.net.Authenticable |
getAuthenticator() |
static String |
getDisplayErrorMessage(Throwable throwable)
Constructs a user-presentable error message based on an exception.
|
Date |
getExpirationDate() |
String |
getName() |
Preferences |
getPreferences() |
URI |
getURI() |
void |
initialize()
Initializes the application.
|
protected static void |
initialize(Application application,
String[] args)
Initializes the environment for the application.
|
protected void |
performExit(int status)
Exits the application with the given status without checking to see if exit should be performed.
|
static int |
run(Application application,
String[] args)
Starts an application.
|
void |
setAuthenticator(com.globalmentor.net.Authenticable authenticable)
Sets the authenticator object used to retrieve client authentication.
|
protected void |
setExpiration(Date newExpirationDate)
Sets the expiration date of the application.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitmainpublic AbstractApplication(URI uri, String name)
uri - The URI identifying the application.name - The name of the application.public URI getURI()
getURI in interface com.globalmentor.net.Resourcepublic String getName()
getName in interface com.globalmentor.model.Named<String>public com.globalmentor.net.Authenticable getAuthenticator()
getAuthenticator in interface Applicationpublic void setAuthenticator(com.globalmentor.net.Authenticable authenticable)
setAuthenticator in interface Applicationauthenticable - The object to retrieve authentication information regarding a client.HTTPClientpublic String[] getArgs()
getArgs in interface Applicationpublic Preferences getPreferences() throws SecurityException
getPreferences in interface ApplicationSecurityException - Thrown if a security manager is present and it denies RuntimePermission("preferences").public Date getExpirationDate()
getExpirationDate in interface Applicationnull if there is no expiration.protected void setExpiration(Date newExpirationDate)
newExpirationDate - The new expiration date, or null if there is no expiration.public void initialize()
throws Exception
initialize in interface ApplicationException - Thrown if anything goes wrong.public boolean canStart()
canStart in interface Applicationtrue if the checks succeeded.public void displayError(Throwable throwable)
displayError in interface Applicationthrowable - The condition that caused the error.public void displayError(String message)
displayError in interface Applicationmessage - The error to display.public static String getDisplayErrorMessage(Throwable throwable)
Throwable.getMessage().throwable - The condition that caused the error.Throwable.getMessage()public static int run(Application application, String[] args)
application - The application to start.args - The command line arguments.protected static void initialize(Application application, String[] args) throws Exception
application - The application to start.args - The command line arguments.Exception - Thrown if anything goes wrong.protected boolean canExit()
true if the application can exit, else false.public final void exit()
exit(int).exit in interface Applicationexit(int)public final void exit(int status)
performExit(int)
should be overridden rather than this method.exit in interface Applicationstatus - The exit status.canExit(),
performExit(int)Copyright © 1996–2016 GlobalMentor, Inc.. All rights reserved.