Package com.kosdev.kos.core.app
Class KosCore
java.lang.Object
com.kosdev.kos.core.app.KosCore
Static accessor for a number of core KOS components that are so common
it's inefficient to inject them everywhere they're needed.
Usage Example
Mode mode = KosCore.getMode();
BeanContext ctx = KosCore.getCtx();
- Since:
- 1
- Version:
- 9
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringformatISO8601(long ms) Format the epoch time in ms as an ISO-8601 string with fractional second resolution and timezone offset.static AnalyticsServiceReturn theAnalyticsServicein order to log analytic data.static intgetApiVersion(String appId) Return the api version for the specified app or extension.static StringgetArch()Returns the arch of this node.static ReadyIndicatorReturn aReadyIndicatorthat becomes ready when all the autostart apps have been started.static StringReturns the board type of this node.static intReturn the api version of KOS core.static BeanContextgetCtx()Returns the rootBeanContextfor KOS.static StringReturns the device type of the overall device the node is part of.static HardwareServiceReturn a reference toHardwareService.static ManifestServiceReturn a reference toManifestService.static StringReturns the manufacturer authority of this node.static FileReturn the manufacturer data directory.static FilegetMfgFile(String path) Return aFilefor the specified path in the manufacturer data directory.static ModegetMode()Returns the current operational mode.static NodeIdReturns the ID of the node we're running on.static intgetPort()Returns the port number that KOS is running on.static NodeIdReturns the nodeId of the primary node.static SystemApplication<?>Return the system application.static BeanContextReturns theBeanContextfor the system app.static StringReturns the vendor authority of this node.static StringReturn the currently running version of KOSstatic booleanReturn true if the specified grant expression is true.static booleanhasProfile(String profile) Returns true if the specified profile is active.static booleanReturns true if we're running on the system's primary node.static booleanisProd()Returns true if the current operational mode is PROD (production).static booleanReturns true if we're running inside the Studio simulator.static booleanisTest()Returns true if the current operational mode is TEST.static voidverifyGrant(String expr) Return if the specified grant expression is true, otherwise throwsGrantException.
-
Method Details
-
hasProfile
Returns true if the specified profile is active.- Parameters:
profile- the profile to check- Since:
- 1
-
getMode
Returns the current operational mode.- Since:
- 1
-
isTest
public static boolean isTest()Returns true if the current operational mode is TEST.- Since:
- 1
-
isProd
public static boolean isProd()Returns true if the current operational mode is PROD (production).- Since:
- 1
-
isSimulator
public static boolean isSimulator()Returns true if we're running inside the Studio simulator.- Since:
- 1
-
isPrimary
public static boolean isPrimary()Returns true if we're running on the system's primary node.- Since:
- 1
-
getPrimaryNodeId
Returns the nodeId of the primary node.- Since:
- 1
-
getDeviceType
Returns the device type of the overall device the node is part of.- Since:
- 1
-
getVendorAuthority
Returns the vendor authority of this node.- Since:
- 1
-
getMfgAuthority
Returns the manufacturer authority of this node.- Since:
- 1
-
getBoardType
Returns the board type of this node.- Since:
- 1
-
getArch
Returns the arch of this node.- Since:
- 1
-
getCtx
Returns the rootBeanContextfor KOS.- Since:
- 1
-
getSystemCtx
Returns theBeanContextfor the system app.- Since:
- 1
-
getSystemApp
Return the system application.- Since:
- 1
-
getAutostartsReady
Return aReadyIndicatorthat becomes ready when all the autostart apps have been started.- Since:
- 8
-
getManifestService
Return a reference toManifestService.- Since:
- 9
-
getHardwareService
Return a reference toHardwareService.- Since:
- 9
-
getPort
public static int getPort()Returns the port number that KOS is running on. It defaults to 8081.- Since:
- 1
-
getNodeId
Returns the ID of the node we're running on.- Since:
- 1
-
getMfgDir
Return the manufacturer data directory.- Since:
- 1
-
getMfgFile
Return aFilefor the specified path in the manufacturer data directory.- Since:
- 1
-
getAnalytics
Return theAnalyticsServicein order to log analytic data. This avoids the need to autowire the service everywhere.- Since:
- 6
-
hasGrant
Return true if the specified grant expression is true.- Parameters:
expr- the grant expression to check- Since:
- 9
-
verifyGrant
Return if the specified grant expression is true, otherwise throwsGrantException.- Parameters:
expr- the grant expression to verify- Since:
- 9
-
getVersion
Return the currently running version of KOS- Since:
- 1
-
formatISO8601
Format the epoch time in ms as an ISO-8601 string with fractional second resolution and timezone offset. This preserves the timezone information such that external systems have the benefit of localtime as well as the ability to normalize the time using the timezone offset.- Parameters:
ms- the time in ms- Since:
- 1
-
getApiVersion
Return the api version for the specified app or extension. Returns the corresponding api version or -1 if the app or extension is not installed. Also returns -1 if appId is null.- Parameters:
appId- the id of the application or name of the extension- Since:
- 9
-
getCoreApiVersion
public static int getCoreApiVersion()Return the api version of KOS core.- Since:
- 9
-