summaryrefslogtreecommitdiff
path: root/cpp/src/IceGrid/SqlDB/SqlDB.cpp
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2013-07-03 13:32:02 +0200
committerBenoit Foucher <benoit@zeroc.com>2013-07-03 13:32:02 +0200
commit811c0f63533cfa3bb89945c7792609ebde700777 (patch)
treedd7586cf1f6ee111334895ca65ae3ef8eb00b3bc /cpp/src/IceGrid/SqlDB/SqlDB.cpp
parentWin32 build fixes with optional test (diff)
downloadice-811c0f63533cfa3bb89945c7792609ebde700777.tar.bz2
ice-811c0f63533cfa3bb89945c7792609ebde700777.tar.xz
ice-811c0f63533cfa3bb89945c7792609ebde700777.zip
Fixed ICE-5371 - fixed IceGrid registry executable to not require data property to be set to get help or the version with -h/-v
Diffstat (limited to 'cpp/src/IceGrid/SqlDB/SqlDB.cpp')
-rw-r--r--cpp/src/IceGrid/SqlDB/SqlDB.cpp49
1 files changed, 29 insertions, 20 deletions
diff --git a/cpp/src/IceGrid/SqlDB/SqlDB.cpp b/cpp/src/IceGrid/SqlDB/SqlDB.cpp
index 14f441fa58d..2d3b58c9a39 100644
--- a/cpp/src/IceGrid/SqlDB/SqlDB.cpp
+++ b/cpp/src/IceGrid/SqlDB/SqlDB.cpp
@@ -12,6 +12,7 @@
#include <Ice/Communicator.h>
#include <Ice/Locator.h>
#include <Ice/Instance.h>
+#include <Ice/LoggerUtil.h>
#include <IceDB/SqlTypes.h>
#include <IceGrid/SqlDB/SqlDB.h>
@@ -168,6 +169,27 @@ SqlDBPlugin::~SqlDBPlugin()
void
SqlDBPlugin::initialize()
{
+}
+
+void
+SqlDBPlugin::destroy()
+{
+ //
+ // Break cyclic reference count (thread hook holds a reference on the cache and the cache holds
+ // a reference on the communicator through the SQL dictionaries).
+ //
+ SqlDB::ThreadHookPtr threadHook =
+ SqlDB::ThreadHookPtr::dynamicCast(IceInternal::getInstance(_communicator)->initializationData().threadHook);
+ if(threadHook)
+ {
+ threadHook->setConnectionPool(0);
+ }
+ _connectionPool = 0;
+}
+
+bool
+SqlDBPlugin::initDB()
+{
Ice::PropertiesPtr properties = _communicator->getProperties();
string databaseName;
string tablePrefix;
@@ -176,17 +198,20 @@ SqlDBPlugin::initialize()
string dbPath = properties->getProperty("IceGrid.Registry.Data");
if(dbPath.empty())
{
- throw Ice::PluginInitializationException(__FILE__, __LINE__, "property `IceGrid.Registry.Data' is not set");
+ Ice::Error out(_communicator->getLogger());
+ out << "property `IceGrid.Registry.Data' is not set";
+ return false;
}
else
{
if(!IceUtilInternal::directoryExists(dbPath))
{
- ostringstream os;
Ice::SyscallException ex(__FILE__, __LINE__);
ex.error = IceInternal::getSystemErrno();
- os << "property `IceGrid.Registry.Data' is set to an invalid path:\n" << ex;
- throw Ice::PluginInitializationException(__FILE__, __LINE__, os.str());
+
+ Ice::Error out(_communicator->getLogger());
+ out << "property `IceGrid.Registry.Data' is set to an invalid path:\n" << ex;
+ return false;
}
}
databaseName = dbPath + "/" + properties->getPropertyWithDefault("IceGrid.SQL.DatabaseName", "registry.db");
@@ -218,7 +243,6 @@ SqlDBPlugin::initialize()
properties->getPropertyWithDefault("IceGrid.SQL.EncodingVersion",
encodingVersionToString(Ice::currentEncoding));
-
_connectionPool = new SqlConnectionPool(_communicator,
properties->getProperty("IceGrid.SQL.DatabaseType"),
databaseName,
@@ -235,21 +259,6 @@ SqlDBPlugin::initialize()
threadHook->setConnectionPool(_connectionPool);
}
-void
-SqlDBPlugin::destroy()
-{
- //
- // Break cyclic reference count (thread hook holds a reference on the cache and the cache holds
- // a reference on the communicator through the SQL dictionaries).
- //
- SqlDB::ThreadHookPtr threadHook =
- SqlDB::ThreadHookPtr::dynamicCast(IceInternal::getInstance(_communicator)->initializationData().threadHook);
- assert(threadHook);
- threadHook->setConnectionPool(0);
-
- _connectionPool = 0;
-}
-
ConnectionPoolPtr
SqlDBPlugin::getConnectionPool()
{