Beispiel #1
0
void Container::onRunLevelSetup()
{
	CliArguments &args = CliArguments::getInstance();
	
	// Load the library containing the plugin
	m_pluginFile = new SharedLib(m_servicePath);
	m_pluginFile->load();
	
	// Settings settup
#ifdef WIN32
	Settings settings("OpenIHS.org", "JSONBus::" + serviceNs + "." + serviceName, QSettings::NativeFormat);
#else
	QString confPath = args.getValue("config").toString();
	if (confPath.isEmpty()) {
		confPath = "/etc/jsonbus/services/" + m_serviceNs + "/" + m_serviceName + ".conf";
	}
	Settings settings(confPath, QSettings::NativeFormat);
#endif
	
	// Get the plugin instance
	m_plugin = (*(Plugin*(*)())(m_pluginFile->getSymbol("getSingleton")))();
	
	// Plugin initialization
	m_plugin->onInit(settings);
	if (args.isEnabled("edit-settings")) {
		settings.setup();
		throw ExitApplicationException();
	}
	
	SlaveApplication::onRunLevelSetup();
	
	// Plugin load
	m_plugin->onLoad(settings);
	connect(m_plugin, SIGNAL(resultAvailable(QVariant)), this, SLOT(onResultAvailable(QVariant)));
}
Beispiel #2
0
void Master::onStart() {
	CliArguments &args = CliArguments::getInstance();
#ifdef WIN32
	m_settings = new Settings("mbedsys.org", "NodeBus", QSettings::NativeFormat);
#else
	m_settings = new Settings(args.getValue("config").toString(), QSettings::NativeFormat);
#endif
	m_settings->define("master/pidfile",	tr("Path of the file where the service PID will be written in"),
					NODEBUS_DEFAULT_PIDFILE);
	m_settings->define("master/bundle-rootpath",	tr("Bundle root directory path"), 
					NODEBUS_DEFAULT_PLUGIN_DIR_PATH);
	m_settings->define("master/registry-service-name",	tr("Registry service name"), 
					NODEBUS_DEFAULT_REGISTRY_SERVICE_NAME);
	if (args.isEnabled("edit-settings")) {
		m_settings->setup();
		throw ExitApplicationException();
	}
	QString path = m_settings->value("master/bundle-rootpath").toString();
	QDirIterator it(path, QStringList("*.so"), QDir::Files, QDirIterator::Subdirectories);
	logFiner() << "Search for bundles in the directory " << path;
	while (it.hasNext()) {
		QString file = it.next();
		logFinest() << "Found file " << file;
		try {
			BundlePtr bundle = new Bundle(file);
			m_bundles[bundle->property("Bundle-SymbolicName").toString()] = bundle;
			logFine() << "Found bundle " << bundle->property("Bundle-Name") << " (" << bundle->property("Bundle-SymbolicName") << ')';
		} catch (Exception &e) {
			logWarn() << "Invalid bundle file " << file << " (" << e.message() << ')';
		}
	}
	if (m_bundles.isEmpty()) {
		throw ApplicationException("No valid bundle found in the directory " + path);
	}
}
Beispiel #3
0
void Master::onRunLevelSetup() {
	Application::onRunLevelSetup();
	
	CliArguments &args = CliArguments::getInstance();
#ifdef WIN32
	Settings settings("OpenIHS.org", "JSONBus", QSettings::NativeFormat);
#else
	Settings settings(args.getValue("config").toString(), QSettings::NativeFormat);
#endif
	settings.define("master/pidfile",	tr("Path of the file where the service PID will be written in"),
					JSONBUS_DEFAULT_PIDFILE);
	settings.define("master/plugindir",	tr("Plugin dir paths"), 
					JSONBUS_DEFAULT_PLUGIN_DIR_PATH);
	if (args.isEnabled("edit-settings")) {
		settings.setup();
		throw ExitApplicationException();
	}
}