Class AppDefinition
java.lang.Object
com.iizix.server.app.AppDefinition
Application definition when loading the applications/projects.
- Author:
- Christopher Mindus
Field Summary
FieldsConstructor Summary
ConstructorsConstructorDescriptionAppDefinition(DBApp dbApp, boolean doHotDeploy) Constructor for an app definition from a database definition.AppDefinition(String id, Set<String> aliases, String serverEnvironmentName, File iiziAppFile, boolean doHotDeploy) Constructor for an app definition loaded from a compiled iiziApp Jar file, or, for the development server only, from separate Module project directories.Method Summary
Modifier and TypeMethodDescriptionbooleanaddListener(IAppChangedListener listener) Adds an app change listener to be informed of app load/reloads and/or app dispose.voidaddModuleDirectory(File dir) Adds a directory for loading.voiddispose()Disposes of the application definition.voidDisposes of the application's hot deploy.Gets the unmodifiable application aliases set.Get the web server file provider for the application session.Gets the application factory.Gets the compiled iiziApp Jar file of this definition (CC-FIX-APP-DEFINITIONS).longGets the load generation: the count of successful loads of this application (CC-FIX-APP-MODULE-REFERENCES).Gets the Module project directories of this definition (-project, the development server), in the order they were added.Gets the Module projects this definition loads from its OWN directories (CC-FIX-APP-MODULE-REFERENCES): the Module projects of the current factory whose directory is one ofgetModuleDirectories(), i.e.Gets the IDs of the applications whose Module projects this application includes as copies, i.e.Returns the Server environment for the application.booleanChecks if the iiziApp has been changed and needs reload.booleanChecks if hot deploy is used for this application.booleanChecks if this definition is a compiled iiziApp Jar file given as a file (the-appjarform of the command line, or afileNameof the configuration), as opposed to Module project directories or a database application.booleanChecks if this definition loads Module project directories (-project, the development server): such an application is never written into the server configuration (CC-FIX-APP-DEFINITIONS, M-5).voidloadApplication(ServerShell server) Loads the application.booleanreload(ServerShell server, boolean forceReload) Reloads the application if it has changed.booleanremoveListener(IAppChangedListener listener) Adds an app change listener to be informed of app load/reloads and/or app dispose.
Field Details
id
The ID of the application.
Constructor Details
AppDefinition
Constructor for an app definition from a database definition.- Parameters:
dbApp- The database app instance.doHotDeploy- Hot deploy flag.
AppDefinition
public AppDefinition(String id, Set<String> aliases, String serverEnvironmentName, File iiziAppFile, boolean doHotDeploy) Constructor for an app definition loaded from a compiled iiziApp Jar file, or, for the development server only, from separate Module project directories.With
iiziAppFilenull the definition is for Module directories: add them withaddModuleDirectory(File)before loading, or loading fails with an IOException.- Parameters:
id- The application ID.aliases- The unmodifiable application aliases set.serverEnvironmentName- The server environment name to use,nullfor default.iiziAppFile- The compiled iiziApp Jar file, ornullfor Module directories.doHotDeploy- Hot deploy flag.
Method Details
getAppAliases
getIiziAppFile
Gets the compiled iiziApp Jar file of this definition (CC-FIX-APP-DEFINITIONS).- Returns:
- The Jar file, or
nullfor an application of Module project directories or of a database.
isJarApplication
public boolean isJarApplication()Checks if this definition is a compiled iiziApp Jar file given as a file (the-appjarform of the command line, or afileNameof the configuration), as opposed to Module project directories or a database application.- Returns:
- true for a Jar file application.
isModuleDirectories
public boolean isModuleDirectories()Checks if this definition loads Module project directories (-project, the development server): such an application is never written into the server configuration (CC-FIX-APP-DEFINITIONS, M-5).- Returns:
- true for Module project directories.
getModuleDirectories
getOwnModuleProjects
Gets the Module projects this definition loads from its OWN directories (CC-FIX-APP-MODULE-REFERENCES): the Module projects of the current factory whose directory is one ofgetModuleDirectories(), i.e. without the copies included for the Module projects of other applications this one references.- Returns:
- The own Module projects; empty for a compiled application or when not loaded.
getLoadGeneration
public long getLoadGeneration()Gets the load generation: the count of successful loads of this application (CC-FIX-APP-MODULE-REFERENCES).- Returns:
- The generation, zero before the first load.
getReferencedApplicationIDs
Gets the IDs of the applications whose Module projects this application includes as copies, i.e. the applications it references, directly or through a chain (CC-FIX-APP-MODULE-REFERENCES).- Returns:
- The application IDs in order of inclusion, empty for an application without references.
dispose
public void dispose()Disposes of the application definition.This method is intended to be called from the server: DO NOT CALL THIS METHOD.
addListener
Adds an app change listener to be informed of app load/reloads and/or app dispose.- Parameters:
listener- The listener to add.- Returns:
trueif the listener was added,falseotherwise (nothing changed).- Throws:
NullPointerException- If thelistenerisnull.
removeListener
Adds an app change listener to be informed of app load/reloads and/or app dispose.- Parameters:
listener- The listener to remove.- Returns:
trueiflisteneris successfully removed,falseotherwise, i.e. if not previous an added listener instance.
getFactory
Gets the application factory.- Returns:
- The application factory once loaded,
nullotherwise.
addModuleDirectory
Adds a directory for loading.- Parameters:
dir- The Module directory to load.- Throws:
IOException- if the directory is already added, or if the application definition is a compiled application.
hasAppChanged
public boolean hasAppChanged()Checks if the iiziApp has been changed and needs reload.- Returns:
- true if app has changed and hot deploy is used, false when not changed or hot deploy is not used.
getServerEnvironmentName
Returns the Server environment for the application.loadApplication
public void loadApplication(ServerShell server) throws PropException, IOException, ServerApplicationSetupException, IllegalStateException Loads the application.- Throws:
IOException- For file errors.PropException- For property errors.ServerApplicationSetupException- In case a plug-in fail to initialize.IllegalStateException- If there are duplicates among the names, or if there is a collision of names in the Assets table when applying the App ID and/or it's aliases, or the asset table is corrupt.
isHotDeployEnabled
public boolean isHotDeployEnabled()Checks if hot deploy is used for this application.- Returns:
- true if hot deploy is enabled, false otherwise.
reload
public boolean reload(ServerShell server, boolean forceReload) throws PropException, IOException, ServerApplicationSetupException, IllegalStateException Reloads the application if it has changed. Apps loaded from databases are not reloaded using this method.An application that includes the Module projects of other applications as copies (CC-FIX-APP-MODULE-REFERENCES) reloads when one of them has reloaded or changed, and reloads those first, so that its copies are taken from their current state; a referenced application's reload in turn reloads every application that includes it.
- Returns:
- true if reloaded, false if not changed or not loaded with hot deploy.
- Throws:
IOException- For file errors.PropException- For property errors.ServerApplicationSetupException- In case a plug-in fail to initialize.IllegalStateException- If there are duplicates among the names, or if there is a collision of names in the Assets table when applying the App ID and/or it's aliases, or the asset table is corrupt.
disposeHotDeploy
public void disposeHotDeploy()Disposes of the application's hot deploy.getAppSessionFileProvider
Get the web server file provider for the application session.- Returns:
- The web server file provider.
- Throws:
IOException- If the directory for the application session files failed to be created.IllegalStateException- If the application is not yet loaded or is disposed of.