Example usage for org.apache.commons.configuration DatabaseConfiguration setProperty

List of usage examples for org.apache.commons.configuration DatabaseConfiguration setProperty

Introduction

In this page you can find the example usage for org.apache.commons.configuration DatabaseConfiguration setProperty.

Prototype

public void setProperty(String key, Object value) 

Source Link

Usage

From source file:com.germinus.easyconf.ConfigurationLoader.java

public void saveConfigurationObjectIntoDatabase(Object configurationObject, String companyId,
        String componentName, String confName, ComponentProperties properties) {
    log.info("Saving the configuration object into the database for " + componentName);
    String inexistentSource = null;
    String sourceName = properties.getString(Conventions.CONFIGURATION_OBJECTS_SOURCE_PROPERTY,
            inexistentSource);//from   w w w  .j  a  v  a 2s .  c om
    if (sourceName == inexistentSource) {
        throw new ConfigurationException("It is imposible to save the configuration object. "
                + "Please specify a valid datasource in property "
                + Conventions.CONFIGURATION_OBJECTS_SOURCE_PROPERTY);
    } else if (DatasourceURL.isDatasource(sourceName)) {
        DatasourceURL dsURL = new DatasourceURL(sourceName, companyId, componentName,
                DatasourceURL.CONFIGURATION_OBJECTS_TABLE);
        DatabaseConfiguration dbConf = dsURL.getConfiguration();
        String xml = serializer.serialize(configurationObject);
        dbConf.setProperty(confName, xml);
    } else {
        throw new ConfigurationException("The specified value for "
                + "easyconf:configuration-object-source is not valid: " + sourceName);
    }
}