Do the following to create a configuration interface:
-
Create an interface inherited from
com.haulmont.cuba.core.config.Config
(not to be confused with the entity classcom.haulmont.cuba.core.entity.Config
). -
Add
@Source
annotation to the interface in order to identify the source (storing method) for parameters:-
SourceType.SYSTEM
– the property value will be taken from the system properties of the given JVM, usingSystem.getProperty()
method. -
SourceType.APP
– the property value will be taken fromapp.properties
files. -
SourceType.DATABASE
– the property value will be taken from SYS_CONFIG table.
-
-
Create property access methods (getters / setters). If the property value is not expected to be changed at runtime, setter is not needed. Possible property types are described below.
-
Add
@Property
annotation defining the property name to getter. -
You can optionally set
@Source
annotation for a particular property of the interface if its source differs from the interface source.
Example:
@Source(type = SourceType.DATABASE) public interface SalesConfig extends Config { @Property("sales.companyName") String getCompanyName(); }
There is no need to create implementation class for the configuration interface as required proxy will be automatically created.