From 32a83c9dc929d05e1b3c01a2527ae63dc115c5c5 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Mon, 28 Sep 2015 01:57:15 +0100 Subject: Use AdHoc plugins for ICE daemon modules --- project2/ice/iceDaemon.cpp | 6 +++--- project2/ice/iceModule.cpp | 4 ++-- project2/ice/iceModule.h | 3 ++- project2/ice/slice2Daemon.cpp | 2 +- project2/ice/unittests/testDaemon.cpp | 6 +++--- project2/ice/unittests/testDaemonCompile.cpp | 4 ++-- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/project2/ice/iceDaemon.cpp b/project2/ice/iceDaemon.cpp index 15ae1b0..0f56a33 100644 --- a/project2/ice/iceDaemon.cpp +++ b/project2/ice/iceDaemon.cpp @@ -72,9 +72,9 @@ IceDaemon::setup() const Ice::ObjectAdapterPtr adapter = ic->createObjectAdapterWithEndpoints(adapterName, adapterEndpoint); Logger()->messagebf(LOG_DEBUG, " %s installing servants...", __PRETTY_FUNCTION__); - InstanceSet::OnAll([this, adapter](IceDaemonAdapterHandlerLoader * loader) { - loader->create(this)->add(adapter, ic); - }); + for(auto p : AdHoc::PluginManager::getDefault()->getAll()) { + p->implementation()->create(this)->add(adapter, ic); + } Logger()->messagebf(LOG_DEBUG, " %s starting...", __PRETTY_FUNCTION__); adapter->activate(); diff --git a/project2/ice/iceModule.cpp b/project2/ice/iceModule.cpp index 7e39858..309e9a5 100644 --- a/project2/ice/iceModule.cpp +++ b/project2/ice/iceModule.cpp @@ -1,7 +1,7 @@ #include #include "iceModule.h" #include "iceDaemon.h" -#include "instanceStore.impl.h" +#include IceDaemonModule::IceDaemonModule(const std::string & n, const IceDaemon * id) : name(n), @@ -31,5 +31,5 @@ IceDaemonModule::remove(Ice::ObjectAdapterPtr adapter, Ice::CommunicatorPtr ic) adapter->remove(ic->stringToIdentity(name)); } -INSTANTIATESTORE(std::string, IceDaemonAdapterHandlerLoader); +INSTANTIATEFACTORY(IceDaemonModule, const IceDaemon *); diff --git a/project2/ice/iceModule.h b/project2/ice/iceModule.h index fcdd3e4..49aa63b 100644 --- a/project2/ice/iceModule.h +++ b/project2/ice/iceModule.h @@ -9,6 +9,7 @@ #include #include #include "iceConvert.h" +#include typedef std::map ParamMap; class IceDaemon; @@ -29,7 +30,7 @@ class IceDaemonModule : virtual public ::Ice::Object { const IceDaemon * const iceDaemon; }; -typedef GenLoader IceDaemonAdapterHandlerLoader; +typedef AdHoc::Factory IceDaemonAdapterHandlerFactory; #endif diff --git a/project2/ice/slice2Daemon.cpp b/project2/ice/slice2Daemon.cpp index 177e406..41e71f1 100644 --- a/project2/ice/slice2Daemon.cpp +++ b/project2/ice/slice2Daemon.cpp @@ -65,7 +65,7 @@ Slice2Daemon::visitClassDefEnd(const Slice::ClassDefPtr & c) { if (code) { fprintf(code, "\t}; // class %sImpl\n\n", c->name().c_str()); - fprintf(code, "\tDECLARE_GENERIC_LOADER(\"%s-%s\", IceDaemonAdapterHandlerLoader, %sImpl);\n\n", + fprintf(code, "\tNAMEDFACTORY(\"%s-%s\", %sImpl, IceDaemonAdapterHandlerFactory);\n\n", module.c_str(), c->name().c_str(), c->name().c_str()); } components += 1; diff --git a/project2/ice/unittests/testDaemon.cpp b/project2/ice/unittests/testDaemon.cpp index f12935d..a1985a4 100644 --- a/project2/ice/unittests/testDaemon.cpp +++ b/project2/ice/unittests/testDaemon.cpp @@ -96,8 +96,8 @@ void commonTests() { BOOST_TEST_CHECKPOINT("Verify loaded"); - BOOST_REQUIRE(IceDaemonAdapterHandlerLoader::getFor("UnitTest-SimpleInterface")); - BOOST_REQUIRE(IceDaemonAdapterHandlerLoader::getFor("UnitTestComplex-ComplexInterface")); + BOOST_REQUIRE(IceDaemonAdapterHandlerFactory::get("UnitTest-SimpleInterface")); + BOOST_REQUIRE(IceDaemonAdapterHandlerFactory::get("UnitTestComplex-ComplexInterface")); int dummy = 0; BOOST_TEST_CHECKPOINT("Run daemon"); @@ -195,7 +195,7 @@ void unloadTests() { BOOST_TEST_CHECKPOINT("Verify unloaded"); - BOOST_REQUIRE_THROW(IceDaemonAdapterHandlerLoader::createNew("UnitTest-SimpleInterface", NULL), NotSupported); + BOOST_REQUIRE_THROW(IceDaemonAdapterHandlerFactory::createNew("UnitTest-SimpleInterface", NULL), AdHoc::NoSuchPluginException); } BOOST_FIXTURE_TEST_SUITE( Core, TestAppInstance ); diff --git a/project2/ice/unittests/testDaemonCompile.cpp b/project2/ice/unittests/testDaemonCompile.cpp index 95fb6f2..c3f7064 100644 --- a/project2/ice/unittests/testDaemonCompile.cpp +++ b/project2/ice/unittests/testDaemonCompile.cpp @@ -18,7 +18,7 @@ void commonTests() { BOOST_TEST_CHECKPOINT("Verify loaded"); - BOOST_REQUIRE(IceDaemonAdapterHandlerLoader::getFor("UnitTest-SimpleInterface")); + BOOST_REQUIRE(IceDaemonAdapterHandlerFactory::get("UnitTest-SimpleInterface")); } static @@ -26,7 +26,7 @@ void unloadTests() { BOOST_TEST_CHECKPOINT("Verify unloaded"); - BOOST_REQUIRE_THROW(IceDaemonAdapterHandlerLoader::createNew("UnitTest-SimpleInterface", NULL), NotSupported); + BOOST_REQUIRE_THROW(IceDaemonAdapterHandlerFactory::createNew("UnitTest-SimpleInterface", NULL), AdHoc::NoSuchPluginException); } BOOST_FIXTURE_TEST_SUITE( Core, TestAppInstance ); -- cgit v1.2.3