Class AppService
- All Implemented Interfaces:
CtxEventListener
,ContextHandleAware
,HandleAware
,Ready
,ReadyListener
- Since:
- 1.0
- Version:
- 2023-03-06
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiongetApps()
Return the list of discovered applications in the manifest.Return the list of auto-started applications from the manifest.Return aReadyIndicator
that is ready once all autostart applications are started.loadApp
(KabFile kab, Application<?> parent) Attempts to load the specified application.loadApp
(KabFile kab, Application<?> parent, Collection<Object> beans) Attempts to load the specified application.void
Override of theReadyListener
interface.void
Unloads the application associated with the given loader.void
whenAppStarted
(String appId, AppStartedCallback callback) Call the specified callback when the requested appId is started.Methods inherited from class com.tccc.kos.commons.core.service.AbstractService
getHandle, getHandlePrefix
Methods inherited from class com.tccc.kos.commons.util.ready.ReadyBean
getReady, onBeanReady
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.tccc.kos.commons.core.context.CtxEventListener
onCtxAutowiringCompleted, onCtxDestroyed, onCtxPhaseCompleted
Methods inherited from interface com.tccc.kos.commons.core.service.handle.HandleAware
addHandleChild, getName, getPath
Methods inherited from interface com.tccc.kos.commons.util.ready.ReadyListener
onDependenciesGroupReady
-
Field Details
-
SYSTEM_SECTION
- See Also:
-
SECTION_PREFIX_AUTOSTART
- See Also:
-
SYSTEM_CONFIG_FILE
- See Also:
-
SYSTEM_APP_ID
- See Also:
-
-
Method Details
-
onDependenciesReady
public void onDependenciesReady()Description copied from class:ReadyBean
Override of theReadyListener
interface. This will callonBeanReady()
and returning true will cause this bean to be marked ready. OverridingonBeanReady
is much safer as it explicitly indicates ready or not whereas overriding this method requires the caller to remember to callsuper.onDependenciesReady()
or explicitly callsetReady()
which is error prone.- Specified by:
onDependenciesReady
in interfaceReadyListener
- Overrides:
onDependenciesReady
in classReadyBean
-
loadApp
Attempts to load the specified application. The specified KAB must contain a properly formedkos.app
section in the descriptor. Typically applications are packaged in kabs of type "kos.app" but this is not required unless they are part ofkos.app.*
orkos.autostart.*
sections.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 KABparent
- optional parent application- Returns:
AppLoader
used to start the app
-
loadApp
Attempts to load the specified application. The specified KAB must contain a properly formedkos.app
section in the descriptor. Typically applications are packaged in kabs of type "kos.app" but this is not required unless they are part ofkos.app.*
orkos.autostart.*
sections.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 KABparent
- optional parent applicationbeans
- optional connection of beans to add to the app context- Returns:
AppLoader
used to start the app
-
unloadApp
Unloads the application associated with the given loader. -
getAutostartAppsReady
Return aReadyIndicator
that is ready once all autostart applications are started. -
getAutostartApps
Return the list of auto-started applications from the manifest. These are defined in sections with a"kos.autostart."
prefix. -
getApps
Return the list of discovered applications in the manifest. These includes every kab of typekos.app
, regardless of the section they are in. -
whenAppStarted
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 implementingAppListener
.
-