Exemplo n.º 1
0
AbstractConfiguration* ConfigurationMapperTest::createConfiguration() const
{
	AbstractConfiguration* pConfig = new MapConfiguration;
	
	pConfig->setString("config.value1", "v1");
	pConfig->setString("config.value2", "v2");
	pConfig->setString("config.sub.value1", "v3");
	pConfig->setString("config.sub.value2", "v4");
	
	return pConfig;
}
Exemplo n.º 2
0
//============================================================================//
void Configuration::checkForSoftware(AbstractConfiguration &config)
{
    if(!config.has("path")) throw Exception(
        "<path> node doesn't exist");

    if(!File(config.getString("path")).exists()) throw Exception(
        "<path> node refers to not exist path or access denied to the folder");

    if(!config.has("uri"))  throw Exception(
        "<uri> node doesn't exist");

    if(!config.has("schedules")) throw Exception(
        "<schedules> doesn't exist");
}
Exemplo n.º 3
0
//============================================================================//
void Configuration::checkForApplication(AbstractConfiguration &config)
{
    if(!config.has("identifier")) throw Exception(
        "<identifier> node doesn't exist");

    if(!config.has("temporary"))  throw Exception(
        "<temporary> node doesn't exist");

    if(!File(config.getString("temporary")).exists()) throw Exception(
        "<temporary> node refers to not exist path or access denied to the folder");

    if(!config.has("updateSoftwares")) throw Exception(
        "<updateSoftwares> node doesn't exist");

}
Exemplo n.º 4
0
AbstractConfiguration* ConfigurationViewTest::createConfiguration() const
{
	AbstractConfiguration* pConfig = new MapConfiguration;
	
	pConfig->setString("prop1", "foo");
	pConfig->setString("prop2", "bar");
	pConfig->setString("prop3.string1", "foo");
	pConfig->setString("prop3.string2", "bar");
	pConfig->setString("prop4.prop41.string1", "FOO");
	pConfig->setString("prop4.prop41.string2", "BAR");
	pConfig->setString("prop4.prop42.string1", "Foo");
	pConfig->setString("prop4.prop42.string2", "Bar");
	
	return pConfig;
}
Exemplo n.º 5
0
void Client::copyProperties(const AbstractConfiguration& abstractConfigs,const string& root) {
	AbstractConfiguration::Keys keys;
	abstractConfigs.keys(root,keys);
	AbstractConfiguration::Keys::const_iterator it;
	for(it=keys.begin();it!=keys.end();++it) {
		string key(root);
		if(!key.empty())
			key+=".";
		key += (*it);
		if(abstractConfigs.hasOption(key))
			setString(key,abstractConfigs.getString(key));
		else
			copyProperties(abstractConfigs,key);
	}
}
Exemplo n.º 6
0
//============================================================================//
void Configuration::prepareApplicationLoggingDisableConsole(AbstractConfiguration &config)
{
    // find all files loggers
    AbstractConfiguration::Keys             channelsKeys;
    AbstractConfiguration::Keys::iterator   keyIt;

    config.keys("logging.channels", channelsKeys);

    for(keyIt = channelsKeys.begin(); keyIt != channelsKeys.end(); ++keyIt) {
        if(!config.getString("logging.channels." + *keyIt + ".class", "").
            compare("ConsoleChannel")) {

            config.setString("logging.channels." + *keyIt + ".class",
                "NullChannel");
        }
    }
}
Exemplo n.º 7
0
//============================================================================//
void AnalyzerDispatcher::create(AbstractConfiguration &config)
{
    AbstractConfiguration::Keys             analyzersCodes;
    AbstractConfiguration::Keys::iterator   iter;

    config.keys("analyzers.list", analyzersCodes);

    for(iter = analyzersCodes.begin(); iter != analyzersCodes.end(); ++iter) {

        string type = config.getString("analyzers.list."+(*iter)+".type");

        if(config.has("analyzers.list."+(*iter)+".disabled")) {
            poco_information_f2(Logger::get(_loggerName),
                "analyzer type of [%s] with code [%s] disabled",
                type, string(*iter));
            continue;
        }

        if(_fabrics->isClass(type)) {

            poco_information_f1(Logger::get(_loggerName), "create analyzer for type [%s]", type);

            Analyzer::Arguments  args(*iter, config);
            Analyzer *a = _fabrics->create(type, args);

            poco_information_f2(Logger::get(_loggerName),
                "starting analyzer type of [%s] with code [%s]",
                type, string(a->getCode()));

            try {
                a->start();
                _analyzers.insert(pair<string, SharedPtr<Analyzer> >(*iter, a));
            }
            catch(exception &e) {
                delete a;
            }
        }
        else {
            poco_warning_f1(Logger::get(_loggerName), "unknown analyzer type [%s]... skip this.", type);
        }
    }

    poco_information_f1(Logger::get(_loggerName), "[%d] analyzers was registered", (int)_analyzers.size());
}
Exemplo n.º 8
0
//============================================================================//
void Configuration::prepareApplicationLoggingFiles(AbstractConfiguration &config, const string &prefix)
{

    // find all files loggers
    AbstractConfiguration::Keys             channelsKeys;
    AbstractConfiguration::Keys::iterator   keyIt;

    config.keys("logging.channels", channelsKeys);

    config.setString("application.logger", prefix);


    for(keyIt = channelsKeys.begin(); keyIt != channelsKeys.end(); ++keyIt) {
        if(!config.getString("logging.channels." + *keyIt + ".class", "").
            compare("FileChannel")) {

            config.setString("logging.channels." + *keyIt + ".path",
                Path(config.getString("logging.channels." + *keyIt + ".path", "") +
                    Path::separator()).makeAbsolute().
                    setFileName(
                        "UpSys" + prefix + 
                        config.getString("args.software_identifier")
                        + ".log").toString());
        }
    }

}