summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--project2/ice/Jamfile.jam2
-rw-r--r--project2/ice/iceboxDaemon.cpp5
-rw-r--r--project2/ice/iceboxOptionsSource.cpp25
-rw-r--r--project2/ice/iceboxOptionsSource.h20
-rw-r--r--project2/ice/unittests/testIceBoxDaemon.cpp11
5 files changed, 54 insertions, 9 deletions
diff --git a/project2/ice/Jamfile.jam b/project2/ice/Jamfile.jam
index fc2b970..76ec226 100644
--- a/project2/ice/Jamfile.jam
+++ b/project2/ice/Jamfile.jam
@@ -62,7 +62,7 @@ lib p2icedaemon :
;
lib p2icebox :
- pch iceboxDaemon.cpp
+ pch [ glob icebox*.cpp ]
:
<include>../../libmisc
<library>glibmm
diff --git a/project2/ice/iceboxDaemon.cpp b/project2/ice/iceboxDaemon.cpp
index ad7849a..fa1afd8 100644
--- a/project2/ice/iceboxDaemon.cpp
+++ b/project2/ice/iceboxDaemon.cpp
@@ -6,6 +6,7 @@
#include <daemon.h>
#include <thread>
#include <appInstance.h>
+#include "iceboxOptionsSource.h"
class IceBoxDaemon : public IceBox::Service, public AppInstance {
public:
@@ -21,6 +22,7 @@ class IceBoxDaemon : public IceBox::Service, public AppInstance {
void start(const std::string &, const Ice::CommunicatorPtr & ic, const Ice::StringSeq &)
{
+ OptionsSources::Add("service", new IceBoxOptionsSource(ic));
OptionsSource::loadSources([this] { return reqPlatform;} );
int argc = 0;
char ** argv = nullptr;
@@ -64,8 +66,9 @@ END_OPTIONS(IceBoxDaemon);
extern "C" {
IceBox::Service *
- createProject2Daemon(Ice::CommunicatorPtr)
+ createProject2Daemon(Ice::CommunicatorPtr ic)
{
+ OptionsSources::Add("admin", new IceBoxOptionsSource(ic));
return new IceBoxDaemon();
}
}
diff --git a/project2/ice/iceboxOptionsSource.cpp b/project2/ice/iceboxOptionsSource.cpp
new file mode 100644
index 0000000..90eca8e
--- /dev/null
+++ b/project2/ice/iceboxOptionsSource.cpp
@@ -0,0 +1,25 @@
+#include "iceboxOptionsSource.h"
+
+IceBoxOptionsSource::IceBoxOptionsSource(Ice::CommunicatorPtr i) :
+ ic(i),
+ startTime(boost::posix_time::microsec_clock::universal_time())
+{
+}
+
+boost::posix_time::ptime
+IceBoxOptionsSource::modifiedTime() const
+{
+ return startTime;
+}
+
+void
+IceBoxOptionsSource::loadInto(const ConfigConsumer & consume, const Options::CurrentPlatform & currentPlatform) const
+{
+ if (!ic) return;
+ auto props = ic->getProperties();
+ if (!props) return;
+ for (auto & prop : props->getPropertiesForPrefix("project2")) {
+ consume(prop.first.substr(9), "", prop.second, currentPlatform);
+ }
+}
+
diff --git a/project2/ice/iceboxOptionsSource.h b/project2/ice/iceboxOptionsSource.h
new file mode 100644
index 0000000..3127fa4
--- /dev/null
+++ b/project2/ice/iceboxOptionsSource.h
@@ -0,0 +1,20 @@
+#ifndef PROJECT2_ICEBOX_OPTIONSSOURCE_H
+#define PROJECT2_ICEBOX_OPTIONSSOURCE_H
+
+#include <optionsSource.h>
+#include <Ice/Communicator.h>
+
+class IceBoxOptionsSource : public OptionsSource {
+ public:
+ IceBoxOptionsSource(Ice::CommunicatorPtr);
+
+ void loadInto(const ConfigConsumer &, const Options::CurrentPlatform & platform) const;
+ boost::posix_time::ptime modifiedTime() const;
+
+ private:
+ Ice::CommunicatorPtr ic;
+ boost::posix_time::ptime startTime;
+};
+
+#endif
+
diff --git a/project2/ice/unittests/testIceBoxDaemon.cpp b/project2/ice/unittests/testIceBoxDaemon.cpp
index b6a2dd5..a2ba774 100644
--- a/project2/ice/unittests/testIceBoxDaemon.cpp
+++ b/project2/ice/unittests/testIceBoxDaemon.cpp
@@ -11,15 +11,14 @@ extern "C" {
BOOST_AUTO_TEST_CASE( test_icebox_daemon )
{
- Ice::StringSeq adminOpts;
- Ice::CommunicatorPtr adminComm = Ice::initialize(adminOpts);
+ Ice::CommunicatorPtr adminComm = Ice::initialize();
BOOST_REQUIRE(adminComm);
+ adminComm->getProperties()->setProperty("project2.daemon.type", "TestDaemon");
IceBox::Service * service = createProject2Daemon(adminComm);
BOOST_REQUIRE(service);
- Ice::StringSeq serviceOpts;
- Ice::CommunicatorPtr serviceComm = Ice::initialize(serviceOpts);
+ Ice::CommunicatorPtr serviceComm = Ice::initialize();
BOOST_REQUIRE(serviceComm);
service->start("test_icebox_daemon", serviceComm, { });
@@ -52,7 +51,5 @@ class TestDaemon : public Daemon {
private:
mutable bool stop;
};
-// DECLARE_COMPONENT_LOADER("TestDaemon", TestDaemon, DaemonLoader);
-// This doesn't have a name yet because there's no current way to inject settings for daemon.type
-DECLARE_COMPONENT_LOADER("", TestDaemon, DaemonLoader);
+DECLARE_COMPONENT_LOADER("TestDaemon", TestDaemon, DaemonLoader);