The goal of OWNER API is to minimize the code required to handle application configuration through Java properties files.
The approach used by OWNER APIs, is to define a Java interface associated to a properties file.
Suppose your properties file is defined as ServerConfig.properties:port=80 hostname=foobar.com maxThreads=100To access this property you need to define a convenient Java interface in ServerConfig.java:
public interface ServerConfig extends Config { int port(); String hostname(); @DefaultValue("42"); int maxThreads(); }
We'll call this interface the Properties Mapping Interface or just Mapping Interface since its goal is to map Properties into a an easy to use piece of code.
Owner has a lot of features and its behavior is fully customizable to your needs.
Have a look at the full documentation from the OWNER website.
Interface | Description |
---|---|
Accessible |
Allows a
Config object to access the contents of the properties, providing utility methods to perform
consequent operations. |
Config |
Marker interface that must be implemented by all Config sub-interfaces.
|
Converter<T> |
Converter interface specifies how to convert an input string coming from a property value to a target object returned
by the Config method.
|
Factory |
Interface for factory implementation used to instantiate
Config instances. |
Mutable |
Allows a
Config object to change its property values at runtime. |
Preprocessor |
Preprocessor interface specifies how to pre-process an input string coming from a property value before being used by
OWNER.
|
Reloadable |
Allows a
Config object to implement the reloading of the properties at runtime. |
Tokenizer |
Tokenizer interface that specifies how to split a single value into tokens to be used as elements for arrays and
collections.
|
Class | Description |
---|---|
ConfigCache |
Utility class caching Config instances that can be used as Singletons.
|
ConfigFactory |
A static factory class to instantiate
Config instances. |
Enum | Description |
---|---|
Config.DisableableFeature |
This enum contains the features that can be disabled using the annotation
Config.DisableFeature . |
Config.HotReloadType |
Allows to specify which type of HotReload should be applied.
|
Config.LoadType |
Specifies the policy type to use to load the
Config.Sources files for properties. |
Annotation Type | Description |
---|---|
Config.ConverterClass |
Specifies a
class to allow the user to define a custom conversion logic for the
type returned by the method. |
Config.DecryptorClass |
When a value should be decrypted this annotation is needed.
|
Config.DefaultValue |
Default value to be used if no property is found.
|
Config.DisableFeature |
Specifies to disable some of the features supported by the API.
|
Config.EncryptedValue |
When a value should be decrypted this annotation is needed.
|
Config.HotReload |
Specify that the class implements hot reloading of properties from filesystem baked
Config.Sources (hot
reloading can't be applied to all types of URIs). |
Config.Key |
The key used for lookup for the property.
|
Config.LoadPolicy |
Specifies the policy for loading the properties files.
|
Config.PreprocessorClasses |
Specifies a
class to allow the user to define a custom logic to pre-process
the property value before being used by the library. |
Config.Separator |
Specifies simple
as separator to tokenize properties values specified as a
single string value, into elements for vectors and collections. |
Config.Sources |
Specifies the source from which to load the properties file.
|
Config.TokenizerClass |
Specifies a
class to allow the user to define a custom logic to split
the property value into tokens to be used as single elements for vectors and collections. |
Copyright © 2012–2020 Luigi R. Viggiano. All rights reserved.