Class AppService

java.lang.Object
com.kosdev.kos.core.service.app.AppService

public final class AppService extends Object
Service that manages applications within KOS.
Since:
1
Version:
9
  • Field Details

  • Method Details

    • loadApp

      public AppLoader loadApp(KabFile kab, Application<?> parent)
      Attempts to load the specified application. The specified KAB must contain a properly formed kos.app section in the descriptor. Typically applications are packaged in kabs of type "kos.app" but this is not required unless they are part of the kos.autostart.* section.

      If a parent application is specified, the new application class loader and bean context will use the parent application class loader and bean context as parents. This allows the new application to access classes and beans from the parent application.

      The resulting loader can be used to start the app by calling loader.start() . This allows the application context to be modified before the application is started, which is an effective way to pass data to an application.

      Parameters:
      kab - the application KAB
      parent - optional parent application
      Returns:
      AppLoader used to start the app
      Since:
      1
    • loadApp

      public AppLoader loadApp(KabFile kab, Application<?> parent, Collection<Object> beans)
      Attempts to load the specified application. The specified KAB must contain a properly formed kos.app section in the descriptor. Typically applications are packaged in kabs of type "kos.app" but this is not required unless they are part of the kos.autostart.* section.

      If a parent application is specified, the new application class loader and bean context will use the parent application class loader and bean context as parents. This allows the new application to access classes and beans from the parent application.

      The resulting loader can be used to start the app by calling loader.start() . This allows the application context to be modified before the application is started, which is an effective way to pass data to an application.

      This allows a collection of beans to be specified. These beans will be added to the BeanContext of the application before it is configured. This allows passing beans to a an application and by autowiring them within the application.

      Parameters:
      kab - the application KAB
      parent - optional parent application
      beans - optional connection of beans to add to the app context
      Returns:
      AppLoader used to start the app
      Since:
      1
    • unloadApp

      public void unloadApp(AppLoader loader)
      Unloads the application associated with the given loader.
      Parameters:
      loader - the loader to unload
      Since:
      1
    • getAutostartAppsReady

      public ReadyIndicator getAutostartAppsReady()
      Return a ReadyIndicator that is ready once all autostart applications are started.
      Since:
      8
    • getAutostartApps

      public Collection<LoadableApp> getAutostartApps()
      Return the list of auto-started applications from the manifest. These are defined in sections with a "kos.autostart." prefix.
      Since:
      8
    • getApps

      public Collection<LoadableApp> getApps()
      Return the list of discovered applications in the manifest. These includes every kab of type kos.app , regardless of the section they are in.
      Since:
      8
    • getStartedApps

      public List<Application<?>> getStartedApps()
      Return the list of all applications that have already been started. This only includes application that have been loaded and started, and not stopped.
      Since:
      8
    • whenAppStarted

      public void whenAppStarted(String appId, AppStartedCallback callback)
      Call the specified callback when the requested appId is started. If already started, this will be called immediately. This will only be called once. If the application unloads and reloads it will not be called again. This is a convenience method which is a simple alternative to implementing AppListener .
      Since:
      6
    • isAppInstalled

      public boolean isAppInstalled(String appId)
      Return true if the specified appId is installed as part of the running manifest.
      Since:
      9
    • isAppAutostart

      public boolean isAppAutostart(String appId)
      Return true if the specified appId is in an autostart section.
      Since:
      9
    • getApiVersion

      public int getApiVersion(String appId)
      Return the api version for the specified appId. Returns -1 if the app is not installed.
      Parameters:
      appId - the id of the app
      Since:
      9