diff options
Diffstat (limited to 'gentoobrowse-api/service/main.cpp')
-rw-r--r-- | gentoobrowse-api/service/main.cpp | 39 |
1 files changed, 8 insertions, 31 deletions
diff --git a/gentoobrowse-api/service/main.cpp b/gentoobrowse-api/service/main.cpp index fcab795..21473af 100644 --- a/gentoobrowse-api/service/main.cpp +++ b/gentoobrowse-api/service/main.cpp @@ -1,39 +1,16 @@ -#include <Ice/Ice.h> -#include <IceBox/IceBox.h> -#include <visibility.h> +#include <Ice/Communicator.h> +#include <Ice/ObjectAdapter.h> +#include <icetrayService.h> #include "portageimpl.h" -#include <connectionPool.h> -class Api : public IceBox::Service { +class Api : public IceTray::Service { public: - typedef boost::shared_ptr<DB::ConnectionPool> DBCPoolPtr; - void start(const std::string & name, const Ice::CommunicatorPtr & ic, const Ice::StringSeq &) + void addObjects(const std::string &, const Ice::CommunicatorPtr & ic, const Ice::StringSeq &, const Ice::ObjectAdapterPtr & adp) override { - db = DBCPoolPtr(new DB::ConnectionPool( - ic->getProperties()->getPropertyAsIntWithDefault(name + ".Database.PoolMax", 10), - ic->getProperties()->getPropertyAsIntWithDefault(name + ".Database.PoolKeep", 2), - "postgresql", - ic->getProperties()->getProperty(name + ".Database.ConnectionString"))); - adp = ic->createObjectAdapter(name); - adp->add(new Portage(*db), ic->stringToIdentity("portage")); - adp->activate(); + auto db = getConnectionPool(ic, "postgresql", "GentooBrowseAPI"); + adp->add(new Portage(db), ic->stringToIdentity("portage")); } - void stop() - { - adp->deactivate(); - adp->destroy(); - } - - DBCPoolPtr db; - Ice::ObjectAdapterPtr adp; }; -extern "C" { - DLL_PUBLIC - IceBox::Service * - createGentooBrowseAPI(Ice::CommunicatorPtr) - { - return new Api(); - } -} +NAMEDFACTORY("default", Api, IceTray::ServiceFactory); |