Qi4j
Introduction
Tutorials
Javadoc
Samples
Core
Libraries
Extensions
Tools
Glossary 

FileConfig

code

docs

tests

The FileConfig library provide a service for accessing application-specific directories.

A lot of the Qi4j Libraries and Extensions make use of this library to locate files.

Table 31. Artifact

Group IDArtifact IDVersion

org.qi4j.library

org.qi4j.library.fileconfig

2.0


Usage

public interface FileConfiguration
{
  [...snip...]

    File configurationDirectory();

    File dataDirectory();

    File temporaryDirectory();

    File cacheDirectory();

    File logDirectory();

}

To use it you simply need to declare the FileConfiguration Service in your application assembly:

module.services( FileConfigurationService.class );

These will default to the platform settings, but can be overridden manually, either one-by-one or as a whole.

You can override defaults by adding org.qi4j.library.fileconfig.FileConfiguration_OS.properties files to your classpath where OS is one of win, mac or unix.

You can also override all properties definitions at assembly time by setting a FileConfigurationOverride object as meta info of this service:

FileConfigurationOverride override = new FileConfigurationOverride().
        withConfiguration( confDir ).
        withData( dataDir ).
        withTemporary( tempDir ).
        withCache( cacheDir ).
        withLog( logDir );
module.services( FileConfigurationService.class ).setMetaInfo( override );

And finally, to get the FileConfiguration Service in your application code, simply use the following:

@Service FileConfiguration fileconfig;