de.esprit.appsuite.appstore

## Class AppCacheManager

- java.lang.Object
- - de.esprit.common.util.DumpableObject
  - - de.esprit.appsuite.launch.AbstractApplicationObject<C>
    - - de.esprit.appsuite.launch.AbstractInitializableObject<ApplicationContext>
      - - de.esprit.appsuite.appstore.AppCacheManager

- All Implemented Interfaces:
    ApplicationObject<ApplicationContext>, Initializable, SimpleLogSupport, Dumpable

      public class AppCacheManager
      extends AbstractInitializableObject<ApplicationContext>

  This class implements the esprit application store. It provides web-start similar functionality for downloading remote software and executing it locally. The application software is provided by a remote software repository. Launching an application happens in two phases.
  1. The `EspritAppStarter` will be installed and started on the client using the standard java-webstart mechanism. It's first action will be to mirror the remote repository structure to a local cache directory by downloading the according description files.
  2. The `EspritAppStarter` downloads and extracts the desired software from an remote zip-archive file. Then it uses the information provided by the `AppDescriptor` to actually launch the software.
  Note that before the download of any file an update-check is done with the remote software repository. An update will only be done if the remote information has changed since the last check.

  The main advantage of the `AppCacheManager` is, that you have full control over every launching detail - i.e. which java version should be used for launching, how much memory should be used etc. Furthermore the downloaded software is not restricted to be pure java. It's jar-files need not to be signed and it also may contain platform specific libraries. Because it executes under the control of the `EspritAppStarterLaunch` it is also restartable.

  The remote software repository is structured as follows:

  - Application directory
    The available applications are described in an `App`s.ndf file
  - Versions directory
    The available versions are described in an `AppVersion`s.ndf file
  - Launch directory
    The Software launch is described in an `AppDescriptor`.ndf file and the software itself is provided by a zip-file which is referred in the app-appDescr
  Author:
    Rainer Buesch
  See Also:
    `EspritAppStarter`

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `AppCacheManager(ApplicationContext ctx, AppCacheUpdater updater)`
    `AppCacheManager(ApplicationContext ctx, java.io.File appCacheRoot, java.net.URL appStoreUrl)`
    `AppCacheManager(ApplicationContext ctx, LogChannel logCh, java.io.File appCacheRoot, java.net.URL appStoreUrl)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `AbstractAsyncTask` | `buildInstallationTask(AppDescriptor descr)`
    `WorkflowTask` | `buildInstallationWFT(AbstractWorkflow workflow, AppDescriptor descr)`
    `WorkflowTask` | `buildJavaAppStartWFT(AbstractWorkflow workflow, JavaAppDescriptor descr, JavaVersion javaVersion, java.util.List<java.lang.String> vmArgList, java.util.List<java.lang.String> commandLineArgList)`
    `JavaCommandTask` | `buildStartJavaAppTask(JavaAppDescriptor descr, JavaVersion javaVersion, java.util.List<java.lang.String> vmArgList, java.util.List<java.lang.String> commandLineArgList)`
    `WorkflowTask` | `buildStartJavaAppWFT(AbstractWorkflow workflow, JavaAppDescriptor descr)`
    `void` | `checkIsSoftwareInstalled(AppDescriptor appDescr)`
    `void` | `checkSoftwareInstallation(AppDescriptor appDescr)`
    `void` | `clearAppCache()`
    `void` | `clearAppLogs()`
    `protected AppDescriptorHandler` | `createAppDescriptorHandler(AppVersion appVersion)`
    `static void` | `deleteAppLaunchPrefsTryFile(java.io.File launchDir)`
    `AppDescriptor` | `findApp(java.lang.String appName)` Finds the `AppDescriptor` for the given appName.
    `AppDescriptor` | `findApp(java.lang.String appName, java.lang.String versionName)` Finds the `AppDescriptor` that matches the given appName and versionName.
    `java.io.File` | `getAppCacheDir()`
    `java.io.File` | `getAppCacheRoot()`
    `java.util.List<AppDescriptor>` | `getAppDescriptors()`
    `java.io.File` | `getAppLogDir()`
    `java.util.List<App>` | `getApps()`
    `java.util.List<AppVersion>` | `getAppVersions()`
    `java.util.List<JavaAppDescriptor>` | `getJavaAppDescriptors()`
    `java.io.File` | `getLaunchDir(AppDescriptor appDescr)`
    `java.io.File` | `getLaunchDir(AppVersion appVersion)`
    `static boolean` | `hasAppLaunchPrefsTryFile(java.io.File launchDir)`
    `void` | `init()` Performs the initialization of this class.
    `boolean` | `isSoftwareInstalled(AppDescriptor appDescr)`
    `void` | `loadAppTree()`
    `static AppLaunchPrefs` | `readAppLaunchPrefs(ApplicationContext ctx, java.io.File launchDir)` Reads the `AppLaunchPrefs` from the given launchDir.
    `void` | `setLogChannel(LogChannel logCh)`
    `void` | `setUpdater(AppCacheUpdater updater)`
    `void` | `setUpdaterEnabled(boolean isEnabled)`
    `AppLaunchTask` | `startApp(AppDescriptor appDescr, java.io.File appWorkingDir, LogChannel logCh)` Returns a launch-task which is not yet submitted!
    `AppLaunchTask` | `startApp(java.lang.String appName, java.io.File appWorkingDir)`
    `AppLaunchTask` | `startApp(java.lang.String appName, java.lang.String versionName, java.io.File appWorkingDir)`
    `AppLaunchTask` | `startApp(java.lang.String appName, java.lang.String versionName, java.io.File appWorkingDir, LogChannel logCh)`
    `static void` | `storeAppLaunchPrefs(ApplicationContext ctx, java.io.File launchDir, AppLaunchPrefs launchPrefs)`

    - ### Methods inherited from class de.esprit.appsuite.launch.AbstractInitializableObject

      `checkInitialized, isInitialized, setInitialized`

    - ### Methods inherited from class de.esprit.appsuite.launch.AbstractApplicationObject

      `getApplicationContext, getLogChannel, isLogDebug, isLogVerbose, logDebug, logDump, logError, logError, logFatal, logInfo, logVerbose, logWarning`

    - ### Methods inherited from class de.esprit.common.util.DumpableObject

      `configureDumpHeadlineLength, configureDumpMaxElementsPrinted, copyDumpStringValues, copyToStringValues, createDumpHeader, toDumpString, toDumpString, toString, toString`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### AppCacheManager

          public AppCacheManager(ApplicationContext ctx,
                         java.io.File appCacheRoot,
                         java.net.URL appStoreUrl)

    - #### AppCacheManager

          public AppCacheManager(ApplicationContext ctx,
                         LogChannel logCh,
                         java.io.File appCacheRoot,
                         java.net.URL appStoreUrl)

    - #### AppCacheManager

          public AppCacheManager(ApplicationContext ctx,
                         AppCacheUpdater updater)

  - ### Method Detail

    - #### init

          public void init()
                    throws java.lang.Exception

      Description copied from interface: `Initializable`
      Performs the initialization of this class. Note that the implementation should maintain an isInitialized flag which must be set when initialization has completed.
      Specified by:
        `init` in interface `Initializable`
      Specified by:
        `init` in class `AbstractInitializableObject<ApplicationContext>`
      Throws:
        `java.lang.Exception`

    - #### setUpdaterEnabled

          public void setUpdaterEnabled(boolean isEnabled)

    - #### setUpdater

          public final void setUpdater(AppCacheUpdater updater)

    - #### setLogChannel

          public final void setLogChannel(LogChannel logCh)

      Specified by:
        `setLogChannel` in interface `SimpleLogSupport`
      Overrides:
        `setLogChannel` in class `AbstractApplicationObject<ApplicationContext>`

    - #### getAppCacheRoot

          public final java.io.File getAppCacheRoot()

    - #### getAppCacheDir

          public final java.io.File getAppCacheDir()

    - #### getAppLogDir

          public final java.io.File getAppLogDir()

    - #### getLaunchDir

          public final java.io.File getLaunchDir(AppVersion appVersion)

    - #### getLaunchDir

          public final java.io.File getLaunchDir(AppDescriptor appDescr)

    - #### loadAppTree

          public final void loadAppTree()
                                 throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### clearAppCache

          public final void clearAppCache()

    - #### clearAppLogs

          public final void clearAppLogs()

    - #### getApps

          public final java.util.List<App> getApps()

    - #### getAppVersions

          public final java.util.List<AppVersion> getAppVersions()

    - #### getAppDescriptors

          public final java.util.List<AppDescriptor> getAppDescriptors()

    - #### getJavaAppDescriptors

          public final java.util.List<JavaAppDescriptor> getJavaAppDescriptors()

    - #### findApp

          public final AppDescriptor findApp(java.lang.String appName)

      Finds the `AppDescriptor` for the given appName. Note that you will get the version marked as the current one.

    - #### findApp

          public final AppDescriptor findApp(java.lang.String appName,
                              java.lang.String versionName)

      Finds the `AppDescriptor` that matches the given appName and versionName.

    - #### startApp

          public final AppLaunchTask startApp(java.lang.String appName,
                               java.io.File appWorkingDir)
                                       throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### startApp

          public final AppLaunchTask startApp(java.lang.String appName,
                               java.lang.String versionName,
                               java.io.File appWorkingDir)
                                       throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### startApp

          public final AppLaunchTask startApp(java.lang.String appName,
                               java.lang.String versionName,
                               java.io.File appWorkingDir,
                               LogChannel logCh)
                                       throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### startApp

          public final AppLaunchTask startApp(AppDescriptor appDescr,
                               java.io.File appWorkingDir,
                               LogChannel logCh)
                                       throws java.lang.Exception

      Returns a launch-task which is not yet submitted!
      Throws:
        `java.lang.Exception`

    - #### createAppDescriptorHandler

          protected AppDescriptorHandler createAppDescriptorHandler(AppVersion appVersion)

    - #### buildInstallationTask

          public final AbstractAsyncTask buildInstallationTask(AppDescriptor descr)

    - #### buildInstallationWFT

          public final WorkflowTask buildInstallationWFT(AbstractWorkflow workflow,
                                          AppDescriptor descr)

    - #### buildStartJavaAppTask

          public final JavaCommandTask buildStartJavaAppTask(JavaAppDescriptor descr,
                                              JavaVersion javaVersion,
                                              java.util.List<java.lang.String> vmArgList,
                                              java.util.List<java.lang.String> commandLineArgList)

    - #### buildStartJavaAppWFT

          public final WorkflowTask buildStartJavaAppWFT(AbstractWorkflow workflow,
                                          JavaAppDescriptor descr)

    - #### buildJavaAppStartWFT

          public final WorkflowTask buildJavaAppStartWFT(AbstractWorkflow workflow,
                                          JavaAppDescriptor descr,
                                          JavaVersion javaVersion,
                                          java.util.List<java.lang.String> vmArgList,
                                          java.util.List<java.lang.String> commandLineArgList)

    - #### storeAppLaunchPrefs

          public static void storeAppLaunchPrefs(ApplicationContext ctx,
                                 java.io.File launchDir,
                                 AppLaunchPrefs launchPrefs)
                                          throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### hasAppLaunchPrefsTryFile

          public static boolean hasAppLaunchPrefsTryFile(java.io.File launchDir)

    - #### deleteAppLaunchPrefsTryFile

          public static void deleteAppLaunchPrefsTryFile(java.io.File launchDir)
                                                  throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### readAppLaunchPrefs

          public static AppLaunchPrefs readAppLaunchPrefs(ApplicationContext ctx,
                                          java.io.File launchDir)
                                                   throws java.lang.Exception

      Reads the `AppLaunchPrefs` from the given launchDir. This is happens in three steps:
      1. The default `AppLaunchPrefs` are read from the `AppDescriptor`
      2. If a launchPrefsTry file exists then the defaults are overridden with the values read from that file
      3. If there is no launchPrefsTry file, but instead a launchPrefs file exists then the defaults are overridden with the values read from that file
      Throws:
        `java.lang.Exception`

    - #### isSoftwareInstalled

          public final boolean isSoftwareInstalled(AppDescriptor appDescr)

    - #### checkIsSoftwareInstalled

          public final void checkIsSoftwareInstalled(AppDescriptor appDescr)
                                              throws java.lang.Exception

      Throws:
        `java.lang.Exception`

    - #### checkSoftwareInstallation

          public final void checkSoftwareInstallation(AppDescriptor appDescr)
                                               throws java.lang.Exception

      Throws:
        `java.lang.Exception`

Copyright © 2014 EsprIT-Systems. All Rights Reserved.