diff options
author | Benoit Foucher <benoit@zeroc.com> | 2013-07-03 13:32:02 +0200 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2013-07-03 13:32:02 +0200 |
commit | 811c0f63533cfa3bb89945c7792609ebde700777 (patch) | |
tree | dd7586cf1f6ee111334895ca65ae3ef8eb00b3bc /cpp/src | |
parent | Win32 build fixes with optional test (diff) | |
download | ice-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')
-rw-r--r-- | cpp/src/IceGrid/DB.h | 1 | ||||
-rw-r--r-- | cpp/src/IceGrid/FreezeDB/FreezeDB.cpp | 39 | ||||
-rw-r--r-- | cpp/src/IceGrid/FreezeDB/FreezeDB.h | 1 | ||||
-rw-r--r-- | cpp/src/IceGrid/RegistryI.cpp | 6 | ||||
-rw-r--r-- | cpp/src/IceGrid/SqlDB/SqlDB.cpp | 49 | ||||
-rw-r--r-- | cpp/src/IceGrid/SqlDB/SqlDB.h | 1 |
6 files changed, 62 insertions, 35 deletions
diff --git a/cpp/src/IceGrid/DB.h b/cpp/src/IceGrid/DB.h index 0bc032b6759..d16a28d597e 100644 --- a/cpp/src/IceGrid/DB.h +++ b/cpp/src/IceGrid/DB.h @@ -53,6 +53,7 @@ class DatabasePlugin : virtual public Ice::Plugin { public: + virtual bool initDB() = 0; virtual ConnectionPoolPtr getConnectionPool() = 0; }; typedef IceUtil::Handle<DatabasePlugin> DatabasePluginPtr; diff --git a/cpp/src/IceGrid/FreezeDB/FreezeDB.cpp b/cpp/src/IceGrid/FreezeDB/FreezeDB.cpp index 5cf4689416c..06faa62a020 100644 --- a/cpp/src/IceGrid/FreezeDB/FreezeDB.cpp +++ b/cpp/src/IceGrid/FreezeDB/FreezeDB.cpp @@ -131,36 +131,47 @@ FreezeConnectionPool::getInternalObjects(const IceDB::DatabaseConnectionPtr& con FreezeDBPlugin::FreezeDBPlugin(const Ice::CommunicatorPtr& communicator) : _communicator(communicator) { +} + +void +FreezeDBPlugin::initialize() +{ +} + +void +FreezeDBPlugin::destroy() +{ + _connectionPool = 0; +} + +bool +FreezeDBPlugin::initDB() +{ string dbPath = _communicator->getProperties()->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; } } _communicator->getProperties()->setProperty("Freeze.DbEnv.Registry.DbHome", dbPath); -} -void -FreezeDBPlugin::initialize() -{ _connectionPool = new FreezeConnectionPool(_communicator); -} -void -FreezeDBPlugin::destroy() -{ - _connectionPool = 0; + return true; } ConnectionPoolPtr diff --git a/cpp/src/IceGrid/FreezeDB/FreezeDB.h b/cpp/src/IceGrid/FreezeDB/FreezeDB.h index 4596a4d0d3d..9a0c7c05588 100644 --- a/cpp/src/IceGrid/FreezeDB/FreezeDB.h +++ b/cpp/src/IceGrid/FreezeDB/FreezeDB.h @@ -39,6 +39,7 @@ public: void initialize(); void destroy(); + bool initDB(); ConnectionPoolPtr getConnectionPool(); private: diff --git a/cpp/src/IceGrid/RegistryI.cpp b/cpp/src/IceGrid/RegistryI.cpp index 7c763c964b3..a0dd9389099 100644 --- a/cpp/src/IceGrid/RegistryI.cpp +++ b/cpp/src/IceGrid/RegistryI.cpp @@ -372,7 +372,11 @@ RegistryI::startImpl() out << "no database plugin configured with `Ice.Plugin.DB' or plugin is not a database plugin"; return false; } - + if(!plugin->initDB()) + { + return false; + } + _database = new Database(registryAdapter, topicManager, _instanceName, _traceLevels, getInfo(), plugin, _readonly); _wellKnownObjects = new WellKnownObjectsManager(_database); 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() { diff --git a/cpp/src/IceGrid/SqlDB/SqlDB.h b/cpp/src/IceGrid/SqlDB/SqlDB.h index 99220a5a52b..f84ed4d0d6c 100644 --- a/cpp/src/IceGrid/SqlDB/SqlDB.h +++ b/cpp/src/IceGrid/SqlDB/SqlDB.h @@ -54,6 +54,7 @@ public: virtual void initialize(); virtual void destroy(); + bool initDB(); ConnectionPoolPtr getConnectionPool(); private: |