Modeling Configuration in Interface Style
To model a managed object that has configuration, implement the supplemental interface com.tibco.tea.agent.api.WithConfig<CONFIG>. WithConfig is a generic interface. It requires that you implement one method, getConfig, which returns a configuration object.
See also Configuration Aspect.
Before you beginThe container object is defined in interface style.
- Procedure
- Define a configuration bean that encapsulates all the parameters of the managed object.
For example, the configuration of a radio could include changeable settings (such as the frequency and volume) and unchanging attributes (such as model and serial number).
public class RadioConfig { private long frequency; private int volume; private string model; private string serial; // Constructors. Get and set methods for each field. ... } - Implement the
WithConfig<CONFIG> interface in your managed object type. Substitute your configuration class as the generic type parameter
CONFIG.
public class Radio implements TopLevelTeaObject, WithConfig<RadioConfig> { ... public RadioConfig getConfig() { ... } } - Declare that the
getConfig method returns an instance of your configuration class.
public class Radio implements TopLevelTeaObject, WithConfig<RadioConfig> { ... public RadioConfig getConfig() { ... } }