Java Reference

Intro to Java Ref

Introduction

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.

Javadocs

The KOS SDKs are delivered in three different components:

Core

SDK for core and common functionality (these pages)
Javadocs

Dispense

SDK for Legacy+ dispensers (here)
Javadocs

Freestyle

SDK for Freestyle-type microdosing dispensers (here)
Javadocs

POM file usage

To use one or more of the SDKs, make the following modifications to your project’s POM file.

Properties

Add a KOS version property:

<properties>
<properties>
    <kos.version>1.2.3</kos.version> <!-- Enter the KOS version you’re using! -->
</properties>

Dependency management

Add the kos-bom artifact to the dependency management section:

<dependencyManagement>
<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>

Dependencies

Add the desired SDK dependencies:

<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>

Repositories

Add the following repositories so that the SDK can be accessed:

<repositories>
<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>

Types of Components

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.

General Classes

Classes that are either used as-is or as parents of new classes.

Base Classes

Abstract or base classes used to derive new user-defined classes.

Interfaces

Intefaces that are implemented in end-user code.

Services

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.

Utility Classes

General-purpose classes, typically with all static variables/methods.

Annotations

Annotations that inform the KOS system how to piece together the code.

SDK Pieces

The KOS SDK components come in different types:

  • Classes

  • Interfaces

  • Enums

  • Annotations

These are discussed in the remaining sections.

Classes

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

Global static classes

A global static class is an object that’s available anywhere in your code. There are two in the KOS system:

Table 1. System services
Global class Purpose

KosCore

Provides access to common KOS components

KosUtil

Similar to KosCore, except that its components have interfaces and default implementations

Services

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:

Table 2. System services
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:

Table 3. Other services
Other class Purpose

BeanContext

Provides a lightweight IOC-style context

JsonTemplate

Provides an easy way to issue HTTP/REST calls

Data classes

These classes primarily just hold data, and have little or no other functionality.

Table 4. Data classes

InboundMessage

OutboundMessage

UriParam

Abstract base classes

These are abstract classes you derive new classes from:

Table 5. Abstract base classes

AbstractConfigurable

AbstractConfigurableService

AbstractService

AbstractVFSSource

Application

Assembly

BinaryMsgIface

BlinkSession

Board

BoardIfaceLink

CoreAssembly

ReadyBean

RegionSource

RoutedMessage

SystemApplication

Unit

UnitSystem

Configuration classes

Configuration classes can be used as-is or new types can be derived from them.

Table 6. Abstract base classes

BaseAppConfig

RegionSourceConfig

Specialty classes

Some KOS specialty classes are:

Table 7. Specialty classes

AutowiredList

FutureWork (AN)

ListenerList (AN)

MultiValueMap

Utility classes

Some SDK pieces are simply utility classes.

Table 8. Utility classes

Convert

HttpStatus

KosCore (AN)

KosUtil

Str

UriBuilder (AN)

XmlUtil

Misc classes

These include all miscellaneous classes, such as exceptions. Exceptions are not listed here, as they are self-defining.

Interfaces

Another software piece that’s available are interfaces.

Utility interfaces

Utility interfaces include:

  • AttributeAware

Base Interfaces

Base interfaces include:

  • DatabaseMigrator

Enums

This section describes the KOS enumerations.

Table 9. Annotations

FutureEvent

FutureState

Mode

RequestMethod

Annotations

This section describes the KOS annotations.

Table 10. Annotations
Annotation Related to

@Autowired

the BeanContext component

@WhenReady

@ConfigDesc

the ConfigBean component

@ConfigIgnore

@ApiController

HTTP (RESTful) methods

@ApiEndpoint

@HandleVariable

@PathVariable

@RequestBody

@RequestParam

@Tracker

Summary

Previous
Next
On this page
Java Development
Seamlessly transition from Legacy+ systems to Freestyle microdosing and advanced distributed dispense systems.
UI Development
Using KOS SDKs, integrating Consumer and Non-consumer facing UIs becomes seamless, giving you less hassle and more time to create.
Video Library
Meet some of our development team, as they lead you through the tools, features, and tips and tricks of various KOS tools.
Resources
Familiarize yourself with KOS terminology, our reference materials, and explore additional resources that complement your KOS journey.
Copyright © 2024 TCCC. All rights reserved.