<properties>
<kos.version>1.2.3</kos.version> <!-- Enter the KOS version you’re using! -->
</properties>
Welcome to the Java reference pages of the KOS operating system SDK. This is a comprehensive resource that provides valuable information for developing your own KOS applications.
Each of these subsections, and each page within those sections, explains a basic software component of the KOS system. They do so without requiring extensive knowledge of the rest of the system. This means you can jump around to those topics that are most relevant to your interests.
To use one or more of the SDKs, make the following modifications to your project’s POM file.
Add a KOS version property:
<properties>
<kos.version>1.2.3</kos.version> <!-- Enter the KOS version you’re using! -->
</properties>
Add the kos-bom artifact to the dependency management section:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.kosdev.kos.sdk.bom</groupId>
<artifactId>kos-bom</artifactId>
<version>${kos.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Add the desired SDK dependencies:
<dependencies>
<dependency>
<groupId>com.kosdev.kos.sdk.api</groupId>
<artifactId>api-core</artifactId> <!-- Required -->
</dependency>
<dependency>
<groupId>com.kosdev.kos.sdk.api</groupId>
<artifactId>api-dispense</artifactId> <!-- Optional -->
</dependency>
<dependency>
<groupId>com.kosdev.kos.sdk.api</groupId>
<artifactId>api-freestyle</artifactId> <!-- Optional -->
</dependency>
</dependencies>
Add the following repositories so that the SDK can be accessed:
<repositories>
<repository>
<id>kosdevcode</id>
<name>KOS Code Repository</name>
<url>https://maven.pkg.github.com/kosdev-code/kos-maven</url>
<releases>
<enabled>true</enabled>
<updatePolicy>daily</updatePolicy>
<checksumPolicy>fail</checksumPolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>fail</checksumPolicy>
</snapshots>
</repository>
</repositories>
Components in this article are grouped based on their type, which corresponds to how they are used. In the succeeding articles and application notes, the components are grouped by functionality.
Classes that are either used as-is or as parents of new classes.
Abstract or base classes used to derive new user-defined classes.
Intefaces that are implemented in end-user code.
Objects that are created by the KOS system and made available to end-user programs using either the @Autowired annotation or the KosUtil convenience class.
General-purpose classes, typically with all static variables/methods.
Annotations that inform the KOS system how to piece together the code.
The KOS SDK components come in different types:
Classes
Interfaces
Enums
Annotations
These are discussed in the remaining sections.
This section gives an overview of classes in the SDK. They are categorized into the following:
Global Static Classes
Services
Data Beans
Abstract Base Classes
Specialty
Utility
A global static class is an object that’s available anywhere in your code. There are two in the KOS system:
Global class | Purpose |
---|---|
KosCore |
Provides access to common KOS components |
KosUtil |
Similar to KosCore, except that its components have interfaces and default implementations |
A KOS service is a software object that provides foundational functionality that you can choose to use or not. You can inject them into your classes using the @Autowired annotation or access them through the KosUtil convenience class. Once injected, you are free to make calls on the component to carry out various operations. You cannot instantiate these objects directly nor derive new classes from them.
KOS Service
A KOS service is a software object that exists throughout the lifetime of your application. It is built into the KOS system, and provides essential capabilities such as bean context, HTTP/REST requests and responses, message broker, router, etc. |
These KOS services extend the AbstractService class:
Service class | Purpose |
---|---|
ApiClient |
Used to interact with applications running on nodes within a KOS cluster |
AppService |
Manages KOS applications |
AssemblyService |
Manages KOS assemblies |
BrowserService |
Manages connections to the Chrome browser |
ConfigService |
Manages all configuration data in the system |
FirmwareService |
Handles firmware updates on devices |
FuseService |
Mounts KAB files into the local filesystem via fuseMounter native program |
HandleService |
Implementation of the handle system |
HardwareService |
Manages all external hardware |
MessageBroker |
Provides the ability to publish (send) and subscribe to (receive) messages over the KOS network |
NodeMgrService |
Used for interacting with nodeMgr clients within the cluster |
RegionService |
Provides access to region and localization information |
SerialService |
Manages serial devices |
SpawnService |
Used to start and stop native programs on this or other nodes using a spawn session |
StateService |
File finder that backs all of the file managers |
StorageService |
Key/value storage service that supports encryption of selected key values |
TroubleService |
Manages troubles, which indicate a problem, state, or action required |
UdevService |
Manages events from the udev (USB) adapter |
These services are instantiated with @Autowired, however they do not extend the AbstractService class:
Other class | Purpose |
---|---|
BeanContext |
Provides a lightweight IOC-style context |
JsonTemplate |
Provides an easy way to issue HTTP/REST calls |
These classes primarily just hold data, and have little or no other functionality.
InboundMessage |
OutboundMessage |
UriParam |
These are abstract classes you derive new classes from:
AbstractConfigurable |
AbstractConfigurableService |
AbstractService |
AbstractVFSSource |
Application |
Assembly |
BinaryMsgIface |
BlinkSession |
Board |
BoardIfaceLink |
CoreAssembly |
ReadyBean |
RegionSource |
RoutedMessage |
SystemApplication |
Unit |
UnitSystem |
Configuration classes can be used as-is or new types can be derived from them.
BaseAppConfig |
RegionSourceConfig |
Some KOS specialty classes are:
AutowiredList |
FutureWork (AN) |
ListenerList (AN) |
MultiValueMap |
This section describes the KOS enumerations.
FutureEvent |
FutureState |
Mode |
RequestMethod |
This section describes the KOS annotations.
Annotation | Related to |
---|---|
@Autowired |
the BeanContext component |
@WhenReady |
|
@ConfigDesc |
the ConfigBean component |
@ConfigIgnore |
|
@ApiController |
HTTP (RESTful) methods |
@ApiEndpoint |
|
@HandleVariable |
|
@PathVariable |
|
@RequestBody |
|
@RequestParam |
|
@Tracker |