pt.digitalis.utils.config
Class BaseConfigurationsImpl

java.lang.Object
  extended by pt.digitalis.utils.config.BaseConfigurationsImpl
All Implemented Interfaces:
IConfigurations
Direct Known Subclasses:
ConfigurationsPreferencesImpl

public abstract class BaseConfigurationsImpl
extends Object
implements IConfigurations

A facilitator base implementation for IConfigurations. It implements the recurrent needs of these implementations allowing the descending classes to focus only on what is specific to each implementation.

Author:
Pedro Viegas pviegas@digitalis.pt

Constructor Summary
BaseConfigurationsImpl()
           
 
Method Summary
<T> T
readConfiguration(Class<T> clazz)
          Reads configurations from the persistence layer.
abstract  Properties readConfiguration(String configID, String sectionID)
          Reads configurations from the persistence layer
<T> T
readConfiguration(String configID, String sectionID, Class<T> clazz)
          Reads configurations from the persistence layer.
 boolean removeConfiguration(Object bean)
          Removes configurations from the persistence layer.
 boolean writeConfiguration(Object annotatedPojo)
          Writes configurations to the persistence layer.
 boolean writeConfiguration(String configID, String sectionID, Object bean)
          Writes configurations to the persistence layer.
abstract  boolean writeConfiguration(String configID, String sectionID, Properties values)
          Writes configurations to the persistence layer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface pt.digitalis.utils.config.IConfigurations
removeConfiguration
 

Constructor Detail

BaseConfigurationsImpl

public BaseConfigurationsImpl()
Method Detail

writeConfiguration

public abstract boolean writeConfiguration(String configID,
                                           String sectionID,
                                           Properties values)
Description copied from interface: IConfigurations
Writes configurations to the persistence layer

Specified by:
writeConfiguration in interface IConfigurations
Parameters:
configID - the identifier of the configuration group
sectionID - the identifier of the section within the group
values - a Properties object with the key value pairs
Returns:
T if the operation was successful
See Also:
IConfigurations.writeConfiguration(java.lang.String, java.lang.String, java.util.Properties)

readConfiguration

public abstract Properties readConfiguration(String configID,
                                             String sectionID)
Description copied from interface: IConfigurations
Reads configurations from the persistence layer

Specified by:
readConfiguration in interface IConfigurations
Parameters:
configID - the identifier of the configuration group
sectionID - the identifier of the section within the group
Returns:
a Properties object with the key value pairs
See Also:
IConfigurations.readConfiguration(java.lang.String, java.lang.String)

readConfiguration

public <T> T readConfiguration(String configID,
                               String sectionID,
                               Class<T> clazz)
Description copied from interface: IConfigurations
Reads configurations from the persistence layer. It will scan the given class for annotations that instruct how to read the values. The annotations are the ones present in "pt.digitalis.utils.config.annotations" If not available a simple conversion of attributes to key name will be used, as in: "method: getFullName -> key FullName"

Specified by:
readConfiguration in interface IConfigurations
Type Parameters:
T - the Type to create
Parameters:
configID - the identifier of the configuration group
sectionID - the identifier of the section within the group
clazz - the class that defines the object that represents the properties to read
Returns:
an instance of class with the read values
See Also:
IConfigurations.readConfiguration(java.lang.String, java.lang.String, java.lang.Class)

readConfiguration

public <T> T readConfiguration(Class<T> clazz)
Description copied from interface: IConfigurations
Reads configurations from the persistence layer. It will scan the given class for annotations that instruct how to read the values. The annotations are the ones present in "pt.digitalis.dif.config.annotations" If not available a simple conversion of attributes to key name will be used, as in: "method: getFullName -> key FullName" Note: The ConfigID and ConfigSectionID annotations are mandatory for this method to succeed

Specified by:
readConfiguration in interface IConfigurations
Type Parameters:
T - the Type to create
Parameters:
clazz - the class that defines the object that represents the properties to read
Returns:
an instance of class with the read values
See Also:
IConfigurations.readConfiguration(java.lang.Class)

writeConfiguration

public boolean writeConfiguration(String configID,
                                  String sectionID,
                                  Object bean)
Description copied from interface: IConfigurations
Writes configurations to the persistence layer. A simple conversion of attributes to key name will be used, as in: "method: getFullName -> key FullName"

Specified by:
writeConfiguration in interface IConfigurations
Parameters:
configID - the identifier of the configuration group
sectionID - the identifier of the section within the group
bean - the object (JavaBean) that will be read and saved
Returns:
T if the operation was successful
See Also:
IConfigurations.writeConfiguration(java.lang.String, java.lang.String, java.lang.Object)

writeConfiguration

public boolean writeConfiguration(Object annotatedPojo)
                           throws Exception
Description copied from interface: IConfigurations
Writes configurations to the persistence layer. It will scan the given class for annotations that instruct how to read the values. The annotations are the ones present in "pt.digitalis.dif.config.annotations" If not available a simple conversion of attributes to key name will be used, as in: "method: getFullName -> key FullName"

Specified by:
writeConfiguration in interface IConfigurations
Parameters:
annotatedPojo - the annotated class object with the values to be saved
Returns:
T if the operation was successful
Throws:
Exception - if the bean class is not found
See Also:
IConfigurations.writeConfiguration(java.lang.Object)

removeConfiguration

public boolean removeConfiguration(Object bean)
                            throws Exception
Description copied from interface: IConfigurations
Removes configurations from the persistence layer. It will scan the given class for annotations that instruct what configurations it should remove. The annotations are the ones present in "pt.digitalis.dif.config.annotations" Note: The ConfigID and ConfigSectionID annotations are mandatory for this method to succeed

Specified by:
removeConfiguration in interface IConfigurations
Parameters:
bean - the object (JavaBean) that will be read and saved
Returns:
T if successful
Throws:
Exception - if the return object cannot be created
See Also:
IConfigurations.removeConfiguration(java.lang.Object)


Copyright © 2009 Digitalis Informática Lda. All Rights Reserved.