FAQ

This is a compilation of common usage doubts, tips and workarounds.

What are the advantages of using Configuration Utils?

Configuration Utils provides the ability to read and save to a repository without the knowledge or overhead of managing the access to that repository. Configuration Utils can implement any type or persistent repository, so this aspect is unimportant to the programmer that uses the API.

Configuration Utils provides the ability to save any POJO to disk and read it. This apart for the normal properties file of key/value pairs. It parses any given JavaBean for all it's attributes and uses the getter and setter methods to read and save the data to/from the bean to the repository.

Configuration Utils can yet be extended by the use of a set of provided Annotations. These allow the use to annotate a POJO instructing the Configuration Utils on how to read/write it to the persistence layer. Information like default values, what attributes to save and not to, ID for the information saved, etc, can be annotated, thus overriding the conventioned default behavior.

More info on all of these features can be read in the User Guide Section.

Where are the configurations kept? How can I access them externally?

This depends on the specific implementation of Configuration Utils. The default one, the ConfigurationsPreferencesImpl, uses the Java Preferences API. This API is part of the Java SE.

The Preferences API saves it's data in different formats/locations depending on the operating system of the server it runs. In Unix/Linux it saves files to disk, while on Windows-based systems it uses the Windows Registry. This is though irrelevant, since we can have complete access to it through the Configuration Utilities, thus abstracting us of where it is saved.

for specific instructions on how to access the data, for instance for backup purposes, refer do the Java Preferences API documentation.

What are the advantages of the POJO approach to reading/writing configurations?

In reading and saving configuration data, there is normally a large chunk of boilerplate code. This code normally addresses issues like the following ones:

  • Accessing the persistent repository, including searching for the data we need
  • Converting text values to other types and back again
  • Assigning default values if none were read

All these are automatically managed by Configuration Utils. It provides bidirectional conversion for all object types, as long and two simple rules are followed (implementation of a String constructor and the .toClass method), default values, accessing the repository, etc. All this is accessed in a very simple way with very little code (one line of code for a read or write operation), and it can be extensively configured by the use of the provided annotations on your POJOs.