- All Implemented Interfaces:
Application,DomainContextProvider,SessionProvider
- Direct Known Subclasses:
AbstractClientApplication
- Author:
- harald
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringProperty to disable the modification tracker.static final StringProperty to disable the tentackle security manager.static final StringProperty to enable statistics.static final StringProperty to set the default locale.static final StringProperty to set the default scripting language. -
Constructor Summary
ConstructorsConstructorDescriptionAbstractApplication(String name, String version) Super constructor for all derived classes.
Detects whether application is running within a container or deployed by JNLP (webstart). -
Method Summary
Modifier and TypeMethodDescriptionprotected voidActivate statistics.
Recommended during development.voidapplyProperties(Properties properties) Applies the given properties.
If the given properties are different from the application properties, they will be copied to the application properties.protected voidcleanup()Cleans up resources.
Invoked fromstop(int, java.lang.Throwable)protected voidDo anything what's necessary after the connection has been established.
The default creates the modification tracker (but does not start it), and configures the preferences and security manager.protected voidConfigures the modification tracker singleton.protected voidConfigures the preferences.protected voidConfigures the security manager.createDomainContext(Session session) Creates the domain context.
Override this method if the application uses a subclass of DomainContext.createSession(SessionInfo sessionInfo) Creates a session.createSessionInfo(String username, char[] password, String sessionPropertiesBaseName) Creates the sessionInfo.
Presets the attributes like locale, timezone, vm-, os- and host-info.protected StringfilterName(String name) Filters the application name.protected StringfilterVersion(String version) Filters the application version.protected voidFinishes the startup.
The default implementation starts the modification tracker, unless the property "notracker" is given.
The property "statistics" activates the statistics.org.tentackle.misc.CommandLineGets the command line.longGets the creation time in epochal milliseconds.Gets the domain context.getName()Gets the application name.protected org.tentackle.common.EncryptedPropertiesGets the current properties.getProperty(String key) Gets an application property.char[]getPropertyAsChars(String key) Gets an application property as a character array.
Useful for passwords and alike.char[]Gets an application property as a character array, case-insensitive.
Useful for passwords and alike.Gets an application property case-insensitive.Gets the session info.Gets the application version.protected voidInitializes the application.
This is the first step when an application is launched.protected voidInitializes the scripting.booleanReturns whether the running application is interactive.booleanisServer()Returns whether the application is a server.protected booleanReturns whether System.exit() must be invoked to stop the application.voidLogs a stackdump.voidLogs and clears the statistics.protected voidsetDomainContext(DomainContext context) Sets the domain context.protected voidsetProperties(org.tentackle.common.EncryptedProperties props) Sets the properties to configure the application.protected voidsetSessionInfo(SessionInfo sessionInfo) Sets the session info.voidStarts the application.protected abstract voidstartup()Invokes all steps to start up the application.
Invoked fromstart(java.lang.String[]).voidTerminates the application with optional error handling.toString()Gets the application's name.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.tentackle.app.Application
getUser, register, start, stop, unregisterMethods inherited from interface org.tentackle.pdo.DomainContextProvider
isWithinContext, isWithinContext, on, on, op, op
-
Field Details
-
DISABLE_MODIFICATION_TRACKER
Property to disable the modification tracker.- See Also:
-
DISABLE_SECURITY_MANAGER
Property to disable the tentackle security manager.- See Also:
-
ENABLE_STATISTICS
Property to enable statistics.- See Also:
-
SCRIPTING
Property to set the default scripting language.- See Also:
-
LOCALE
Property to set the default locale.- See Also:
-
-
Constructor Details
-
AbstractApplication
Super constructor for all derived classes.
Detects whether application is running within a container or deployed by JNLP (webstart).- Parameters:
name- the application name, null for default nameversion- the application version, null for default version- See Also:
-
-
Method Details
-
getName
Gets the application name.- Specified by:
getNamein interfaceApplication- Returns:
- the name, never null
-
filterName
Filters the application name.- Parameters:
name- the name given by the constructor- Returns:
- the filtered name, never null
-
getVersion
Gets the application version.- Specified by:
getVersionin interfaceApplication- Returns:
- the version, never null
-
filterVersion
Filters the application version.- Parameters:
version- the version given by the constructor- Returns:
- the filtered version, never null
-
getCreationTime
public long getCreationTime()Gets the creation time in epochal milliseconds.- Specified by:
getCreationTimein interfaceApplication- Returns:
- the creation time of this application
-
toString
Gets the application's name. -
getCommandLine
public org.tentackle.misc.CommandLine getCommandLine()Gets the command line.- Specified by:
getCommandLinein interfaceApplication- Returns:
- the commandline, null if not started
-
logStackdump
public void logStackdump()Logs a stackdump.The logging level used is INFO.
Can be used for example from a groovy console at runtime. -
isServer
public boolean isServer()Returns whether the application is a server.- Specified by:
isServerin interfaceApplication- Returns:
- true if server, false if a client or nothing of both
-
isInteractive
public boolean isInteractive()Returns whether the running application is interactive.- Specified by:
isInteractivein interfaceApplication- Returns:
- true if interaction with user, false if server, daemon or whatever
-
setProperties
protected void setProperties(org.tentackle.common.EncryptedProperties props) Sets the properties to configure the application.Must be set before starting the application.
- Parameters:
props- the properties to configure the application
-
getProperties
protected org.tentackle.common.EncryptedProperties getProperties()Gets the current properties.- Returns:
- the properties
-
applyProperties
Applies the given properties.
If the given properties are different from the application properties, they will be copied to the application properties.The default implementation first parses the properties for system properties and replaces any system properties according to
StringHelper.evaluate(String, Function).
System properties start withSYSTEM_or^followed by the property name.Other well-known properties that can be set:
scripting=...sets the default scripting languagenosecuritydisables the tentackle security managerlocale=...sets the default locale.- Specified by:
applyPropertiesin interfaceApplication- Parameters:
properties- the properties, null if none
-
getProperty
Description copied from interface:ApplicationGets an application property.- Specified by:
getPropertyin interfaceApplication- Parameters:
key- the property's name- Returns:
- the value of the key, null if no such property, the empty string if no value for this property
-
getPropertyIgnoreCase
Description copied from interface:ApplicationGets an application property case-insensitive.- Specified by:
getPropertyIgnoreCasein interfaceApplication- Parameters:
key- the property's name- Returns:
- the value of the key, null if no such property, the empty string if no value for this property
-
getPropertyAsChars
Description copied from interface:ApplicationGets an application property as a character array.
Useful for passwords and alike.- Specified by:
getPropertyAsCharsin interfaceApplication- Parameters:
key- the property's name- Returns:
- the value of the key, null if no such property, the empty array if no value for this property
-
getPropertyAsCharsIgnoreCase
Description copied from interface:ApplicationGets an application property as a character array, case-insensitive.
Useful for passwords and alike.- Specified by:
getPropertyAsCharsIgnoreCasein interfaceApplication- Parameters:
key- the property's name- Returns:
- the value of the key, null if no such property, the empty array if no value for this property
-
getSession
- Specified by:
getSessionin interfaceSessionProvider
-
setDomainContext
Sets the domain context.- Parameters:
context- the context
-
getDomainContext
Gets the domain context.- Specified by:
getDomainContextin interfaceDomainContextProvider- Returns:
- the domain context
-
getSessionInfo
Gets the session info.- Specified by:
getSessionInfoin interfaceApplication- Returns:
- the session info
-
setSessionInfo
Sets the session info.- Parameters:
sessionInfo- the session info
-
createSessionInfo
public SessionInfo createSessionInfo(String username, char[] password, String sessionPropertiesBaseName) Creates the sessionInfo.
Presets the attributes like locale, timezone, vm-, os- and host-info.- Parameters:
username- is the name of the userpassword- is the password, null if nonesessionPropertiesBaseName- the resource bundle basename of the property file, null if default- Returns:
- the sessionInfo
-
createSession
Creates a session.- Parameters:
sessionInfo- the session info- Returns:
- the open session
-
createDomainContext
Creates the domain context.
Override this method if the application uses a subclass of DomainContext.- Parameters:
session- the session, null if thread-local- Returns:
- the domain context
-
configureModificationTracker
protected void configureModificationTracker()Configures the modification tracker singleton. -
configurePreferences
protected void configurePreferences()Configures the preferences.If the property
"readonlyprefs"is set, any write attempt to the preferences will be silently ignored.
The property"noprefsync"turns off preferences auto sync between jvms.
The property"systemprefs"restricts to system preferences. Default is user and system prefs. -
configureSecurityManager
protected void configureSecurityManager()Configures the security manager. -
initialize
protected void initialize()Initializes the application.
This is the first step when an application is launched. -
initializeScripting
protected void initializeScripting()Initializes the scripting. -
configure
protected void configure()Do anything what's necessary after the connection has been established.
The default creates the modification tracker (but does not start it), and configures the preferences and security manager. -
finishStartup
protected void finishStartup()Finishes the startup.
The default implementation starts the modification tracker, unless the property "notracker" is given.
The property "statistics" activates the statistics. -
activateStatistics
protected void activateStatistics()Activate statistics.
Recommended during development. -
logStatistics
public void logStatistics()Logs and clears the statistics. -
startup
protected abstract void startup()Invokes all steps to start up the application.
Invoked fromstart(java.lang.String[]). -
start
Description copied from interface:ApplicationStarts the application.- Specified by:
startin interfaceApplication- Parameters:
args- the arguments (usually from commandline), null or empty if none
-
stop
Description copied from interface:ApplicationTerminates the application with optional error handling.- Specified by:
stopin interfaceApplication- Parameters:
exitValue- the stop value for System.exit()exitThrowable- an exception causing the termination, null if none
-
isSystemExitNecessaryToStop
protected boolean isSystemExitNecessaryToStop()Returns whether System.exit() must be invoked to stop the application.- Returns:
- true if JVM must be terminated
-
cleanup
protected void cleanup()Cleans up resources.
Invoked fromstop(int, java.lang.Throwable)
-