diff options
Diffstat (limited to 'gentoobrowse-api/service/main.cpp')
-rw-r--r-- | gentoobrowse-api/service/main.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/gentoobrowse-api/service/main.cpp b/gentoobrowse-api/service/main.cpp new file mode 100644 index 0000000..fcab795 --- /dev/null +++ b/gentoobrowse-api/service/main.cpp @@ -0,0 +1,39 @@ +#include <Ice/Ice.h> +#include <IceBox/IceBox.h> +#include <visibility.h> +#include "portageimpl.h" +#include <connectionPool.h> + +class Api : public IceBox::Service { + public: + typedef boost::shared_ptr<DB::ConnectionPool> DBCPoolPtr; + void start(const std::string & name, const Ice::CommunicatorPtr & ic, const Ice::StringSeq &) + { + 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(); + } + void stop() + { + adp->deactivate(); + adp->destroy(); + } + + DBCPoolPtr db; + Ice::ObjectAdapterPtr adp; +}; + +extern "C" { + DLL_PUBLIC + IceBox::Service * + createGentooBrowseAPI(Ice::CommunicatorPtr) + { + return new Api(); + } +} + |