summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cpp/config/PropertyNames.def1
-rw-r--r--cpp/src/Ice/Instance.cpp6
-rw-r--r--cpp/src/Ice/PluginManagerI.cpp57
-rw-r--r--cpp/src/Ice/PluginManagerI.h6
-rw-r--r--cpp/src/Ice/PropertyNames.cpp3
-rw-r--r--cpp/src/Ice/PropertyNames.h2
-rwxr-xr-xcs/src/Ice/Instance.cs5
-rwxr-xr-xcs/src/Ice/PluginManagerI.cs124
-rw-r--r--cs/src/Ice/PropertyNames.cs3
9 files changed, 160 insertions, 47 deletions
diff --git a/cpp/config/PropertyNames.def b/cpp/config/PropertyNames.def
index d663066c1e7..96f9e4433e9 100644
--- a/cpp/config/PropertyNames.def
+++ b/cpp/config/PropertyNames.def
@@ -143,6 +143,7 @@ Ice:
GC.Interval
ImplicitContext
InitPlugins
+ LoggerPlugin
MessageSizeMax
MonitorConnections
Nohup
diff --git a/cpp/src/Ice/Instance.cpp b/cpp/src/Ice/Instance.cpp
index fe3a13ff113..8cf07bdf2e4 100644
--- a/cpp/src/Ice/Instance.cpp
+++ b/cpp/src/Ice/Instance.cpp
@@ -743,6 +743,12 @@ IceInternal::Instance::finishSetup(int& argc, char* argv[])
assert(pluginManagerImpl);
pluginManagerImpl->loadPlugins(argc, argv);
+ LoggerPtr logger = pluginManagerImpl->getLogger();
+ if(logger)
+ {
+ _initData.logger = logger;
+ }
+
//
// Get default router and locator proxies. Don't move this
// initialization before the plug-in initialization!!! The proxies
diff --git a/cpp/src/Ice/PluginManagerI.cpp b/cpp/src/Ice/PluginManagerI.cpp
index c5cf4648f0e..bcb91b667d0 100644
--- a/cpp/src/Ice/PluginManagerI.cpp
+++ b/cpp/src/Ice/PluginManagerI.cpp
@@ -22,6 +22,7 @@ using namespace IceInternal;
const char * const Ice::PluginManagerI::_kindOfObject = "plugin";
typedef Ice::Plugin* (*PLUGIN_FACTORY)(const CommunicatorPtr&, const string&, const StringSeq&);
+typedef Ice::Logger* (*LOGGER_FACTORY)(const CommunicatorPtr&, const StringSeq&);
void
Ice::PluginManagerI::initializePlugins()
@@ -125,6 +126,7 @@ Ice::PluginManagerI::destroy()
r->second = 0;
}
+ _logger = 0;
_communicator = 0;
}
@@ -192,7 +194,7 @@ Ice::PluginManagerI::loadPlugins(int& argc, char* argv[])
PropertyDict::iterator q = plugins.find("Ice.Plugin." + name);
if(q != plugins.end())
{
- loadPlugin(name, q->second, cmdArgs);
+ loadPlugin(name, q->second, cmdArgs, false);
plugins.erase(q);
}
else
@@ -211,7 +213,13 @@ Ice::PluginManagerI::loadPlugins(int& argc, char* argv[])
for(p = plugins.begin(); p != plugins.end(); ++p)
{
string name = p->first.substr(prefix.size());
- loadPlugin(name, p->second, cmdArgs);
+ loadPlugin(name, p->second, cmdArgs, false);
+ }
+
+ string loggerStr = properties->getProperty("Ice.LoggerPlugin");
+ if(loggerStr.length() != 0)
+ {
+ loadPlugin("Logger", loggerStr, cmdArgs, true);
}
stringSeqToArgs(cmdArgs, argc, argv);
@@ -228,7 +236,7 @@ Ice::PluginManagerI::loadPlugins(int& argc, char* argv[])
}
void
-Ice::PluginManagerI::loadPlugin(const string& name, const string& pluginSpec, StringSeq& cmdArgs)
+Ice::PluginManagerI::loadPlugin(const string& name, const string& pluginSpec, StringSeq& cmdArgs, bool isLogger)
{
assert(_communicator);
@@ -296,18 +304,41 @@ Ice::PluginManagerI::loadPlugin(const string& name, const string& pluginSpec, St
// Invoke the factory function. No exceptions can be raised
// by the factory function because it's declared extern "C".
//
- PLUGIN_FACTORY factory = (PLUGIN_FACTORY)sym;
- plugin = factory(_communicator, name, args);
- if(!plugin)
+ if(isLogger)
{
- PluginInitializationException e(__FILE__, __LINE__);
- ostringstream out;
- out << "failure in entry point `" << entryPoint << "'";
- e.reason = out.str();
- throw e;
+ LOGGER_FACTORY factory = (LOGGER_FACTORY)sym;
+ _logger = factory(_communicator, args);
+ if(!_logger)
+ {
+ PluginInitializationException e(__FILE__, __LINE__);
+ ostringstream out;
+ out << "failure in entry point `" << entryPoint << "'";
+ e.reason = out.str();
+ throw e;
+ }
}
+ else
+ {
+ PLUGIN_FACTORY factory = (PLUGIN_FACTORY)sym;
+ plugin = factory(_communicator, name, args);
+ if(!plugin)
+ {
+ PluginInitializationException e(__FILE__, __LINE__);
+ ostringstream out;
+ out << "failure in entry point `" << entryPoint << "'";
+ e.reason = out.str();
+ throw e;
+ }
+ _plugins[name] = plugin;
+ _initOrder.push_back(plugin);
+ }
_libraries->add(library);
- _plugins[name] = plugin;
- _initOrder.push_back(plugin);
}
+
+Ice::LoggerPtr
+Ice::PluginManagerI::getLogger() const
+{
+ return _logger;
+}
+
diff --git a/cpp/src/Ice/PluginManagerI.h b/cpp/src/Ice/PluginManagerI.h
index 5a5460c2427..042515c06d6 100644
--- a/cpp/src/Ice/PluginManagerI.h
+++ b/cpp/src/Ice/PluginManagerI.h
@@ -13,6 +13,7 @@
#include <Ice/Plugin.h>
#include <Ice/InstanceF.h>
#include <Ice/CommunicatorF.h>
+#include <Ice/LoggerF.h>
#include <Ice/DynamicLibraryF.h>
#include <Ice/BuiltinSequences.h>
#include <IceUtil/Mutex.h>
@@ -36,7 +37,8 @@ private:
friend class IceInternal::Instance;
void loadPlugins(int&, char*[]);
- void loadPlugin(const std::string&, const std::string&, StringSeq&);
+ void loadPlugin(const std::string&, const std::string&, StringSeq&, bool);
+ LoggerPtr getLogger() const;
CommunicatorPtr _communicator;
IceInternal::DynamicLibraryListPtr _libraries;
@@ -45,6 +47,8 @@ private:
std::vector<PluginPtr> _initOrder;
bool _initialized;
static const char * const _kindOfObject;
+
+ LoggerPtr _logger;
};
}
diff --git a/cpp/src/Ice/PropertyNames.cpp b/cpp/src/Ice/PropertyNames.cpp
index c4be2fac535..2449070ce72 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 Dec 4 13:26:07 2006
+// Generated by makeprops.py from file `./config/PropertyNames.def', Mon Dec 11 11:13:50 2006
// IMPORTANT: Do not edit this file -- any edits made here will be lost!
@@ -45,6 +45,7 @@ const char* IceInternal::PropertyNames::IceProps[] =
"Ice.GC.Interval",
"Ice.ImplicitContext",
"Ice.InitPlugins",
+ "Ice.LoggerPlugin",
"Ice.MessageSizeMax",
"Ice.MonitorConnections",
"Ice.Nohup",
diff --git a/cpp/src/Ice/PropertyNames.h b/cpp/src/Ice/PropertyNames.h
index f28e0c564be..5df9ba17997 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 Dec 4 13:26:07 2006
+// Generated by makeprops.py from file `./config/PropertyNames.def', Mon Dec 11 11:13:50 2006
// IMPORTANT: Do not edit this file -- any edits made here will be lost!
diff --git a/cs/src/Ice/Instance.cs b/cs/src/Ice/Instance.cs
index c97ec5d8079..ca581f40123 100755
--- a/cs/src/Ice/Instance.cs
+++ b/cs/src/Ice/Instance.cs
@@ -475,6 +475,11 @@ namespace IceInternal
//
Ice.PluginManagerI pluginManagerImpl = (Ice.PluginManagerI)_pluginManager;
pluginManagerImpl.loadPlugins(ref args);
+ Ice.Logger logger = pluginManagerImpl.getLogger();
+ if(logger != null)
+ {
+ _initData.logger = logger;
+ }
//
// Get default router and locator proxies. Don't move this
diff --git a/cs/src/Ice/PluginManagerI.cs b/cs/src/Ice/PluginManagerI.cs
index ca7032df81d..f152b9c1f82 100755
--- a/cs/src/Ice/PluginManagerI.cs
+++ b/cs/src/Ice/PluginManagerI.cs
@@ -17,6 +17,11 @@ namespace Ice
Plugin create(Communicator communicator, string name, string[] args);
}
+ public interface LoggerFactory
+ {
+ Logger create(Communicator communicator, string[] args);
+ }
+
public sealed class PluginManagerI : LocalObjectImpl, PluginManager
{
private static string _kindOfObject = "plugin";
@@ -118,6 +123,7 @@ namespace Ice
plugin.destroy();
}
+ _logger = null;
_communicator = null;
}
}
@@ -178,7 +184,7 @@ namespace Ice
if(plugins.Contains(key))
{
string value = (string)plugins[key];
- loadPlugin(names[i], value, ref cmdArgs);
+ loadPlugin(names[i], value, ref cmdArgs, false);
plugins.Remove(key);
}
else
@@ -197,9 +203,18 @@ namespace Ice
{
string name = ((string)entry.Key).Substring(prefix.Length);
string val = (string)entry.Value;
- loadPlugin(name, val, ref cmdArgs);
+ loadPlugin(name, val, ref cmdArgs, false);
}
+ //
+ // Check for a Logger Plugin
+ //
+ string loggerStr = properties.getProperty("Ice.LoggerPlugin");
+ if(loggerStr.Length != 0)
+ {
+ loadPlugin("Logger", loggerStr, ref cmdArgs, true);
+ }
+
//
// An application can set Ice.InitPlugins=0 if it wants to postpone
// initialization until after it has interacted directly with the
@@ -211,7 +226,7 @@ namespace Ice
}
}
- private void loadPlugin(string name, string pluginSpec, ref string[] cmdArgs)
+ private void loadPlugin(string name, string pluginSpec, ref string[] cmdArgs, bool isLogger)
{
Debug.Assert(_communicator != null);
@@ -308,7 +323,8 @@ namespace Ice
//
// Instantiate the class.
//
- PluginFactory factory = null;
+ PluginFactory pluginFactory = null;
+ LoggerFactory loggerFactory = null;
string className = entryPoint.Substring(sepPos + 1);
System.Type c = pluginAssembly.GetType(className);
if(c == null)
@@ -320,18 +336,31 @@ namespace Ice
try
{
- factory = (PluginFactory)IceInternal.AssemblyUtil.createInstance(c);
- if(factory == null)
+ if(isLogger)
{
- PluginInitializationException e = new PluginInitializationException();
- e.reason = err + "Can't find constructor for '" + className + "'";
- throw e;
+ loggerFactory = (LoggerFactory)IceInternal.AssemblyUtil.createInstance(c);
+ if(loggerFactory == null)
+ {
+ PluginInitializationException e = new PluginInitializationException();
+ e.reason = err + "Can't find constructor for '" + className + "'";
+ throw e;
+ }
+ }
+ else
+ {
+ pluginFactory = (PluginFactory)IceInternal.AssemblyUtil.createInstance(c);
+ if(pluginFactory == null)
+ {
+ PluginInitializationException e = new PluginInitializationException();
+ e.reason = err + "Can't find constructor for '" + className + "'";
+ throw e;
+ }
}
}
catch(System.InvalidCastException ex)
{
PluginInitializationException e = new PluginInitializationException(ex);
- e.reason = err + "InvalidCastException to Ice.PluginFactory";
+ e.reason = err + "InvalidCastException to " + (isLogger ? "Ice.LoggerFactory" : "Ice.PluginFactory");
throw e;
}
catch(System.UnauthorizedAccessException ex)
@@ -350,37 +379,72 @@ namespace Ice
//
// Invoke the factory.
//
- Plugin plugin = null;
- try
+ if(isLogger)
{
- plugin = factory.create(_communicator, name, args);
- }
- catch(PluginInitializationException ex)
- {
- ex.reason = err + ex.reason;
- throw ex;
+ try
+ {
+ _logger = loggerFactory.create(_communicator, args);
+ }
+ catch(PluginInitializationException ex)
+ {
+ ex.reason = err + ex.reason;
+ throw ex;
+ }
+ catch(System.Exception ex)
+ {
+ PluginInitializationException e = new PluginInitializationException(ex);
+ e.reason = err + "System.Exception in factory.create: " + ex.ToString();
+ throw e;
+ }
+
+ if(_logger == null)
+ {
+ PluginInitializationException ex = new PluginInitializationException();
+ ex.reason = err + "factory.create returned null logger";
+ throw ex;
+ }
}
- catch(System.Exception ex)
+ else
{
- PluginInitializationException e = new PluginInitializationException(ex);
- e.reason = err + "System.Exception in factory.create: " + ex.ToString();
- throw e;
- }
+ Plugin plugin = null;
+ try
+ {
+ plugin = pluginFactory.create(_communicator, name, args);
+ }
+ catch(PluginInitializationException ex)
+ {
+ ex.reason = err + ex.reason;
+ throw ex;
+ }
+ catch(System.Exception ex)
+ {
+ PluginInitializationException e = new PluginInitializationException(ex);
+ e.reason = err + "System.Exception in factory.create: " + ex.ToString();
+ throw e;
+ }
- if(plugin == null)
- {
- PluginInitializationException ex = new PluginInitializationException();
- ex.reason = err + "factory.create returned null plug-in";
- throw ex;
+ if(plugin == null)
+ {
+ PluginInitializationException ex = new PluginInitializationException();
+ ex.reason = err + "factory.create returned null plug-in";
+ throw ex;
+ }
+
+ _plugins[name] = plugin;
+ _initOrder.Add(plugin);
}
+ }
- _plugins[name] = plugin;
- _initOrder.Add(plugin);
+ public Logger
+ getLogger()
+ {
+ return _logger;
}
private Communicator _communicator;
private Hashtable _plugins;
private ArrayList _initOrder;
+ private Logger _logger = null;
private bool _initialized;
private static bool _sslWarnOnce = false;
}
diff --git a/cs/src/Ice/PropertyNames.cs b/cs/src/Ice/PropertyNames.cs
index ac6e16918b2..34b02d34f6a 100644
--- a/cs/src/Ice/PropertyNames.cs
+++ b/cs/src/Ice/PropertyNames.cs
@@ -7,7 +7,7 @@
//
// **********************************************************************
-// Generated by makeprops.py from file `./config/PropertyNames.def', Mon Dec 4 13:26:07 2006
+// Generated by makeprops.py from file `./config/PropertyNames.def', Mon Dec 11 11:13:50 2006
// IMPORTANT: Do not edit this file -- any edits made here will be lost!
@@ -47,6 +47,7 @@ namespace IceInternal
@"^Ice\.GC\.Interval$",
@"^Ice\.ImplicitContext$",
@"^Ice\.InitPlugins$",
+ @"^Ice\.LoggerPlugin$",
@"^Ice\.MessageSizeMax$",
@"^Ice\.MonitorConnections$",
@"^Ice\.Nohup$",