Java Reference

Config Service

Introduction

API Components

This section describes the primary beans related to configuration.

ConfigBean (class)

The ConfigBean class is an optional base class for configuration beans. If used, the ConfigService sets its "configured" flag to true after all values are set.

This is useful for knowing when a bean has been configured. This class also implements the Ready interface, which means services that have config beans can mark the field @WhenReady, and then onReady() will be called after the bean is configured.

The following shows the ConfigBean definition:

API: ConfigBean class
public class ConfigBean implements Ready {

    // "Is configured" getter and setter:
    public boolean isConfigured();
    public void setConfigured(boolean configured);

    // Control of listeners:
    public void addListener(ConfigBeanListener listener);
    public void removeListener(ConfigBeanListener listener);

    // From the Ready interface:
    public boolean isReady();
    public void setReady();
}

The next code snippet shows how easy it is to create a config bean:

UserBean extends ConfigBean
@Data
public class UserBean extends ConfigBean {

    // Data fields:
    private int id;
    private String firstName;
    private String lastName;
}

ConfigBeanListener (interface)

The ConfigBeanListener interface is implemented by classes that want to be notified when their configuration bean is updated.

API: ConfigBeanListener interface
public interface ConfigBeanListener {
    void onConfigChanged(ConfigBean bean, BeanChanges changes);
}

Let’s look at an example bean that want to get notified with its configuration changes:

public class MyClass {

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