Class AbstractServerApplication
- All Implemented Interfaces:
Application, ConnectionManagerProvider, DomainContextProvider, org.tentackle.session.SessionPoolProvider, org.tentackle.session.SessionProvider
- Direct Known Subclasses:
ServerApplication
A server application is either connected directly to the database (and serves the client sessions
from a SessionPool via its own ConnectionManager), or is itself a client of another server
(and serves the client sessions from a MultiUserSessionPool of remote sessions).
Server applications may also run within a container, such as a servlet engine.
- Author:
- harald
-
Field Summary
Fields inherited from class AbstractApplication
DISABLE_MODIFICATION_TRACKER, DISABLE_SECURITY_MANAGER, ENABLE_STATISTICS, LOCALE, SCRIPTING -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidprotected voidcleanup()protected voidprotected voidprotected voidconfigureSessionInfo(org.tentackle.session.SessionInfo sessionInfo) Configures the session info of the server's main session.
Loads the session properties and merges the application properties into them.protected ConnectionManagerCreates the connection manager for the client sessions.
The default creates anMpxConnectionManagerwith session IDs following those of the server's own connection manager.org.tentackle.session.MultiUserSessionPoolCreates the remote session pool to serve the client sessions.
If the server's main session does not belong to a session group yet, a new group is created with the main session, so that all pooled sessions are closed if the main session dies.org.tentackle.session.SessionPoolCreates the session pool to serve the client sessions.protected voidDeregisters all JDBC drivers loaded by the app's classloader.
Necessary in containers only (in case connected directly via JDBC and not via JNDI).protected voidDetects whether this application is running within a container.
The result can be retrieved byisRunningInContainer().protected voidorg.tentackle.session.MultiUserSessionPoolorg.tentackle.session.SessionPoolprotected voidbooleanIndicates whether this application is running within a container.booleanisServer()protected booleanprotected voidlogin()Connects the server to the database backend or another remote server.
Creates the server's main session, makes it the current session and sets the application's session info and domain context.voidLogs and clears the statistics.
Overridden to log the statement and transaction statistics as well.protected voidsetSessionInfo(org.tentackle.session.SessionInfo sessionInfo) protected voidstartup()protected voidValidates the validators.
The default implementation loads all field- and object-Validators of all PDO classes and invokesValidator.validate().Methods inherited from class AbstractApplication
applyProperties, configure, configureSecurityManager, createDomainContext, createSession, createSessionInfo, filterName, filterVersion, getCommandLine, getCreationTime, getDomainContext, getName, getProperties, getProperty, getPropertyAsChars, getPropertyAsCharsIgnoreCase, getPropertyIgnoreCase, getSessionInfo, getVersion, initialize, isInteractive, isPropertySet, logStackdump, preloadCaches, setDomainContext, setProperties, start, stop, toStringMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Application
getUser, register, start, stop, unregisterMethods inherited from interface DomainContextProvider
isWithinContext, isWithinContext, on, on, op, op
-
Constructor Details
-
AbstractServerApplication
-
-
Method Details
-
getSessionPool
public org.tentackle.session.SessionPool getSessionPool()The pool is created by
finishStartup()if the server is connected directly to the database.- Specified by:
getSessionPoolin interfaceorg.tentackle.session.SessionPoolProvider- Returns:
- the session pool, null if the server's session is remote or not started yet
-
getRemoteSessionPool
public org.tentackle.session.MultiUserSessionPool getRemoteSessionPool()The pool is created by
finishStartup()if the server is a client of another server.- Specified by:
getRemoteSessionPoolin interfaceorg.tentackle.session.SessionPoolProvider- Returns:
- the remote session pool, null if the server's session is local or not started yet
-
isServer
public boolean isServer()- Specified by:
isServerin interfaceApplication- Overrides:
isServerin classAbstractApplication
-
setSessionInfo
protected void setSessionInfo(org.tentackle.session.SessionInfo sessionInfo) Overridden to protect the SessionInfo once it is set. The session info is made immutable.
- Overrides:
setSessionInfoin classAbstractApplication- Throws:
org.tentackle.session.PersistenceException- if the session info is already set
-
configurePreferences
protected void configurePreferences()Overridden to restrict the server to system preferences.
- Overrides:
configurePreferencesin classAbstractApplication
-
configureModificationTracker
protected void configureModificationTracker()Overridden to set the tracker's sleep interval to 1 second.
- Overrides:
configureModificationTrackerin classAbstractApplication
-
initializeScripting
protected void initializeScripting()Overridden to validate the validators afterward.
- Overrides:
initializeScriptingin classAbstractApplication- See Also:
-
validateValidators
protected void validateValidators()Validates the validators.
The default implementation loads all field- and object-Validators of all PDO classes and invokesValidator.validate(). This will load allCompoundValues and compile the scripts, if any. Thus, configuration errors are detected at server startup. -
finishStartup
protected void finishStartup()Overridden to create the session pool and connection manager for local sessions, or the remote session pool if this server is a client of another server.
- Overrides:
finishStartupin classAbstractApplication
-
createSessionPool
public org.tentackle.session.SessionPool createSessionPool()Creates the session pool to serve the client sessions.- Returns:
- the session pool
-
createRemoteSessionPool
public org.tentackle.session.MultiUserSessionPool createRemoteSessionPool()Creates the remote session pool to serve the client sessions.
If the server's main session does not belong to a session group yet, a new group is created with the main session, so that all pooled sessions are closed if the main session dies.- Returns:
- the session pool
-
getSession
- Specified by:
getSessionin interfaceorg.tentackle.session.SessionProvider- Overrides:
getSessionin classAbstractApplication
-
createConnectionManager
Creates the connection manager for the client sessions.
The default creates anMpxConnectionManagerwith session IDs following those of the server's own connection manager.- Returns:
- the connection manager
-
getConnectionManager
- Specified by:
getConnectionManagerin interfaceConnectionManagerProvider
-
configureSessionInfo
protected void configureSessionInfo(org.tentackle.session.SessionInfo sessionInfo) Configures the session info of the server's main session.
Loads the session properties and merges the application properties into them. Application properties override those from a file or the classpath.- Parameters:
sessionInfo- the session info
-
startup
protected void startup()Registers and initializes the server, logs into the backend, configures the server and finishes the startup.
- Specified by:
startupin classAbstractApplication
-
login
protected void login()Connects the server to the database backend or another remote server.
Creates the server's main session, makes it the current session and sets the application's session info and domain context. -
cleanup
protected void cleanup()Overridden to shut down the session pools and the connection manager. If running in a container, the JDBC drivers loaded by the application are deregistered.
- Overrides:
cleanupin classAbstractApplication
-
isRunningInContainer
public boolean isRunningInContainer()Indicates whether this application is running within a container.- Returns:
- true if running in a container, false if not
-
isSystemExitNecessaryToStop
protected boolean isSystemExitNecessaryToStop()- Overrides:
isSystemExitNecessaryToStopin classAbstractApplication
-
detectContainer
protected void detectContainer()Detects whether this application is running within a container.
The result can be retrieved byisRunningInContainer(). -
deregisterJdbcDrivers
Deregisters all JDBC drivers loaded by the app's classloader.
Necessary in containers only (in case connected directly via JDBC and not via JNDI). Avoids memory leaks.- Parameters:
cl- the app's classloader
-
activateStatistics
protected void activateStatistics()Overridden to collect the statistics of remote invocations, connections and transactions as well.
- Overrides:
activateStatisticsin classAbstractApplication
-
logStatistics
public void logStatistics()Logs and clears the statistics.
Overridden to log the statement and transaction statistics as well.- Overrides:
logStatisticsin classAbstractApplication
-