public abstract class Application<T extends BaseAppConfig>
implements ConfigAware<T>, ContextHandleAware, JsonDescriptorAware {
//--- App ID and descriptor ---
// Returns the ID of this application, which comes from the "kos.app.appId" field of the "descriptor.json" file:
public String getAppId();
// Returns the descriptor from this application's KAB file (descriptor.json):
public JsonDescriptor getDescriptor();
//--- Handle ---
// Returns the application's handle:
public Handle getHandle();
// Returns the application's handle prefix:
public String getHandlePrefix();
//--- Config ---
// Returns the application's config bean:
public T getConfig();
// Sets the application's config bean:
public void setConfig(T config);
//--- App directory and files ---
// Returns the base directory of the application:
public File getAppDir();
// Adds the specified path to the base application directory and returns it as a File:
public File getAppFile(String path);
//--- Data directory and files ---
// Returns the base directory of the application's local storage area:
public File getDataDir();
// Adds the specified path to the base application data directory and returns it as a File:
public File getDataFile(String path);
//--- Context and VFS ---
// Returns this applicaton's bean context:
public BeanContext getCtx();
// Returns the root VFS (virtual file system) for this application:
public VFS getVfs();
//--- KAB file and related ---
// Returns the application KAB file, allowing for direct access to it contents:
public KabFile getKab();
// Returns the resolved manifest section associated with the application:
public ResolvedManifestSection getSection();
// Returns the storage domain associated with the application:
public StorageDomain getStorage();
//--- Databases ---
// Opens or creates a database with the specified name in the local storage area of the application:
public Jdbi openDatabase(String name, DatabaseMigrator migrator);
//--- Profiles ---
// Returns true if the given profile is in effect:
public boolean hasProfile(String profile);
//--- Methods called by KOS during the application's lifecycle ---
// Called when the application is first loaded; used for application initialization:
public void load() throws Exception;
// Called when the application is started. Once this returns, the application is considered to be running:
public abstract void start() throws Exception;
// Called after start() returns. When this is called, all application VFS and endpoints are available:
public void started() throws Exception;
// Called to stop the application:
public abstract void stop() throws Exception;
// Called when the application is unloaded from memory:
public void unload() throws Exception;
}