-
Notifications
You must be signed in to change notification settings - Fork 18
XMLConfigurationService
Rogiel edited this page Sep 16, 2011
·
1 revision
This Configuration Service implementation uses the an XML file as the backing storage engine. All configuration interfaces will use the same file with all the properties. See the syntax below:
public interface ExampleConfiguration extends Configuration {
@ConfigurationPropertyGetter(defaultValue = "default!")
@ConfigurationXPath("/configuration/example/key")
String getValue();
@ConfigurationPropertySetter
@ConfigurationXPath("/configuration/example/key")
void setValue(String value);
}
The following XML file is used:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="configuration configuration.xsd"
xsi:noNamespaceSchemaLocation="configuration">
<configuration>
<example>
<key>this is the example value!</key>
</example>
</configuration>
As stated in ConfigurationService each configuration interface requires implementation-specific annotations. This implementation defines a single mandatory annotation:
@ConfigurationXPath Defines the property (as an XPath).
If the XPath does not exists, it will use defaultValue.