- All Implemented Interfaces:
Application
,DomainContextProvider
,SessionProvider
- Direct Known Subclasses:
AbstractClientApplication
- Author:
- harald
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Property to disable the modification tracker.static final String
Property to disable the tentackle security manager.static final String
Property to enable statistics.static final String
Property to set the default locale.static final String
Property to set the default scripting language. -
Constructor Summary
ConstructorDescriptionAbstractApplication
(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 void
Activate statistics.
Recommended during development.void
applyProperties
(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 void
cleanup()
Cleans up resources.
Invoked fromstop(int, java.lang.Throwable)
protected void
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.protected void
Configures the modification tracker singleton.protected void
Configures the preferences.protected void
Configures 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 String
filterName
(String name) Filters the application name.protected String
filterVersion
(String version) Filters the application version.protected void
Finishes the startup.
The default implementation starts the modification tracker, unless the property "notracker" is given.
The property "statistics" activates the statistics.org.tentackle.misc.CommandLine
Gets the command line.long
Gets the creation time in epochal milliseconds.Gets the domain context.getName()
Gets the application name.protected org.tentackle.common.EncryptedProperties
Gets 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 void
Initializes the application.
This is the first step when an application is launched.protected void
Initializes the scripting.boolean
Returns whether the running application is interactive.boolean
isServer()
Returns whether the application is a server.protected boolean
Returns whether System.exit() must be invoked to stop the application.void
Logs a stackdump.void
Logs and clears the statistics.protected void
setDomainContext
(DomainContext context) Sets the domain context.protected void
setProperties
(org.tentackle.common.EncryptedProperties props) Sets the properties to configure the application.protected void
setSessionInfo
(SessionInfo sessionInfo) Sets the session info.void
Starts the application.protected abstract void
startup()
Invokes all steps to start up the application.
Invoked fromstart(java.lang.String[])
.void
Terminates 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, wait
Methods inherited from interface org.tentackle.app.Application
getUser, register, start, stop, unregister
Methods 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:
getName
in 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:
getVersion
in 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:
getCreationTime
in 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:
getCommandLine
in 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:
isServer
in 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:
isInteractive
in 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 languagenosecurity
disables the tentackle security managerlocale=...
sets the default locale.- Specified by:
applyProperties
in interfaceApplication
- Parameters:
properties
- the properties, null if none
-
getProperty
Description copied from interface:Application
Gets an application property.- Specified by:
getProperty
in 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:Application
Gets an application property case-insensitive.- Specified by:
getPropertyIgnoreCase
in 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:Application
Gets an application property as a character array.
Useful for passwords and alike.- Specified by:
getPropertyAsChars
in 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:Application
Gets an application property as a character array, case-insensitive.
Useful for passwords and alike.- Specified by:
getPropertyAsCharsIgnoreCase
in 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:
getSession
in interfaceSessionProvider
-
setDomainContext
Sets the domain context.- Parameters:
context
- the context
-
getDomainContext
Gets the domain context.- Specified by:
getDomainContext
in interfaceDomainContextProvider
- Returns:
- the domain context
-
getSessionInfo
Gets the session info.- Specified by:
getSessionInfo
in 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:Application
Starts the application.- Specified by:
start
in interfaceApplication
- Parameters:
args
- the arguments (usually from commandline), null or empty if none
-
stop
Description copied from interface:Application
Terminates the application with optional error handling.- Specified by:
stop
in 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)
-