org.universAAL.middleware.container.utils
Class ModuleConfigHome

Package class diagram package ModuleConfigHome
java.lang.Object
  extended by org.universAAL.middleware.container.utils.ModuleConfigHome
Direct Known Subclasses:
BundleConfigHome

public class ModuleConfigHome
extends Object

The base class for configuration files in universAAL. All configuration files are contained in the root directory of the universAAL runtime (rundir). The configuration files of a bundle are contained in a subdirectory with the name of that module (Best Practice). Configuration files that follow the key-value format should use ModuleContext.registerConfigFile(Object[]) and the container-specific mechanisms to get notified when the configuration changes.

Author:
Carsten Stockloew

Field Summary
protected  File confHome
          The File containing the path for the configuration file (the home directory of the configuration file).
 
Constructor Summary
protected ModuleConfigHome()
          Default constructor to allow overwriting the default implementation.
  ModuleConfigHome(String confHome, String id)
          Constructor the create a new object for accessing configuration files.
 
Method Summary
 String getAbsolutePath()
          Returns the absolute pathname string of this abstract pathname.
 OutputStream getConfFileAsOutputStream(String filename)
          Get an OutputStream for the file of the given file name in the home directory of the configuration file.
 InputStream getConfFileAsStream(String filename)
          Get an InputStream for the file of the given file name in the home directory of the configuration file.
 File[] listFiles()
          List all files in the home directory of the configuration file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

confHome

protected File confHome
The File containing the path for the configuration file (the home directory of the configuration file).

Constructor Detail

ModuleConfigHome

protected ModuleConfigHome()
Default constructor to allow overwriting the default implementation.


ModuleConfigHome

public ModuleConfigHome(String confHome,
                        String id)
Constructor the create a new object for accessing configuration files. The actual file name consists of the root directory of the universAAL runtime, the given ID (which is by Best Practice the module name), and a file name which is given to the method getConfFileAsStream(String). The directory is created if it does not exist.

Parameters:
confHome - The home directory.
id - The ID of this module.
Method Detail

getAbsolutePath

public String getAbsolutePath()
Returns the absolute pathname string of this abstract pathname.

Returns:
the absolute pathname string
See Also:
File.getAbsolutePath()

getConfFileAsStream

public InputStream getConfFileAsStream(String filename)
                                throws IOException
Get an InputStream for the file of the given file name in the home directory of the configuration file. The file is created if it does not exist.

Parameters:
filename - The name of the file.
Returns:
An InputStream for the file.
Throws:
IOException

getConfFileAsOutputStream

public OutputStream getConfFileAsOutputStream(String filename)
                                       throws IOException
Get an OutputStream for the file of the given file name in the home directory of the configuration file. The file is created if it does not exist.

Parameters:
filename - The name of the file.
Returns:
An OutputStream for the file.
Throws:
IOException

listFiles

public File[] listFiles()
List all files in the home directory of the configuration file.

Returns:
The list of files.


Copyright © 2014 universAAL Consortium. All Rights Reserved.