summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Ice/PluginManagerI.cpp63
-rw-r--r--cpp/src/Ice/PluginManagerI.h3
-rw-r--r--cpp/src/Ice/PropertyNames.cpp6
-rw-r--r--cpp/src/Ice/PropertyNames.h2
4 files changed, 66 insertions, 8 deletions
diff --git a/cpp/src/Ice/PluginManagerI.cpp b/cpp/src/Ice/PluginManagerI.cpp
index 7d65df2234c..c5cf4648f0e 100644
--- a/cpp/src/Ice/PluginManagerI.cpp
+++ b/cpp/src/Ice/PluginManagerI.cpp
@@ -19,10 +19,55 @@ using namespace std;
using namespace Ice;
using namespace IceInternal;
-const char * const Ice::PluginManagerI::_kindOfObject = "plug-in";
+const char * const Ice::PluginManagerI::_kindOfObject = "plugin";
typedef Ice::Plugin* (*PLUGIN_FACTORY)(const CommunicatorPtr&, const string&, const StringSeq&);
+void
+Ice::PluginManagerI::initializePlugins()
+{
+ if(_initialized)
+ {
+ InitializationException ex(__FILE__, __LINE__);
+ ex.reason = "plugins already initialized";
+ throw ex;
+ }
+
+ //
+ // Invoke initialize() on the plugins, in the order they were loaded.
+ //
+ vector<PluginPtr> initializedPlugins;
+ try
+ {
+ for(vector<PluginPtr>::iterator p = _initOrder.begin(); p != _initOrder.end(); ++p)
+ {
+ (*p)->initialize();
+ initializedPlugins.push_back(*p);
+ }
+ }
+ catch(...)
+ {
+ //
+ // Destroy the plugins that have been successfully initialized, in the
+ // reverse order.
+ //
+ for(vector<PluginPtr>::reverse_iterator p = initializedPlugins.rbegin(); p != initializedPlugins.rend(); ++p)
+ {
+ try
+ {
+ (*p)->destroy();
+ }
+ catch(...)
+ {
+ // Ignore.
+ }
+ }
+ throw;
+ }
+
+ _initialized = true;
+}
+
PluginPtr
Ice::PluginManagerI::getPlugin(const string& name)
{
@@ -88,7 +133,8 @@ Ice::PluginManagerI::destroy()
Ice::PluginManagerI::PluginManagerI(const CommunicatorPtr& communicator, const DynamicLibraryListPtr& libraries) :
_communicator(communicator),
- _libraries(libraries)
+ _libraries(libraries),
+ _initialized(false)
{
}
@@ -115,7 +161,7 @@ Ice::PluginManagerI::loadPlugins(int& argc, char* argv[])
PropertyDict plugins = properties->getPropertiesForPrefix(prefix);
string loadOrder = properties->getProperty("Ice.PluginLoadOrder");
- string::size_type beg = 0;
+ string::size_type beg = 0;
if(!loadOrder.empty())
{
const string delim = ", \t\n";
@@ -169,6 +215,16 @@ Ice::PluginManagerI::loadPlugins(int& argc, char* argv[])
}
stringSeqToArgs(cmdArgs, argc, argv);
+
+ //
+ // An application can set Ice.InitPlugins=0 if it wants to postpone
+ // initialization until after it has interacted directly with the
+ // plugins.
+ //
+ if(properties->getPropertyAsIntWithDefault("Ice.InitPlugins", 1) > 0)
+ {
+ initializePlugins();
+ }
}
void
@@ -253,4 +309,5 @@ Ice::PluginManagerI::loadPlugin(const string& name, const string& pluginSpec, St
_libraries->add(library);
_plugins[name] = plugin;
+ _initOrder.push_back(plugin);
}
diff --git a/cpp/src/Ice/PluginManagerI.h b/cpp/src/Ice/PluginManagerI.h
index 7b766f95eb8..5a5460c2427 100644
--- a/cpp/src/Ice/PluginManagerI.h
+++ b/cpp/src/Ice/PluginManagerI.h
@@ -25,6 +25,7 @@ class PluginManagerI : public PluginManager, public IceUtil::Mutex
{
public:
+ virtual void initializePlugins();
virtual PluginPtr getPlugin(const std::string&);
virtual void addPlugin(const std::string&, const PluginPtr&);
virtual void destroy();
@@ -41,6 +42,8 @@ private:
IceInternal::DynamicLibraryListPtr _libraries;
std::map<std::string, PluginPtr> _plugins;
+ std::vector<PluginPtr> _initOrder;
+ bool _initialized;
static const char * const _kindOfObject;
};
diff --git a/cpp/src/Ice/PropertyNames.cpp b/cpp/src/Ice/PropertyNames.cpp
index 2d58eef25f6..002e9720f4a 100644
--- a/cpp/src/Ice/PropertyNames.cpp
+++ b/cpp/src/Ice/PropertyNames.cpp
@@ -7,7 +7,7 @@
//
// **********************************************************************
-// Generated by makeprops.py from file `../config/PropertyNames.def', Mon Apr 17 10:30:14 2006
+// Generated by makeprops.py from file `../config/PropertyNames.def', Tue Apr 25 16:28:52 2006
// IMPORTANT: Do not edit this file -- any edits made here will be lost!
@@ -28,6 +28,7 @@ const char* IceInternal::PropertyNames::IceProps[] =
"Ice.Default.Protocol",
"Ice.Default.Router",
"Ice.GC.Interval",
+ "Ice.InitPlugins",
"Ice.Logger.Timestamp",
"Ice.MessageSizeMax",
"Ice.MonitorConnections",
@@ -208,13 +209,10 @@ const char* IceInternal::PropertyNames::IceSSLProps[] =
"IceSSL.CertAuthDir",
"IceSSL.CertAuthFile",
"IceSSL.CertFile",
- "IceSSL.Certs",
- "IceSSL.CertsPassword",
"IceSSL.CheckCertName",
"IceSSL.CheckCRL",
"IceSSL.Ciphers",
"IceSSL.DefaultDir",
- "IceSSL.DelayInit",
"IceSSL.DH.*",
"IceSSL.EntropyDaemon",
"IceSSL.ImportCert.*.*",
diff --git a/cpp/src/Ice/PropertyNames.h b/cpp/src/Ice/PropertyNames.h
index 98446db0f6a..9f72cdaad0d 100644
--- a/cpp/src/Ice/PropertyNames.h
+++ b/cpp/src/Ice/PropertyNames.h
@@ -7,7 +7,7 @@
//
// **********************************************************************
-// Generated by makeprops.py from file `../config/PropertyNames.def', Mon Apr 17 10:30:14 2006
+// Generated by makeprops.py from file `../config/PropertyNames.def', Tue Apr 25 16:28:52 2006
// IMPORTANT: Do not edit this file -- any edits made here will be lost!